/** * 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; }
/** * Check if the queue does contain a given object * * @param KCommandInterface $object * @return bool * @throws InvalidArgumentException if the object implement KCommandInterface */ public function contains(KObjectHandlable $command) { if (!$command instanceof KCommandInterface) { throw new InvalidArgumentException('Command needs to implement KCommandInterface'); } return parent::contains($command); }