CakeEventManager::_attachSubscriber PHP Method

_attachSubscriber() protected method

Auxiliary function to attach all implemented callbacks of a CakeEventListener class instance as individual methods on this manager
protected _attachSubscriber ( CakeEventListener $subscriber ) : void
$subscriber CakeEventListener
return void
    protected function _attachSubscriber(CakeEventListener $subscriber)
    {
        foreach ((array) $subscriber->implementedEvents() as $eventKey => $function) {
            $options = array();
            $method = $function;
            if (is_array($function) && isset($function['callable'])) {
                list($method, $options) = $this->_extractCallable($function, $subscriber);
            } elseif (is_array($function) && is_numeric(key($function))) {
                foreach ($function as $f) {
                    list($method, $options) = $this->_extractCallable($f, $subscriber);
                    $this->attach($method, $eventKey, $options);
                }
                continue;
            }
            if (is_string($method)) {
                $method = array($subscriber, $function);
            }
            $this->attach($method, $eventKey, $options);
        }
    }