/** * Adds the filter to the event dispatcher. * * @param string $when Either 'before' or 'after' * @param string $action * @param mixed $callback */ protected function addFilter($when, $action, $callback) { if (!is_callable($callback) && !is_array($callback)) { $callback = [$this, $callback]; } if (is_array($action)) { foreach ($action as $method) { $this->addFilter($when, $method, $callback); } } else { EventDispatcher::addListener("{$when}." . get_called_class() . "::{$action}", $callback); } }