Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/#6398-forward-controller-plugin-fluent-interface…
Browse files Browse the repository at this point in the history
…-consistency'

Close #6398
  • Loading branch information
Ocramius committed Nov 17, 2014
2 parents 529a0c8 + 1bd49a1 commit 4ab7cda
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
10 changes: 7 additions & 3 deletions library/Zend/Mvc/Controller/Plugin/Forward.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Forward extends AbstractPlugin
protected $numNestedForwards = 0;

/**
* @var array
* @var array[]|null
*/
protected $listenersToDetach = null;

Expand All @@ -55,11 +55,12 @@ public function __construct(ControllerManager $controllers)
* Set maximum number of nested forwards allowed
*
* @param int $maxNestedForwards
* @return Forward
* @return self
*/
public function setMaxNestedForwards($maxNestedForwards)
{
$this->maxNestedForwards = (int) $maxNestedForwards;

return $this;
}

Expand Down Expand Up @@ -94,11 +95,14 @@ public function getListenersToDetach()
* Set information on listeners that need to be detached before dispatching.
*
* @param array $listeners Listener information; see getListenersToDetach() for details on format.
* @return void
*
* @return self
*/
public function setListenersToDetach($listeners)
{
$this->listenersToDetach = $listeners;

return $this;
}

/**
Expand Down
28 changes: 28 additions & 0 deletions tests/ZendTest/Mvc/Controller/Plugin/ForwardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@

class ForwardTest extends TestCase
{
/**
* @var PluginManager
*/
private $plugins;

/**
* @var ControllerManager
*/
private $controllers;

/**
* @var SampleController
*/
private $controller;

/**
* @var \Zend\Mvc\Controller\Plugin\Forward
*/
private $plugin;

public function setUp()
{
StaticEventManager::resetInstance();
Expand Down Expand Up @@ -193,4 +213,12 @@ public function testAllowsPassingEmptyArrayOfRouteParams()
$this->assertTrue(isset($result['params']));
$this->assertEquals(array(), $result['params']);
}

/**
* @group 6398
*/
public function testSetListenersToDetachIsFluent()
{
$this->assertSame($this->plugin, $this->plugin->setListenersToDetach(array()));
}
}

0 comments on commit 4ab7cda

Please sign in to comment.