/** * Inserts an entity into the identity map. It uses the keys to uniquely identifies an entity * * @param AnDomainEntityAbstract $entity The entity to insert * @param array $identifiers An array of identifiying keys that uniquely identifies an entity * * @return void */ public function insertEntity($entity, $identifiers = array()) { //check if an entity has already been added //if not then add it to the bottom if (!$this->_entities->getPriority($entity)) { $priority = count($this->_entities); $this->_entities->enqueue($entity, $priority); } //get all the entity parent classes $classes = $entity->getEntityDescription()->getUniqueIdentifiers(); $description = $entity->getEntityDescription(); foreach ($identifiers as $key => $value) { if (empty($value)) { continue; } $property = $description->getProperty($key); $value = $property->serialize($value); $value = implode('', $value); //use the identifier application as the unique context $key = $entity->getIdentifier()->application . $key . $value; foreach ($classes as $class) { if (!isset($this->_identity_map[$class])) { $this->_identity_map[$class] = array(); } $this->_identity_map[$class][$key] = $entity; } } }
/** * Add a filter to the queue based on priority * * @param KFilterInterface $filter A Filter * @param integer $priority The command priority, usually between 1 (high priority) and 5 (lowest), * default is 3. If no priority is set, the command priority will be used * instead. * * @return KFilterChain */ public function addFilter(KFilterInterface $filter, $priority = null) { //Store reference to be used for filter chaining $this->_last = $filter; //Enqueue the filter $this->_queue->enqueue($filter, $priority); return $this; }
/** * Attach a transport handler * * @param mixed $transport An object that implements ObjectInterface, ObjectIdentifier object * or valid identifier string * @param array $config An optional associative array of configuration settings * @return KDispatcherResponseAbstract */ public function attachTransport($transport, $config = array()) { if (!$transport instanceof KDispatcherResponseTransportInterface) { $transport = $this->getTransport($transport, $config); } //Enqueue the transport handler in the command chain $this->_queue->enqueue($transport, $transport->getPriority()); return $this; }
/** * Attach a logger. * * @param mixed $logger An object that implements ObjectInterface, ObjectIdentifier object or valid identifier * string. * @param array $config An optional associative array of configuration settings. * @throws UnexpectedValueException if the logger does not implement ComActivitiesActivityLoggerInterface. * @return ComActivitiesControllerBehaviorLoggable */ public function attachLogger($logger, $config = array()) { $identifier = $this->getIdentifier($logger); if (!$this->__queue->hasIdentifier($identifier)) { $logger = $this->getObject($identifier, $config); if (!$logger instanceof ComActivitiesActivityLoggerInterface) { throw new UnexpectedValueException("Logger {$identifier} does not implement ComActivitiesActivityLoggerInterface"); } $this->__queue->enqueue($logger, self::PRIORITY_NORMAL); } return $this; }
/** * Attach a filter for template transformation * * @param mixed $filter An object that implements ObjectInterface, ObjectIdentifier object * or valid identifier string * @param array $config An optional associative array of configuration settings * @throws UnexpectedValueException * @return KTemplateAbstract */ public function addFilter($filter, $config = array()) { //Create the complete identifier if a partial identifier was passed if (is_string($filter) && strpos($filter, '.') === false) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('template', 'filter'); $identifier['name'] = $filter; $identifier = $this->getIdentifier($identifier); } else { $identifier = $this->getIdentifier($filter); } if (!$this->hasFilter($identifier->name)) { $filter = $this->getObject($identifier, array_merge($config, array('template' => $this))); if (!$filter instanceof KTemplateFilterInterface) { throw new UnexpectedValueException("Template filter {$identifier} does not implement KTemplateFilterInterface"); } //Store the filter $this->__filters[$filter->getIdentifier()->name] = $filter; //Enqueue the filter $this->__filter_queue->enqueue($filter, $filter->getPriority()); } return $this; }
/** * Attach a command to the chain * * The priority parameter can be used to override the command priority with * enqueing the command. * * @param object A KCommand object * @param integer The command priority, usually between 1 (high priority) and 5 (lowest), * default is 3. If no priority is set, the command priority will be used * instead. * @return KCommandChain */ public function enqueue(KCommandInterface $cmd, $priority = null) { $priority = is_int($priority) ? $priority : $cmd->getPriority(); return parent::enqueue($cmd, $priority); }
/** * Attach a command to the chain * * The priority parameter can be used to override the command priority while enqueueing the command. * * @param KCommandInterface $command * @param integer $priority The command priority, usually between 1 (high priority) and 5 (lowest), * default is 3. If no priority is set, the command priority will be used * instead. * @return \KCommandChain * @throws InvalidArgumentException if the object doesn't implement KCommandInterface */ public function enqueue(KObjectHandlable $command, $priority = null) { if (!$command instanceof KCommandInterface) { throw new InvalidArgumentException('Command needs to implement KCommandInterface'); } $priority = is_int($priority) ? $priority : $command->getPriority(); return parent::enqueue($command, $priority); }
/** * Attach a command to the chain * * @param KCommandHandlerInterface $handler The command handler * @return KCommandChain */ public function addHandler(KCommandHandlerInterface $handler) { $this->__queue->enqueue($handler, $handler->getPriority()); return $this; }
/** * (non-PHPdoc). * * @see KObjectQueue::enqueue() */ public function enqueue(KObjectHandlable $object, $priority) { $this->getRepositoryEntities($object->getRepository())->insert($object); return parent::enqueue($object, $priority); }