/** * Return an array of validations for a property. * * @param AnDomainPropertyAbstract|string $property Property * * @return KConfig */ public function getValidations($property) { if (is_string($property)) { $property = $this->_description->getProperty($property); } $name = $property->getName(); if (!$this->_validations->{$name}) { $this->_validations->{$name} = new KConfig(); } return $this->_validations->{$name}; }
/** * Set a property value for a key.If value is null and the $property is required then * set the default value * * @param string $property Property name * @param mixed $value Property value * * @return void */ protected function _setPropertyValue($property, $value) { //if a value is null and it's requires set it to the default //value $property = $this->_description->getProperty($property); $name = $property->getName(); if ($property->isAttribute()) { $default = $property->getDefaultValue(); if ($value === null && $default) { $value = $default; } } $this->_property[$name] = $value; $this->_materialized[$name] = $name; }
/** * Checks to see if an entity of a class with passed in keys exists * in the map. If it exist it will return the entity if not it will return * null * * @param AnDomainDescriptionAbstract $description The entity description * @param array $identifiers The keys that uniquely identifies the entity * * @return AnDomainEntityAbstract */ public function findEntity($description, $identifiers) { $classes = $description->getUniqueIdentifiers(); foreach ($classes as $class) { foreach ($identifiers as $key => $value) { $property = $description->getProperty($key); $value = $property->serialize($value); $value = implode('', $value); //use the identifier application as the unique context $key = $description->getEntityIdentifier()->application . $key . $value; if (isset($this->_identity_map[$class][$key])) { //found an entity $entity = $this->_identity_map[$class][$key]; //only return an entity if it's still within the space if (!$this->_entities->contains($entity)) { return null; } //if the description we are using is the parent of the found entity //if not then we must have found a different entity with the common parent //as the caller repository if (!is_a($entity, $description->getEntityIdentifier()->classname)) { return null; } return $entity; } } } return null; }