/** * Serialize an entity * * @param AnDomainEntityAbstract $entity * @return array */ public function serialize($entity) { return array($this->getName() . '.' . $this->_target_parent_key => $entity->get($this->_target_parent_key)); }
/** * Called to validate an entity. By deafult it validates all the entity * properties. * * @param AnDomainEntityAbstract $entity The entity that is being validated * * @return bool */ public function validateEntity($entity) { $description = $entity->getEntityDescription(); //if entity is persisted only look at the modified //properties if ($entity->isModified()) { $properties = array_intersect_key($description->getProperty(), KConfig::unbox($entity->getModifiedData())); } else { $properties = $description->getProperty(); } foreach ($properties as $property) { $value = $entity->get($property->getName()); $entity->getValidator()->validateData($entity, $property, $value); } return $entity->getErrors()->count() === 0; }