/** * 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; }
/** * Return an array of entities. If the repository is set then return entities for the * repository * * @param AnDomainRepositoryAbstract $repository If the repository is set then return the entities * for the $repository * @return KObjectQeueue */ public function getEntities($repository = null) { return $repository ? $this->_entities->getRepositoryEntities($repository) : $this->_entities; }
/** * Get the priority of a command * * @param object A KCommand object * @param integer The command priority * @return integer The command priority */ public function getPriority(KCommandInterface $cmd) { return parent::getPriority($cmd); }
/** * Get the priority of a command * * @param KCommandInterface $object * @return integer The command priority * @throws InvalidArgumentException if the object doesn't implement KCommandInterface */ public function getPriority(KObjectHandlable $command) { if (!$command instanceof KCommandInterface) { throw new InvalidArgumentException('Command needs to implement KCommandInterface'); } return parent::getPriority($command); }
/** * Get the priority of a command * * @param KCommandHandlerInterface $handler A command handler * @return integer The command priority */ public function getHandlerPriority(KCommandHandlerInterface $handler) { return $this->__queue->getPriority($handler); }
/** * (non-PHPdoc). * * @see KObjectQueue::dequeue() */ public function dequeue(KObjectHandlable $object) { $this->getRepositoryEntities($object->getRepository())->extract($object); return parent::dequeue($object); }