Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions library/Zend/Mvc/Controller/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ public function __construct(ConfigInterface $configuration = null)
* plugin is lost.
*
* @param string $cName
* @param array $options
* @param array $params
* @return mixed
*/
public function get($name, $usePeeringServiceManagers = true)
public function get($name, $options = array(), $usePeeringServiceManagers = true)
{
$plugin = parent::get($name, $usePeeringServiceManagers);
$plugin = parent::get($name, $options, $usePeeringServiceManagers);
$this->injectController($plugin);
return $plugin;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mvc
*/

namespace ZendTest\Mvc\Controller\Plugin\TestAsset;

use Zend\Mvc\Controller\Plugin\AbstractPlugin;

class SamplePluginWithConstructor extends AbstractPlugin
{
protected $bar;

public function __construct($bar = 'baz')
{
$this->bar = $bar;
}

public function getBar()
{
return $this->bar;
}
}
17 changes: 17 additions & 0 deletions tests/ZendTest/Mvc/Controller/PluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use PHPUnit_Framework_TestCase as TestCase;
use ZendTest\Mvc\Controller\TestAsset\SampleController;
use ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePlugin;
use ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePluginWithConstructor;
use Zend\Mvc\Controller\PluginManager;

class PluginManagerTest extends TestCase
Expand Down Expand Up @@ -54,4 +55,20 @@ public function testPluginManagerInjectsControllerForExistingPlugin()
$plugin = $pluginManager->get('samplePlugin');
$this->assertEquals($controller2, $plugin->getController());
}

public function testGetWithConstrutor()
{
$pluginManager = new PluginManager;
$pluginManager->setInvokableClass('samplePlugin', 'ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePluginWithConstructor');
$plugin = $pluginManager->get('samplePlugin');
$this->assertEquals($plugin->getBar(), 'baz');
}

public function testGetWithConstrutorAndOptions()
{
$pluginManager = new PluginManager;
$pluginManager->setInvokableClass('samplePlugin', 'ZendTest\Mvc\Controller\Plugin\TestAsset\SamplePluginWithConstructor');
$plugin = $pluginManager->get('samplePlugin', 'foo');
$this->assertEquals($plugin->getBar(), 'foo');
}
}