Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
2 parents 6e2f365 + 1c84238 commit c3647f5b94753917361fe30adb718068111a208f @weierophinney weierophinney committed Sep 13, 2012
View
5 library/Zend/Mvc/Controller/PluginManager.php
@@ -81,12 +81,13 @@ public function __construct(ConfigInterface $configuration = null)
* plugin is lost.
*
* @param string $name
+ * @param mixed $options
* @param bool $usePeeringServiceManagers
* @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;
}
View
28 tests/ZendTest/Mvc/Controller/Plugin/TestAsset/SamplePluginWithConstructor.php
@@ -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;
+ }
+}
View
17 tests/ZendTest/Mvc/Controller/PluginManagerTest.php
@@ -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
@@ -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');
+ }
}

0 comments on commit c3647f5

Please sign in to comment.