public function testGetEntityIdentifierNotManageableEntity() { $entity = $this->getMock('FooEntity'); $this->setExpectedException('Oro\\Bundle\\EntityBundle\\Exception\\NotManageableEntityException', sprintf('Entity class "%s" is not manageable', get_class($entity))); $this->registry->expects($this->once())->method('getManagerForClass')->with(get_class($entity))->will($this->returnValue(null)); $this->doctrineHelper->getEntityIdentifier($entity); }
/** * {@inheritdoc} */ public function normalize(Workflow $workflow, Attribute $attribute, $attributeValue) { if (null === $attributeValue) { return null; } $this->validateAttributeValue($workflow, $attribute, $attributeValue); $identifier = $this->doctrineHelper->getEntityIdentifier($attributeValue); return $identifier ?: null; }
/** * {@inheritdoc} */ public function normalize(Workflow $workflow, Attribute $attribute, $attributeValue) { if (null === $attributeValue) { return null; } $this->validateAttributeValue($workflow, $attribute, $attributeValue); $result = []; foreach ($attributeValue as $value) { $result[] = $this->doctrineHelper->getEntityIdentifier($value); } return $result; }
/** * Compare two values for equality * * @param mixed $left * @param mixed $right * @return boolean */ protected function doCompare($left, $right) { if (is_object($left) && is_object($right)) { $leftClass = $this->doctrineHelper->getEntityClass($left); $rightClass = $this->doctrineHelper->getEntityClass($right); if ($leftClass == $rightClass && $this->doctrineHelper->isManageableEntity($left) && $this->doctrineHelper->isManageableEntity($right)) { $leftIdentifier = $this->doctrineHelper->getEntityIdentifier($left); $rightIdentifier = $this->doctrineHelper->getEntityIdentifier($right); return $leftIdentifier == $rightIdentifier; } } return $left == $right; }
/** * @param array|\Traversable $values * @return array */ protected function convertToPlainArray($values) { $result = array(); foreach ($values as $key => $value) { if (is_object($value) && $this->doctrineHelper->isManageableEntity($value)) { $result[$key] = $this->doctrineHelper->getEntityIdentifier($value); } elseif (is_array($value) || $value instanceof \Traversable) { $result[$key] = $this->convertToPlainArray($value); } else { $result[$key] = $value; } } return $result; }
/** * @param object $entity * @return Integration */ protected function reloadEntity($entity) { return $this->doctrineHelper->getEntity($this->doctrineHelper->getEntityClass($entity), $this->doctrineHelper->getEntityIdentifier($entity)); }