Esempio n. 1
0
 public function setEventStateObject(AbstractEvent $state, $morph = true)
 {
     if (!$state instanceof AbstractEvent) {
         throw new Exception\InvalidArgumentException('AbstractEvent->setStateObject: ' . 'state not instance of AbstractEvent');
     } else {
         if ($morph) {
             $this->tags->clear();
             $this->categories->clear();
             $this->target = null;
             $this->data = null;
             $this->class = '';
             $this->function = '';
             $this->namespace = '';
         }
         $this->identifier = $state->getIdentifier();
         $this->{$field} = new Types\Set(Types\Set::union($state->getTags(), $this->{$field}), array('strict' => true));
         $this->categories = new Types\Set(Types\Set::union($state->getCategories(), $this->{$field}), array('strict' => true));
         $this->target = $state->getTarget();
         $this->data = $state->getData();
         $this->class = $state->getClass();
         $this->function = $state->getFunction();
         $this->namespace = $state->getNamespace();
     }
 }
Esempio n. 2
0
 /**
  * See if an event matches the filter exactly
  * 
  * If one thing doesn't match between the event and the filter
  * then we return false, instead of only one thing matching
  * 
  * @param Falcraft\Event\Resource\AbstractEvent $event
  *      The event to compare
  * 
  * @return bool
  * 
  */
 public function isStrictlyApplicable(EventResource\AbstractEvent $event, $includeIdentifier = false)
 {
     if ($includeIdentifier) {
         if ($this->identifier != $event->getIdentifier()) {
             return false;
         }
     }
     if ($this->target != $event->getTarget() || $this->function != $event->getFunction() || $this->class != $event->getClass() || $this->namespace != $event->getNamespace() || !Types\Set::subset($event->getTagsObject(), $this->tags) || !Types\Set::subset($event->getCategoriesObject(), $this->categories)) {
         return false;
     }
     return true;
 }
Esempio n. 3
0
 /**
  * The Generic Event Constructor
  * 
  * This is implements an event, setting all the necessary fields
  * 
  * @param object $target The target of the event
  * @param string $function The function/method generating the event
  * @param string $class The class name generating the event if applicable
  * @param string $namespace The namespace of the generating point
  * @param mixed $data Any data associated with the event
  * @param array $tags An array of strings associating the event with a set of tags
  * @param array $cats An array of strings associating the event with a set of categories
  * @param array $options
  * 
  */
 public function __construct($target, $function, $class, $namespace, $data = null, array $tags = array(), array $cats = array())
 {
     parent::__construct($target, $function, $class, $namespace, $data, $tags, $cats);
     $this->identityPrefix = 'GenericEvent';
     $this->setIdentifier();
 }
Esempio n. 4
0
 /**
  * Propagate an event down through the list of handlers
  * 
  * This checks if an event has been stopped or is unstoppable
  * These can be set in the handlers themselves.
  * 
  * NOTE: PriorityQueue inherits from AbsractSortedList
  *       getList() will already be sorted with the appropriate queues
  * 
  * It's important that the event passed is a reference, so that it can
  * be potentially stopped.
  * 
  * @param Falcraft\Patterns\Resource\PublisherInterface &$p
  *              The event originator
  * @param Falcraft\Event\Resource\AbstractEvent &$e
  *              The actual event object
  * 
  */
 public function propagate(PatternsResource\PublisherInterface &$p, EventResource\AbstractEvent &$e)
 {
     // foreach doesn't guarantee proper order
     $list = $this->getList();
     $count = count($list);
     for ($i = 0; $i < $count; $i++) {
         if ($e->isUnstoppable() || !$e->isStopped()) {
             $list[$i]->notify($p, $e);
         }
     }
 }