setController() public method

Set controller
public setController ( Zend\Stdlib\DispatchableInterface $controller ) : PluginManager
$controller Zend\Stdlib\DispatchableInterface
return PluginManager
コード例 #1
0
 public function testPluginManagerInjectsControllerForExistingPlugin()
 {
     $controller1 = new SampleController();
     $pluginManager = new PluginManager();
     $pluginManager->setInvokableClass('samplePlugin', 'ZendTest\\Mvc\\Controller\\Plugin\\TestAsset\\SamplePlugin');
     $pluginManager->setController($controller1);
     // Plugin manager registers now instance of SamplePlugin
     $pluginManager->get('samplePlugin');
     $controller2 = new SampleController();
     $pluginManager->setController($controller2);
     $plugin = $pluginManager->get('samplePlugin');
     $this->assertEquals($controller2, $plugin->getController());
 }
コード例 #2
0
    /**
     * Set plugin manager
     *
     * @param  PluginManager $plugins
     * @return AbstractController
     */
    public function setPluginManager(PluginManager $plugins)
    {
        $this->plugins = $plugins;
        $this->plugins->setController($this);

        return $this;
    }
コード例 #3
0
ファイル: AbstractController.php プロジェクト: nuklehed/zf2
 /**
  * Set plugin manager
  *
  * @param  string|PluginManager $plugins
  * @return AbstractController
  * @throws Exception\InvalidArgumentException
  */
 public function setPluginManager(PluginManager $plugins)
 {
     $this->plugins = $plugins;
     if (method_exists($plugins, 'setController')) {
         $this->plugins->setController($this);
     }
     return $this;
 }