public function addResponder($actions, $responder, array $data = null)
    {
        if (!$responder instanceof ResponderInterface && !is_callable($responder)) {
            throw new \InvalidArgumentException('The $responder parameter must be either a ResponderInterface object or a callable');
        }

        $actions = (array) $actions;

        foreach ($actions as $action) {
            if (!is_string($action) || empty($action)) {
                throw new \InvalidArgumentException('The action name is invalid');
            }

            $this->responders[$action][] = $responder;

            if (isset($data)) {
                $this->data[$action] = $data;
            }
        }
    }
public function addResponder($actions, $responder, array $data = null)
    {
        if (!$responder instanceof ResponderInterface && !is_callable($responder)) {
            throw new \InvalidArgumentException('The $responder parameter must be either a ResponderInterface object or a callable');
        }

        $actions = (array) $actions;

        foreach ($actions as $action) {
            if (!is_string($action) || empty($action)) {
                throw new \InvalidArgumentException('The action name is invalid');
            }

            $this->responders[$action][] = $responder;

            if (isset($data)) {
                $this->data[$action] = $data;
            }
        }
    }
public function addResponder ( $ actions , $ responder , array $ data = null ) { if ( ! $ responder instanceof ResponderInterface && ! is_callable ( $ responder ) ) { throw new \ InvalidArgumentException ( 'The $responder parameter must be either a ResponderInterface object or a callable' ) ; } $ actions = ( array ) $ actions ; foreach ( $ actions as $ action ) { if ( ! is_string ( $ action ) || empty ( $ action ) ) { throw new \ InvalidArgumentException ( 'The action name is invalid' ) ; } $ this -> responders [ $ action ] [ ] = $ responder ; if ( isset ( $ data ) ) { $ this -> data [ $ action ] = $ data ; } } }
Assigns a responder to the given event action.

@param string|array $actions The event action(s) to assign the responder to
@param \FlameCore\EventObserver\Responder\ResponderInterface|callable $responder The responder to add
@param array $data Optional data to store for all events of the given action(s)
@throws \InvalidArgumentException if the action name is invalid.
Assigns a responder to the given event action .