/** * Add a plugin for use by this controller. * * @param Controller $plugin * @param string $name * * @return $this */ protected function registerPlugin(Controller $plugin, $name = '') { if (empty($name)) { $this->plugins->append($plugin); } else { $this->plugins->{$name} = $plugin; } /* * Allow late registration of plugins */ if ($this->running) { $this->view->addPlugin($plugin->run($this->params), $name); } return $this; }