Example #1
0
 /**
  * Remove one or more event handlers
  *
  * @param string $event An event type/namespace combo
  * @return sndsgd\event\Target
  */
 public function off($event)
 {
     list($type, $namespace) = Event::split($event);
     for ($i = count($this->eventHandlers) - 1; $i > -1; $i--) {
         $h = $this->eventHandlers[$i];
         if ($type !== null && $h->getType() !== $type) {
             continue;
         } else {
             if ($namespace !== null && $h->getNamespace() !== $namespace) {
                 continue;
             }
         }
         array_splice($this->eventHandlers, $i, 1);
     }
     return $this;
 }
Example #2
0
 /**
  * Create a new event handler
  *
  * @param string $event The type/namespace combo for an event
  */
 public function __construct($event, callable $handler)
 {
     list($this->type, $this->namespace) = Event::split($event);
     $this->handler = $handler;
 }