From b10f2293d950384d912a6bfe39f2e66dfb8446b0 Mon Sep 17 00:00:00 2001 From: Christian Gahlert Date: Mon, 17 Sep 2012 19:26:09 +0200 Subject: [PATCH 01/68] Fixed wrong imports. All unit tests seem to pass. --- src/Helper/Navigation/AbstractHelper.php | 2 +- src/Helper/Navigation/HelperInterface.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 824bfc06..8c97074d 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -15,7 +15,7 @@ use Zend\I18n\Translator\TranslatorAwareInterface; use Zend\Navigation; use Zend\Navigation\Page\AbstractPage; -use Zend\Permissions\AclInterface; +use Zend\Permissions\Acl; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View; diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index 2c65978d..080bd675 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -12,7 +12,7 @@ use Zend\I18n\Translator\Translator; use Zend\Navigation; -use Zend\Permissions\AclInterface; +use Zend\Permissions\Acl; use Zend\View\Helper\HelperInterface as BaseHelperInterface; /** From 5fb04901e056455d02f764251263ca4054625525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Gallego?= Date: Wed, 19 Sep 2012 18:20:36 +0200 Subject: [PATCH 02/68] Reorder parameters according to i18n --- src/Helper/Plural.php | 4 ++-- test/Helper/PluralTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Helper/Plural.php b/src/Helper/Plural.php index 2271324c..c6e35546 100644 --- a/src/Helper/Plural.php +++ b/src/Helper/Plural.php @@ -22,12 +22,12 @@ class Plural extends AbstractHelper { /** - * @param int $number The number that is used to decide if it's singular or plurial * @param string $singular String to use if singular * @param string $plural String to use if plural + * @param int $number The number that is used to decide if it's singular or plurial * @return string */ - public function __invoke($number, $singular, $plural) + public function __invoke($singular, $plural, $number) { if ($number > 1) { return $plural; diff --git a/test/Helper/PluralTest.php b/test/Helper/PluralTest.php index 17a2eef1..04bd1621 100644 --- a/test/Helper/PluralTest.php +++ b/test/Helper/PluralTest.php @@ -37,13 +37,13 @@ public function setUp() public function testVerifySingularString() { - $result = $this->helper->__invoke(1, 'one car', 'two cars'); + $result = $this->helper->__invoke('one car', 'two cars', 1); $this->assertEquals('one car', $result); } public function testVerifyPluralString() { - $result = $this->helper->__invoke(2, 'one car', 'two cars'); + $result = $this->helper->__invoke('one car', 'two cars', 2); $this->assertEquals('two cars', $result); } } From d445aca6badb23e3205204ca85a0fba96720cf2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Gallego?= Date: Wed, 19 Sep 2012 18:22:08 +0200 Subject: [PATCH 03/68] add it to the helper plugin manager --- src/HelperPluginManager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 517c07a3..af8fbcd5 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -64,6 +64,7 @@ class HelperPluginManager extends AbstractPluginManager 'partialloop' => 'Zend\View\Helper\PartialLoop', 'partial' => 'Zend\View\Helper\Partial', 'placeholder' => 'Zend\View\Helper\Placeholder', + 'plural' => 'Zend\View\Helper\Plural', 'renderchildmodel' => 'Zend\View\Helper\RenderChildModel', 'rendertoplaceholder' => 'Zend\View\Helper\RenderToPlaceholder', 'serverurl' => 'Zend\View\Helper\ServerUrl', From add0753063b1465516755fb5136e57f20749de83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Gallego?= Date: Thu, 20 Sep 2012 15:19:08 +0200 Subject: [PATCH 04/68] Updated to handle every cases --- src/Helper/Plural.php | 39 ----------------------------- src/HelperPluginManager.php | 1 - test/Helper/PluralTest.php | 49 ------------------------------------- 3 files changed, 89 deletions(-) delete mode 100644 src/Helper/Plural.php delete mode 100644 test/Helper/PluralTest.php diff --git a/src/Helper/Plural.php b/src/Helper/Plural.php deleted file mode 100644 index c6e35546..00000000 --- a/src/Helper/Plural.php +++ /dev/null @@ -1,39 +0,0 @@ - 1) { - return $plural; - } - - return $singular; - } -} - diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index af8fbcd5..517c07a3 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -64,7 +64,6 @@ class HelperPluginManager extends AbstractPluginManager 'partialloop' => 'Zend\View\Helper\PartialLoop', 'partial' => 'Zend\View\Helper\Partial', 'placeholder' => 'Zend\View\Helper\Placeholder', - 'plural' => 'Zend\View\Helper\Plural', 'renderchildmodel' => 'Zend\View\Helper\RenderChildModel', 'rendertoplaceholder' => 'Zend\View\Helper\RenderToPlaceholder', 'serverurl' => 'Zend\View\Helper\ServerUrl', diff --git a/test/Helper/PluralTest.php b/test/Helper/PluralTest.php deleted file mode 100644 index 04bd1621..00000000 --- a/test/Helper/PluralTest.php +++ /dev/null @@ -1,49 +0,0 @@ -helper = new PluralHelper(); - } - - public function testVerifySingularString() - { - $result = $this->helper->__invoke('one car', 'two cars', 1); - $this->assertEquals('one car', $result); - } - - public function testVerifyPluralString() - { - $result = $this->helper->__invoke('one car', 'two cars', 2); - $this->assertEquals('two cars', $result); - } -} From 203338a90c9405c1a27c51607bf5f61e84176641 Mon Sep 17 00:00:00 2001 From: Tim Roediger Date: Wed, 3 Oct 2012 11:29:40 +1000 Subject: [PATCH 05/68] Add view helper and controller plugin to pull the current identity from an AuthenticationService --- src/Helper/Identity.php | 65 +++++++++++++++++++ test/Helper/IdentityTest.php | 57 ++++++++++++++++ .../TestAsset/AuthenticationAdapter.php | 30 +++++++++ test/Helper/TestAsset/IdentityObject.php | 56 ++++++++++++++++ 4 files changed, 208 insertions(+) create mode 100644 src/Helper/Identity.php create mode 100644 test/Helper/IdentityTest.php create mode 100644 test/Helper/TestAsset/AuthenticationAdapter.php create mode 100644 test/Helper/TestAsset/IdentityObject.php diff --git a/src/Helper/Identity.php b/src/Helper/Identity.php new file mode 100644 index 00000000..9fe59510 --- /dev/null +++ b/src/Helper/Identity.php @@ -0,0 +1,65 @@ +authenticationService; + } + + /** + * + * @param \Zend\Authentication\AuthenticationService $authetnicationService + */ + public function setAuthenticationService(AuthenticationService $authenticationService) + { + $this->authenticationService = $authenticationService; + } + + /** + * + * @return mixed | null + * @throws Exception\RuntimeException + */ + public function __invoke() + { + if ( ! $this->authenticationService instanceof AuthenticationService){ + throw new Exception\RuntimeException('No AuthenticationService instance provided'); + } + if ($this->authenticationService->hasIdentity()) { + return $this->authenticationService->getIdentity(); + } + return null; + } +} \ No newline at end of file diff --git a/test/Helper/IdentityTest.php b/test/Helper/IdentityTest.php new file mode 100644 index 00000000..33ff74ae --- /dev/null +++ b/test/Helper/IdentityTest.php @@ -0,0 +1,57 @@ +setUsername('a username'); + $identity->setPassword('a password'); + + + $authenticationService = new AuthenticationService(new NonPersistentStorage, new AuthenticationAdapter); + + $identityHelper = new IdentityHelper; + $identityHelper->setAuthenticationService($authenticationService); + + $this->assertNull($identityHelper()); + + $this->assertFalse($authenticationService->hasIdentity()); + + $authenticationService->getAdapter()->setIdentity($identity); + $result = $authenticationService->authenticate(); + $this->assertTrue($result->isValid()); + + $this->assertEquals($identity, $identityHelper()); + } +} diff --git a/test/Helper/TestAsset/AuthenticationAdapter.php b/test/Helper/TestAsset/AuthenticationAdapter.php new file mode 100644 index 00000000..5bb58c25 --- /dev/null +++ b/test/Helper/TestAsset/AuthenticationAdapter.php @@ -0,0 +1,30 @@ +identity = $identity; + } + + public function authenticate() + { + return new Result(Result::SUCCESS, $this->identity); + } +} diff --git a/test/Helper/TestAsset/IdentityObject.php b/test/Helper/TestAsset/IdentityObject.php new file mode 100644 index 00000000..0517fce0 --- /dev/null +++ b/test/Helper/TestAsset/IdentityObject.php @@ -0,0 +1,56 @@ +password = (string) $password; + } + + /** + * @return string|null + */ + public function getPassword() + { + return $this->password; + } + + /** + * @param string $username + */ + public function setUsername($username) + { + $this->username = (string) $username; + } + + /** + * @return string|null + */ + public function getUsername() + { + return $this->username; + } +} From fb522802bb327dcb860d872f4eba3b37f2abcf81 Mon Sep 17 00:00:00 2001 From: Tim Roediger Date: Wed, 3 Oct 2012 11:56:07 +1000 Subject: [PATCH 06/68] Fix EOF --- src/Helper/Identity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/Identity.php b/src/Helper/Identity.php index 9fe59510..1fb1fc30 100644 --- a/src/Helper/Identity.php +++ b/src/Helper/Identity.php @@ -62,4 +62,4 @@ public function __invoke() } return null; } -} \ No newline at end of file +} From db5d4230a83f4ce5ecdd4d94fc9dadae9a52b7cc Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 3 Oct 2012 12:42:58 -0500 Subject: [PATCH 07/68] [zendframework/zf2#2650] CS fixes - Removed unnecessary empty lines and empty docblock lines - Removed unnecessary imports (and resolved class names relative to existing imports or current namespace) - Ensured all docblocks were present - Minor flow fixes --- src/Helper/Identity.php | 24 +++++++++---------- test/Helper/IdentityTest.php | 10 ++------ .../TestAsset/AuthenticationAdapter.php | 6 ++++- test/Helper/TestAsset/IdentityObject.php | 5 ++++ 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/Helper/Identity.php b/src/Helper/Identity.php index 1fb1fc30..34dc8a23 100644 --- a/src/Helper/Identity.php +++ b/src/Helper/Identity.php @@ -22,16 +22,13 @@ */ class Identity extends AbstractHelper { - /** - * - * @var \Zend\Authentication\AuthenticationService + * @var AuthenticationService */ protected $authenticationService; /** - * - * @return \Zend\Authentication\AuthenticationService + * @return AuthenticationService */ public function getAuthenticationService() { @@ -39,8 +36,7 @@ public function getAuthenticationService() } /** - * - * @param \Zend\Authentication\AuthenticationService $authetnicationService + * @param AuthenticationService $authenticationService */ public function setAuthenticationService(AuthenticationService $authenticationService) { @@ -48,18 +44,22 @@ public function setAuthenticationService(AuthenticationService $authenticationSe } /** + * Retrieve the current identity, if any. + * + * If none available, returns null. * - * @return mixed | null + * @return mixed|null * @throws Exception\RuntimeException */ public function __invoke() { - if ( ! $this->authenticationService instanceof AuthenticationService){ + if (!$this->authenticationService instanceof AuthenticationService){ throw new Exception\RuntimeException('No AuthenticationService instance provided'); } - if ($this->authenticationService->hasIdentity()) { - return $this->authenticationService->getIdentity(); + + if (!$this->authenticationService->hasIdentity()) { + return null; } - return null; + return $this->authenticationService->getIdentity(); } } diff --git a/test/Helper/IdentityTest.php b/test/Helper/IdentityTest.php index 33ff74ae..20dd70a5 100644 --- a/test/Helper/IdentityTest.php +++ b/test/Helper/IdentityTest.php @@ -13,8 +13,6 @@ use Zend\Authentication\AuthenticationService; use Zend\Authentication\Storage\NonPersistent as NonPersistentStorage; use Zend\View\Helper\Identity as IdentityHelper; -use ZendTest\View\Helper\TestAsset\IdentityObject; -use ZendTest\View\Helper\TestAsset\AuthenticationAdapter; /** * Zend_View_Helper_IdentityTest @@ -27,19 +25,15 @@ * @group Zend_View * @group Zend_View_Helper */ - class IdentityTest extends \PHPUnit_Framework_TestCase { - public function testGetIdentity() { - - $identity = new IdentityObject(); + $identity = new TestAsset\IdentityObject(); $identity->setUsername('a username'); $identity->setPassword('a password'); - - $authenticationService = new AuthenticationService(new NonPersistentStorage, new AuthenticationAdapter); + $authenticationService = new AuthenticationService(new NonPersistentStorage, new TestAsset\AuthenticationAdapter); $identityHelper = new IdentityHelper; $identityHelper->setAuthenticationService($authenticationService); diff --git a/test/Helper/TestAsset/AuthenticationAdapter.php b/test/Helper/TestAsset/AuthenticationAdapter.php index 5bb58c25..1ed89161 100644 --- a/test/Helper/TestAsset/AuthenticationAdapter.php +++ b/test/Helper/TestAsset/AuthenticationAdapter.php @@ -13,9 +13,13 @@ use Zend\Authentication\Adapter\AdapterInterface; use Zend\Authentication\Result; +/** + * @category Zend + * @package Zend_View + * @subpackage UnitTests + */ class AuthenticationAdapter implements AdapterInterface { - protected $identity; public function setIdentity($identity) diff --git a/test/Helper/TestAsset/IdentityObject.php b/test/Helper/TestAsset/IdentityObject.php index 0517fce0..d1606901 100644 --- a/test/Helper/TestAsset/IdentityObject.php +++ b/test/Helper/TestAsset/IdentityObject.php @@ -10,6 +10,11 @@ namespace ZendTest\View\Helper\TestAsset; +/** + * @category Zend + * @package Zend_View + * @subpackage UnitTests + */ class IdentityObject { /** From a7503a6c1e6351ae7ab0a3f2f43b480cf1c47eb9 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 3 Oct 2012 12:56:23 -0500 Subject: [PATCH 08/68] [zendframework/zf2#2650] Added factories for identity plugins - In View HelperPluginManager and Mvc Controller\PluginManager - Includes tests for expected behavior --- src/HelperPluginManager.php | 11 +++++++++++ test/HelperPluginManagerTest.php | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 517c07a3..aee4f6ef 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -86,6 +86,17 @@ class HelperPluginManager extends AbstractPluginManager public function __construct(ConfigInterface $configuration = null) { parent::__construct($configuration); + + $this->setFactory('identity', function ($helpers) { + $services = $helpers->getServiceLocator(); + $helper = new Helper\Identity(); + if (!$services->has('Zend\Authentication\AuthenticationService')) { + return $helper; + } + $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService')); + return $helper; + }); + $this->addInitializer(array($this, 'injectRenderer')) ->addInitializer(array($this, 'injectTranslator')); } diff --git a/test/HelperPluginManagerTest.php b/test/HelperPluginManagerTest.php index fd5c8142..b47613c8 100644 --- a/test/HelperPluginManagerTest.php +++ b/test/HelperPluginManagerTest.php @@ -10,6 +10,7 @@ namespace ZendTest\View; +use Zend\ServiceManager\ServiceManager; use Zend\View\HelperPluginManager; use Zend\View\Renderer\PhpRenderer; @@ -64,4 +65,19 @@ public function testLoadingInvalidHelperRaisesException() $this->setExpectedException('Zend\View\Exception\InvalidHelperException'); $this->helpers->get('test'); } + + public function testDefinesFactoryForIdentityPlugin() + { + $this->assertTrue($this->helpers->has('identity')); + } + + public function testIdentityFactoryCanInjectAuthenticationServiceIfInParentServiceManager() + { + $services = new ServiceManager(); + $services->setInvokableClass('Zend\Authentication\AuthenticationService', 'Zend\Authentication\AuthenticationService'); + $this->helpers->setServiceLocator($services); + $identity = $this->helpers->get('identity'); + $expected = $services->get('Zend\Authentication\AuthenticationService'); + $this->assertSame($expected, $identity->getAuthenticationService()); + } } From 79be22602a34c2d9add21f51ed5a7d2012d25a1e Mon Sep 17 00:00:00 2001 From: Jerry Saravia Date: Wed, 3 Oct 2012 22:44:31 -0400 Subject: [PATCH 09/68] Added tests for set and prepend fluency. --- test/Helper/Placeholder/ContainerTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/Helper/Placeholder/ContainerTest.php b/test/Helper/Placeholder/ContainerTest.php index e62fb9d5..7422039e 100644 --- a/test/Helper/Placeholder/ContainerTest.php +++ b/test/Helper/Placeholder/ContainerTest.php @@ -123,6 +123,26 @@ public function testSetPostfixImplementsFluentInterface() $this->assertSame($this->container, $result); } + /** + * @return void + */ + + public function testPrependImplementsFluentInterface() + { + $result = $this->container->prepend( 'test' ); + $this->assertSame($this->container, $result); + } + + /** + * @return void + */ + public function testSetImplementsFluentInterface() + { + $result = $this->container->set( 'test' ); + $this->assertSame($this->container, $result); + } + + /** * @return void */ From 126aa2216437522382378c6c9752ba75f7f78be3 Mon Sep 17 00:00:00 2001 From: Rafi Date: Fri, 19 Oct 2012 18:17:36 -0500 Subject: [PATCH 10/68] clear out child models --- src/Model/ModelInterface.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Model/ModelInterface.php b/src/Model/ModelInterface.php index fe359e0d..25636b4c 100644 --- a/src/Model/ModelInterface.php +++ b/src/Model/ModelInterface.php @@ -127,6 +127,13 @@ public function getChildren(); */ public function hasChildren(); + /** + * Clears out all child models + * + * @return ModelInterface + */ + public function clearChildren(); + /** * Set the name of the variable to capture this model to, if it is a child model * From 76dcbd29918b1cfed32ca62bbcbfefed70c2f281 Mon Sep 17 00:00:00 2001 From: Rafi Date: Fri, 19 Oct 2012 18:19:18 -0500 Subject: [PATCH 11/68] Implemented clearChildren() --- src/Model/ViewModel.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index c5fb3f9c..4ae50f2d 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -351,6 +351,17 @@ public function hasChildren() return (0 < count($this->children)); } + /** + * Clears out all child models + * + * @return ViewModel + */ + public function clearChildren() + { + $this->children = array(); + return $this; + } + /** * Set the name of the variable to capture this model to, if it is a child model * From ad7d036ec36c977619c9e5e2227d99210497935a Mon Sep 17 00:00:00 2001 From: Clemens Sahs Date: Mon, 29 Oct 2012 11:04:02 +0100 Subject: [PATCH 12/68] add a view event - add "ViewEvent::EVENT_RENDERER_POST" --- src/View.php | 3 +++ src/ViewEvent.php | 1 + 2 files changed, 4 insertions(+) diff --git a/src/View.php b/src/View.php index 65f34b84..2350b0c4 100644 --- a/src/View.php +++ b/src/View.php @@ -186,6 +186,9 @@ public function render(Model $model) )); } + $event->setRenderer($renderer); + $results = $events->trigger(ViewEvent::EVENT_RENDERER_POST, $event); + // If we have children, render them first, but only if: // a) the renderer does not implement TreeRendererInterface, or // b) it does, but canRenderTrees() returns false diff --git a/src/ViewEvent.php b/src/ViewEvent.php index b0fad47c..6fed9dc2 100644 --- a/src/ViewEvent.php +++ b/src/ViewEvent.php @@ -27,6 +27,7 @@ class ViewEvent extends Event * View events triggered by eventmanager */ const EVENT_RENDERER = 'renderer'; + const EVENT_RENDERER_POST = 'renderer.post'; const EVENT_RESPONSE = 'response'; /**#@-*/ From d6cb976bd86c662df22247941c2c22f1f09d8b49 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 13 Nov 2012 14:36:49 -0600 Subject: [PATCH 13/68] [zendframework/zf2#2812][zendframework/zf2#2528] Fix newly failing test - Test now had an expectation that was no longer necessary: that the output would continue to be captured and present. Since the PhpRenderer now catches exceptions and re-throws, the output buffering is handled slightly differently in exceptional circumstances. --- test/Helper/RenderChildModelTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Helper/RenderChildModelTest.php b/test/Helper/RenderChildModelTest.php index 36f7919b..c3d15700 100644 --- a/test/Helper/RenderChildModelTest.php +++ b/test/Helper/RenderChildModelTest.php @@ -126,7 +126,6 @@ public function testAttemptingToRenderWithNoCurrentModelRaisesException() $renderer = new PhpRenderer(); $renderer->setResolver($this->resolver); $this->setExpectedException('Zend\View\Exception\RuntimeException', 'no view model'); - $this->expectOutputString("Layout start" . PHP_EOL . PHP_EOL); $renderer->render('layout'); } } From 3717606ae9d3178548fe3e6498479b58c325bd31 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 13 Nov 2012 15:00:01 -0600 Subject: [PATCH 14/68] [zendframework/zf2#2812][zendframework/zf2#2528] Moved clearChildren into separate interface - Cannot add methods to existing interfaces; breaks BC - Created ClearableModelInterface with clearChildren(), and also added clearVariables() and clearOptions(). - ViewModel implements ModelInterface and ClearableModelInterface. - InjectViewModelListener now tests for ClearableModelInterface before attempting to clearChildren() --- src/Model/ClearableModelInterface.php | 28 +++++++++++++++++ src/Model/ModelInterface.php | 7 ----- src/Model/ViewModel.php | 26 +++++++++++++++- test/Model/ViewModelTest.php | 43 +++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 src/Model/ClearableModelInterface.php diff --git a/src/Model/ClearableModelInterface.php b/src/Model/ClearableModelInterface.php new file mode 100644 index 00000000..9d88e535 --- /dev/null +++ b/src/Model/ClearableModelInterface.php @@ -0,0 +1,28 @@ +options; } + /** + * Clear any existing renderer options/hints + * + * @return ViewModel + */ + public function clearOptions() + { + $this->options = array(); + return $this; + } + /** * Get a single view variable * @@ -286,6 +297,19 @@ public function getVariables() return $this->variables; } + /** + * Clear all variables + * + * Resets the internal variable container to an empty container. + * + * @return ViewModel + */ + public function clearVariables() + { + $this->variables = new ViewVariables(); + return $this; + } + /** * Set the template to be used by this model * diff --git a/test/Model/ViewModelTest.php b/test/Model/ViewModelTest.php index fa4f2859..af62206e 100644 --- a/test/Model/ViewModelTest.php +++ b/test/Model/ViewModelTest.php @@ -24,6 +24,18 @@ */ class ViewModelTest extends TestCase { + public function testImplementsModelInterface() + { + $model = new ViewModel(); + $this->assertInstanceOf('Zend\View\Model\ModelInterface', $model); + } + + public function testImplementsClearableModelInterface() + { + $model = new ViewModel(); + $this->assertInstanceOf('Zend\View\Model\ClearableModelInterface', $model); + } + public function testAllowsEmptyConstructor() { $model = new ViewModel(); @@ -80,6 +92,7 @@ public function testSetVariablesMergesWithPreviouslyStoredVariables() $model = new ViewModel(array('foo' => 'bar', 'bar' => 'baz')); $model->setVariables(array('bar' => 'BAZBAT')); $this->assertEquals(array('foo' => 'bar', 'bar' => 'BAZBAT'), $model->getVariables()); + return $model; } public function testCanUnsetVariable() @@ -89,6 +102,16 @@ public function testCanUnsetVariable() $this->assertEquals(array(), $model->getVariables()); } + /** + * @depends testSetVariablesMergesWithPreviouslyStoredVariables + */ + public function testCanClearAllVariables(ViewModel $model) + { + $model->clearVariables(); + $vars = $model->getVariables(); + $this->assertEquals(0, count($vars)); + } + public function testCanSetOptionsSingly() { $model = new ViewModel(array(), array('foo' => 'bar')); @@ -108,6 +131,7 @@ public function testSetOptionsOverwritesAllPreviouslyStored() $model = new ViewModel(array(), array('foo' => 'bar', 'bar' => 'baz')); $model->setOptions(array('bar' => 'BAZBAT')); $this->assertEquals(array('bar' => 'BAZBAT'), $model->getOptions()); + return $model; } public function testOptionsAreInternallyConvertedToAnArrayFromTraversables() @@ -118,6 +142,15 @@ public function testOptionsAreInternallyConvertedToAnArrayFromTraversables() $this->assertEquals($options->getArrayCopy(), $model->getOptions()); } + /** + * @depends testSetOptionsOverwritesAllPreviouslyStored + */ + public function testCanClearOptions(ViewModel $model) + { + $model->clearOptions(); + $this->assertEquals(array(), $model->getOptions()); + } + public function testPassingAnInvalidArgumentToSetVariablesRaisesAnException() { $model = new ViewModel(); @@ -173,6 +206,7 @@ public function testCanCountChildren() $this->assertEquals(1, count($model)); $model->addChild($child); $this->assertEquals(2, count($model)); + return $model; } public function testCanIterateChildren() @@ -191,6 +225,15 @@ public function testCanIterateChildren() $this->assertEquals(3, $count); } + /** + * @depends testCanCountChildren + */ + public function testCanClearChildren(ViewModel $model) + { + $model->clearChildren(); + $this->assertEquals(0, count($model)); + } + public function testTemplateIsEmptyByDefault() { $model = new ViewModel(); From f56c87d523d15f93f5c5ee0dfbfa6349fa1ed0f2 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 13 Nov 2012 17:02:33 -0600 Subject: [PATCH 15/68] [zendframework/zf2#2855] Added test for renderer.post event - Added a test for the renderer.post event to ensure it gets triggered --- test/ViewTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/ViewTest.php b/test/ViewTest.php index 5139f733..2baa1ec4 100644 --- a/test/ViewTest.php +++ b/test/ViewTest.php @@ -290,4 +290,20 @@ public function testUsesTreeRendererInterfaceToDetermineWhetherOrNotToPassOnlyRo $this->assertEquals($expected, $result->content); } + + public function testCanTriggerPostRendererEvent() + { + $this->attachTestStrategies(); + $test = (object) array('flag' => false); + $this->view->getEventManager()->attach('renderer.post', function ($e) use ($test) { + $test->flag = true; + }); + $variables = array( + 'foo' => 'bar', + 'bar' => 'baz', + ); + $this->model->setVariables($variables); + $this->view->render($this->model); + $this->assertTrue($test->flag); + } } From 802bc014a0b735ff68bcd93ba4bd83266f7049a0 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 25 Dec 2012 01:52:06 +0700 Subject: [PATCH 16/68] remove else in other because already return early --- src/Helper/Navigation/AbstractHelper.php | 4 ++-- src/Helper/Navigation/Breadcrumbs.php | 4 ++-- src/Model/ViewModel.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index cace5156..25bbcd0a 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -541,9 +541,9 @@ public function findActive($container, $minDepth = null, $maxDepth = -1) if ($found) { return array('page' => $found, 'depth' => $foundDepth); - } else { - return array(); } + + return array(); } /** diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php index 84c8bd60..7cb70010 100644 --- a/src/Helper/Navigation/Breadcrumbs.php +++ b/src/Helper/Navigation/Breadcrumbs.php @@ -291,8 +291,8 @@ public function render($container = null) $partial = $this->getPartial(); if ($partial) { return $this->renderPartial($container, $partial); - } else { - return $this->renderStraight($container); } + + return $this->renderStraight($container); } } diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index d4aa28d3..70a36eca 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -222,9 +222,9 @@ public function getVariable($name, $default = null) $name = (string) $name; if (array_key_exists($name, $this->variables)) { return $this->variables[$name]; - } else { - return $default; } + + return $default; } /** From e4f3c7691819cc9e08f79bced7f1b2b05a9afd48 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 25 Dec 2012 02:22:58 +0700 Subject: [PATCH 17/68] remove trailing_spaces --- src/Helper/Navigation/AbstractHelper.php | 2 +- src/Helper/Navigation/Breadcrumbs.php | 2 +- src/Model/ViewModel.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 25bbcd0a..10540a14 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -542,7 +542,7 @@ public function findActive($container, $minDepth = null, $maxDepth = -1) if ($found) { return array('page' => $found, 'depth' => $foundDepth); } - + return array(); } diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php index 7cb70010..bf0697a0 100644 --- a/src/Helper/Navigation/Breadcrumbs.php +++ b/src/Helper/Navigation/Breadcrumbs.php @@ -292,7 +292,7 @@ public function render($container = null) if ($partial) { return $this->renderPartial($container, $partial); } - + return $this->renderStraight($container); } } diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index 70a36eca..89c9ed46 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -223,7 +223,7 @@ public function getVariable($name, $default = null) if (array_key_exists($name, $this->variables)) { return $this->variables[$name]; } - + return $default; } From f3cd314e1eb8246991501d7813ac12de5284b14b Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 18 Jan 2013 15:40:16 -0600 Subject: [PATCH 18/68] Incorporate feedbac - Added getter for charset - For selected multibyte character sets, an additional content-transfer-encoding header is set with the value 'BINARY' --- src/Strategy/JsonStrategy.php | 24 +++++++++++++++++++ test/Strategy/JsonStrategyTest.php | 37 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 76747ac8..097738b9 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -36,6 +36,16 @@ class JsonStrategy implements ListenerAggregateInterface */ protected $listeners = array(); + /** + * Multibyte character sets that will trigger a binary content-transfer-encoding + * + * @var array + */ + protected $multibyteCharsets = array( + 'UTF-16', + 'UTF-32', + ); + /** * @var JsonRenderer */ @@ -91,6 +101,16 @@ public function setCharset($charset) return $this; } + /** + * Retrieve the current character set + * + * @return string + */ + public function getCharset() + { + return $this->charset; + } + /** * Detect if we should use the JsonRenderer based on model type and/or * Accept header @@ -144,5 +164,9 @@ public function injectResponse(ViewEvent $e) $contentType .= '; charset=' . $this->charset; $headers->addHeaderLine('content-type', $contentType); + + if (in_array(strtoupper($this->charset), $this->multibyteCharsets)) { + $headers->addHeaderLine('content-transfer-encoding', 'BINARY'); + } } } diff --git a/test/Strategy/JsonStrategyTest.php b/test/Strategy/JsonStrategyTest.php index af0db45b..1ac73601 100644 --- a/test/Strategy/JsonStrategyTest.php +++ b/test/Strategy/JsonStrategyTest.php @@ -288,4 +288,41 @@ public function testUsesProvidedCharsetWhenCreatingJsonHeader() $this->assertTrue($headers->has('content-type')); $this->assertContains('application/json; charset=utf-16', $headers->get('content-type')->getFieldValue()); } + + public function testCharsetIsUtf8ByDefault() + { + $this->assertEquals('utf-8', $this->strategy->getCharset()); + } + + public function testCharsetIsMutable() + { + $this->strategy->setCharset('iso-8859-1'); + $this->assertEquals('iso-8859-1', $this->strategy->getCharset()); + } + + public function multibyteCharsets() + { + return array( + 'utf-16' => array('utf-16'), + 'utf-32' => array('utf-32'), + ); + } + + /** + * @dataProvider multibyteCharsets + */ + public function testContentTransferEncodingHeaderSetToBinaryForSpecificMultibyteCharsets($charset) + { + $this->strategy->setCharset($charset); + + $this->event->setResponse($this->response); + $this->event->setRenderer($this->renderer); + $this->event->setResult(json_encode(array('foo' => 'bar'))); + + $this->strategy->injectResponse($this->event); + $content = $this->response->getContent(); + $headers = $this->response->getHeaders(); + $this->assertTrue($headers->has('content-transfer-encoding')); + $this->assertEquals('BINARY', $headers->get('content-transfer-encoding')->getFieldValue()); + } } From 45429b5e46fc7d3a31f367187f0f11d097852d87 Mon Sep 17 00:00:00 2001 From: blanchonvincent Date: Mon, 21 Jan 2013 12:42:21 +0100 Subject: [PATCH 19/68] Fix namespace constant name --- src/Helper/FlashMessenger.php | 10 +++++----- test/Helper/FlashMessengerTest.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Helper/FlashMessenger.php b/src/Helper/FlashMessenger.php index 5399567a..56de2a65 100644 --- a/src/Helper/FlashMessenger.php +++ b/src/Helper/FlashMessenger.php @@ -50,10 +50,10 @@ class FlashMessenger extends AbstractHelper implements ServiceLocatorAwareInterf * @var array Default attributes for the open format tag */ protected $classMessages = array( - PluginFlashMessenger::INFO_MESSAGE => 'info', - PluginFlashMessenger::ERROR_MESSAGE => 'error', - PluginFlashMessenger::SUCCESS_MESSAGE => 'success', - PluginFlashMessenger::DEFAULT_MESSAGE => 'default', + PluginFlashMessenger::NAMESPACE_INFO => 'info', + PluginFlashMessenger::NAMESPACE_ERROR => 'error', + PluginFlashMessenger::NAMESPACE_SUCCESS => 'success', + PluginFlashMessenger::NAMESPACE_DEFAULT => 'default', ); /** @@ -98,7 +98,7 @@ public function render($namespace = null, array $classes = array()) // Prepare classes for opening tag if (empty($classes)) { $classes = isset($this->classMessages[$namespace]) ? - $this->classMessages[$namespace] : $this->classMessages[PluginFlashMessenger::DEFAULT_MESSAGE]; + $this->classMessages[$namespace] : $this->classMessages[PluginFlashMessenger::NAMESPACE_DEFAULT]; $classes = array($classes); } diff --git a/test/Helper/FlashMessengerTest.php b/test/Helper/FlashMessengerTest.php index bcb1844d..6a6a9be1 100644 --- a/test/Helper/FlashMessengerTest.php +++ b/test/Helper/FlashMessengerTest.php @@ -106,13 +106,13 @@ public function testCanProxyAndRetrieveMessagesFromPluginController() public function testCanDisplayListOfMessages() { $displayInfoAssertion = ''; - $displayInfo = $this->helper->render(PluginFlashMessenger::INFO_MESSAGE); + $displayInfo = $this->helper->render(PluginFlashMessenger::NAMESPACE_INFO); $this->assertEquals($displayInfoAssertion, $displayInfo); $this->seedMessages(); $displayInfoAssertion = '
  • bar-info
'; - $displayInfo = $this->helper->render(PluginFlashMessenger::INFO_MESSAGE); + $displayInfo = $this->helper->render(PluginFlashMessenger::NAMESPACE_INFO); $this->assertEquals($displayInfoAssertion, $displayInfo); } @@ -122,7 +122,7 @@ public function testCanDisplayListOfMessagesByInvoke() $this->seedMessages(); $displayInfoAssertion = '
  • bar-info
'; - $displayInfo = $helper()->render(PluginFlashMessenger::INFO_MESSAGE); + $displayInfo = $helper()->render(PluginFlashMessenger::NAMESPACE_INFO); $this->assertEquals($displayInfoAssertion, $displayInfo); } @@ -135,7 +135,7 @@ public function testCanDisplayListOfMessagesCustomised() ->setMessageOpenFormat('

') ->setMessageSeparatorString('

') ->setMessageCloseString('

') - ->render(PluginFlashMessenger::INFO_MESSAGE, array('foo-baz', 'foo-bar')); + ->render(PluginFlashMessenger::NAMESPACE_INFO, array('foo-baz', 'foo-bar')); $this->assertEquals($displayInfoAssertion, $displayInfo); } @@ -170,7 +170,7 @@ public function testCanDisplayListOfMessagesCustomisedByConfig() $helper = $helperPluginManager->get('flashmessenger'); $displayInfoAssertion = '
  • bar-info
'; - $displayInfo = $helper->render(PluginFlashMessenger::INFO_MESSAGE); + $displayInfo = $helper->render(PluginFlashMessenger::NAMESPACE_INFO); $this->assertEquals($displayInfoAssertion, $displayInfo); } } From 6c9a292ee87c6cbfe55c3f3f4a27c3862e354107 Mon Sep 17 00:00:00 2001 From: blanchonvincent Date: Mon, 21 Jan 2013 21:56:43 +0100 Subject: [PATCH 20/68] Fix special key "view_helper_config" --- src/Helper/Service/FlashMessengerFactory.php | 4 ++-- test/Helper/FlashMessengerTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helper/Service/FlashMessengerFactory.php b/src/Helper/Service/FlashMessengerFactory.php index b9e10bd5..925fb67e 100644 --- a/src/Helper/Service/FlashMessengerFactory.php +++ b/src/Helper/Service/FlashMessengerFactory.php @@ -29,8 +29,8 @@ public function createService(ServiceLocatorInterface $serviceLocator) $flashMessenger = $controllerPluginManager->get('flashmessenger'); $helper->setPluginFlashMessenger($flashMessenger); $config = $serviceLocator->get('Config'); - if (isset($config['view_helper']['flashmessenger'])) { - $configHelper = $config['view_helper']['flashmessenger']; + if (isset($config['view_helper_config']['flashmessenger'])) { + $configHelper = $config['view_helper_config']['flashmessenger']; if (isset($configHelper['message_open_format'])) { $helper->setMessageOpenFormat($configHelper['message_open_format']); } diff --git a/test/Helper/FlashMessengerTest.php b/test/Helper/FlashMessengerTest.php index 6a6a9be1..80fc36c1 100644 --- a/test/Helper/FlashMessengerTest.php +++ b/test/Helper/FlashMessengerTest.php @@ -144,7 +144,7 @@ public function testCanDisplayListOfMessagesCustomisedByConfig() $this->seedMessages(); $config = array( - 'view_helper' => array( + 'view_helper_config' => array( 'flashmessenger' => array( 'message_open_format' => '
  • ', 'message_separator_string' => '
  • ', From 1d5094edaef215b4de0376b8f2ea583b908a48e8 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 21 Jan 2013 15:01:17 -0600 Subject: [PATCH 21/68] [zendframework/zf2#3502] Point flashmessenger to factory class, not implementing class --- src/HelperPluginManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 423e77a4..80ff9faf 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -32,7 +32,7 @@ class HelperPluginManager extends AbstractPluginManager * @var array */ protected $factories = array( - 'flashmessenger' => 'Zend\View\Helper\FlashMessenger', + 'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory', ); /** From 77251428e2cd501c8ca87f0b7ec88f7d5369e0b3 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 21 Jan 2013 16:14:27 -0600 Subject: [PATCH 22/68] Removed all @category, @package, and @subpackage annotations - Per zendframework/zf2#2743, and following on zendframework/zf2#2953 and discussion on the ML - Also removes empty docblocks, and empty lines at the end of docblocks - Library only; phpdoc is never run on tests anyways, and did not want to potentially create breakage due to test expectations that relied on annotations. At this time, all tests pass. --- src/Exception/BadMethodCallException.php | 4 ---- src/Exception/DomainException.php | 4 ---- src/Exception/ExceptionInterface.php | 5 ----- src/Exception/InvalidArgumentException.php | 4 ---- src/Exception/InvalidHelperException.php | 4 ---- src/Exception/RuntimeException.php | 4 ---- src/Helper/AbstractHelper.php | 6 ------ src/Helper/AbstractHtmlElement.php | 6 ------ src/Helper/BasePath.php | 4 ---- src/Helper/Cycle.php | 4 ---- src/Helper/DeclareVars.php | 4 ---- src/Helper/Doctype.php | 4 ---- src/Helper/EscapeCss.php | 4 ---- src/Helper/EscapeHtml.php | 4 ---- src/Helper/EscapeHtmlAttr.php | 4 ---- src/Helper/EscapeJs.php | 4 ---- src/Helper/EscapeUrl.php | 4 ---- src/Helper/Escaper/AbstractHelper.php | 4 ---- src/Helper/FlashMessenger.php | 4 ---- src/Helper/Gravatar.php | 4 ---- src/Helper/HeadLink.php | 3 --- src/Helper/HeadMeta.php | 3 --- src/Helper/HeadScript.php | 4 ---- src/Helper/HeadStyle.php | 4 ---- src/Helper/HeadTitle.php | 4 ---- src/Helper/HelperInterface.php | 6 ------ src/Helper/HtmlFlash.php | 6 ------ src/Helper/HtmlList.php | 5 ----- src/Helper/HtmlObject.php | 6 ------ src/Helper/HtmlPage.php | 6 ------ src/Helper/HtmlQuicktime.php | 6 ------ src/Helper/Identity.php | 5 ----- src/Helper/InlineScript.php | 4 ---- src/Helper/Json.php | 4 ---- src/Helper/Layout.php | 4 ---- src/Helper/Navigation.php | 5 ----- src/Helper/Navigation/AbstractHelper.php | 5 ----- src/Helper/Navigation/Breadcrumbs.php | 5 ----- src/Helper/Navigation/HelperInterface.php | 5 ----- src/Helper/Navigation/Links.php | 5 ----- src/Helper/Navigation/Menu.php | 5 ----- src/Helper/Navigation/PluginManager.php | 5 ----- src/Helper/Navigation/Sitemap.php | 5 ----- src/Helper/PaginationControl.php | 5 ----- src/Helper/Partial.php | 4 ---- src/Helper/PartialLoop.php | 4 ---- src/Helper/Placeholder.php | 4 ---- src/Helper/Placeholder/Container.php | 4 ---- src/Helper/Placeholder/Container/AbstractContainer.php | 4 ---- src/Helper/Placeholder/Container/AbstractStandalone.php | 4 ---- src/Helper/Placeholder/Registry.php | 4 ---- src/Helper/RenderChildModel.php | 4 ---- src/Helper/RenderToPlaceholder.php | 4 ---- src/Helper/ServerUrl.php | 5 ----- src/Helper/Service/FlashMessengerFactory.php | 6 ------ src/Helper/Url.php | 4 ---- src/Helper/ViewModel.php | 4 ---- src/HelperPluginManager.php | 4 ---- src/Model/ClearableModelInterface.php | 5 ----- src/Model/ConsoleModel.php | 6 ------ src/Model/FeedModel.php | 5 ----- src/Model/JsonModel.php | 6 ------ src/Model/ModelInterface.php | 5 ----- src/Model/ViewModel.php | 6 ------ src/Renderer/ConsoleRenderer.php | 4 ---- src/Renderer/FeedRenderer.php | 5 ----- src/Renderer/JsonRenderer.php | 5 ----- src/Renderer/PhpRenderer.php | 4 ---- src/Renderer/RendererInterface.php | 4 ---- src/Renderer/TreeRendererInterface.php | 6 ------ src/Resolver/AggregateResolver.php | 6 ------ src/Resolver/ResolverInterface.php | 6 ------ src/Resolver/TemplateMapResolver.php | 6 ------ src/Resolver/TemplatePathStack.php | 5 ----- src/Strategy/FeedStrategy.php | 6 ------ src/Strategy/JsonStrategy.php | 6 ------ src/Strategy/PhpRendererStrategy.php | 6 ------ src/Stream.php | 4 ---- src/Variables.php | 3 --- src/View.php | 5 ----- src/ViewEvent.php | 5 ----- 81 files changed, 378 deletions(-) diff --git a/src/Exception/BadMethodCallException.php b/src/Exception/BadMethodCallException.php index b04596f8..af309aaa 100644 --- a/src/Exception/BadMethodCallException.php +++ b/src/Exception/BadMethodCallException.php @@ -5,16 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Exception; /** * Bad method call exception - * - * @category Zend - * @package Zend_View */ class BadMethodCallException extends \BadMethodCallException diff --git a/src/Exception/DomainException.php b/src/Exception/DomainException.php index 0e723106..e52fc739 100644 --- a/src/Exception/DomainException.php +++ b/src/Exception/DomainException.php @@ -5,16 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Exception; /** * Domain exception - * - * @category Zend - * @package Zend_View */ class DomainException extends \DomainException diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index e7d18295..753e6a02 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -5,14 +5,9 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Exception; -/** - * @category Zend - * @package Zend_View - */ interface ExceptionInterface {} diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 82b4eab4..8acb6439 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -5,16 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Exception; /** * Invalid argument exception - * - * @category Zend - * @package Zend_View */ class InvalidArgumentException extends \InvalidArgumentException diff --git a/src/Exception/InvalidHelperException.php b/src/Exception/InvalidHelperException.php index a87a49de..7926eac9 100644 --- a/src/Exception/InvalidHelperException.php +++ b/src/Exception/InvalidHelperException.php @@ -5,16 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Exception; /** * Invalid helper exception - * - * @category Zend - * @package Zend_View */ class InvalidHelperException extends \Exception diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php index 8db91d3b..fc50ac03 100644 --- a/src/Exception/RuntimeException.php +++ b/src/Exception/RuntimeException.php @@ -5,16 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Exception; /** * Runtime exception - * - * @category Zend - * @package Zend_View */ class RuntimeException extends \RuntimeException diff --git a/src/Helper/AbstractHelper.php b/src/Helper/AbstractHelper.php index 88cc308c..8234a8a6 100644 --- a/src/Helper/AbstractHelper.php +++ b/src/Helper/AbstractHelper.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -13,11 +12,6 @@ use Zend\View\Helper\HelperInterface; use Zend\View\Renderer\RendererInterface as Renderer; -/** - * @category Zend - * @package Zend_View - * @subpackage Helper - */ abstract class AbstractHelper implements HelperInterface { /** diff --git a/src/Helper/AbstractHtmlElement.php b/src/Helper/AbstractHtmlElement.php index 3274cf14..03707411 100644 --- a/src/Helper/AbstractHtmlElement.php +++ b/src/Helper/AbstractHtmlElement.php @@ -5,16 +5,10 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; -/** - * @category Zend - * @package Zend_View - * @subpackage Helper - */ abstract class AbstractHtmlElement extends AbstractHelper { /** diff --git a/src/Helper/BasePath.php b/src/Helper/BasePath.php index fb6ddd80..dc1b2d48 100644 --- a/src/Helper/BasePath.php +++ b/src/Helper/BasePath.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,9 +13,6 @@ /** * Helper for retrieving the base path. - * - * @package Zend_View - * @subpackage Helper */ class BasePath extends AbstractHelper { diff --git a/src/Helper/Cycle.php b/src/Helper/Cycle.php index 3da7022d..60a296d4 100644 --- a/src/Helper/Cycle.php +++ b/src/Helper/Cycle.php @@ -5,16 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; /** * Helper for alternating between set of values - * - * @package Zend_View - * @subpackage Helper */ class Cycle extends AbstractHelper implements \Iterator { diff --git a/src/Helper/DeclareVars.php b/src/Helper/DeclareVars.php index e6c9d2c7..d2dde4bc 100644 --- a/src/Helper/DeclareVars.php +++ b/src/Helper/DeclareVars.php @@ -5,16 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; /** * Helper for declaring default values of template variables - * - * @package Zend_View - * @subpackage Helper */ class DeclareVars extends AbstractHelper { diff --git a/src/Helper/Doctype.php b/src/Helper/Doctype.php index 7f10b266..ed3d5e72 100644 --- a/src/Helper/Doctype.php +++ b/src/Helper/Doctype.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -15,9 +14,6 @@ /** * Helper for setting and retrieving the doctype - * - * @package Zend_View - * @subpackage Helper */ class Doctype extends AbstractHelper { diff --git a/src/Helper/EscapeCss.php b/src/Helper/EscapeCss.php index fe4797e2..c156629c 100644 --- a/src/Helper/EscapeCss.php +++ b/src/Helper/EscapeCss.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,9 +13,6 @@ /** * Helper for escaping values - * - * @package Zend_View - * @subpackage Helper */ class EscapeCss extends Escaper\AbstractHelper { diff --git a/src/Helper/EscapeHtml.php b/src/Helper/EscapeHtml.php index 3149afdf..c2ebfd02 100644 --- a/src/Helper/EscapeHtml.php +++ b/src/Helper/EscapeHtml.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,9 +13,6 @@ /** * Helper for escaping values - * - * @package Zend_View - * @subpackage Helper */ class EscapeHtml extends Escaper\AbstractHelper { diff --git a/src/Helper/EscapeHtmlAttr.php b/src/Helper/EscapeHtmlAttr.php index 237bfd75..0fba7cd6 100644 --- a/src/Helper/EscapeHtmlAttr.php +++ b/src/Helper/EscapeHtmlAttr.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,9 +13,6 @@ /** * Helper for escaping values - * - * @package Zend_View - * @subpackage Helper */ class EscapeHtmlAttr extends Escaper\AbstractHelper { diff --git a/src/Helper/EscapeJs.php b/src/Helper/EscapeJs.php index ec99b2e3..c324c7c8 100644 --- a/src/Helper/EscapeJs.php +++ b/src/Helper/EscapeJs.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,9 +13,6 @@ /** * Helper for escaping values - * - * @package Zend_View - * @subpackage Helper */ class EscapeJs extends Escaper\AbstractHelper { diff --git a/src/Helper/EscapeUrl.php b/src/Helper/EscapeUrl.php index 749a36b6..67ea5a7b 100644 --- a/src/Helper/EscapeUrl.php +++ b/src/Helper/EscapeUrl.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,9 +13,6 @@ /** * Helper for escaping values - * - * @package Zend_View - * @subpackage Helper */ class EscapeUrl extends Escaper\AbstractHelper { diff --git a/src/Helper/Escaper/AbstractHelper.php b/src/Helper/Escaper/AbstractHelper.php index ca9d1ae0..969b9ace 100644 --- a/src/Helper/Escaper/AbstractHelper.php +++ b/src/Helper/Escaper/AbstractHelper.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Escaper; @@ -16,9 +15,6 @@ /** * Helper for escaping values - * - * @package Zend_View - * @subpackage Helper */ abstract class AbstractHelper extends Helper\AbstractHelper { diff --git a/src/Helper/FlashMessenger.php b/src/Helper/FlashMessenger.php index 56de2a65..d06cce9a 100644 --- a/src/Helper/FlashMessenger.php +++ b/src/Helper/FlashMessenger.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -18,9 +17,6 @@ /** * Helper to proxy the plugin flash messenger - * - * @package Zend_View - * @subpackage Helper */ class FlashMessenger extends AbstractHelper implements ServiceLocatorAwareInterface { diff --git a/src/Helper/Gravatar.php b/src/Helper/Gravatar.php index 7e84df6f..7c1202bc 100644 --- a/src/Helper/Gravatar.php +++ b/src/Helper/Gravatar.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,9 +13,6 @@ /** * Helper for retrieving avatars from gravatar.com - * - * @package Zend\View - * @subpackage Helper */ class Gravatar extends AbstractHtmlElement { diff --git a/src/Helper/HeadLink.php b/src/Helper/HeadLink.php index 95cb8b42..6d9723cc 100644 --- a/src/Helper/HeadLink.php +++ b/src/Helper/HeadLink.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -18,8 +17,6 @@ * Zend_Layout_View_Helper_HeadLink * * @see http://www.w3.org/TR/xhtml1/dtds.html - * @package Zend_View - * @subpackage Helper */ class HeadLink extends Placeholder\Container\AbstractStandalone { diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index 4ef4ad7d..ed0e1f4f 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -18,8 +17,6 @@ * Zend_Layout_View_Helper_HeadMeta * * @see http://www.w3.org/TR/xhtml1/dtds.html - * @package Zend_View - * @subpackage Helper */ class HeadMeta extends Placeholder\Container\AbstractStandalone { diff --git a/src/Helper/HeadScript.php b/src/Helper/HeadScript.php index 77a3c52a..fe6372ac 100644 --- a/src/Helper/HeadScript.php +++ b/src/Helper/HeadScript.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -16,9 +15,6 @@ /** * Helper for setting and retrieving script elements for HTML head section - * - * @package Zend_View - * @subpackage Helper */ class HeadScript extends Placeholder\Container\AbstractStandalone { diff --git a/src/Helper/HeadStyle.php b/src/Helper/HeadStyle.php index 1739180f..3835e41e 100644 --- a/src/Helper/HeadStyle.php +++ b/src/Helper/HeadStyle.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -16,9 +15,6 @@ /** * Helper for setting and retrieving stylesheets - * - * @package Zend_View - * @subpackage Helper */ class HeadStyle extends Placeholder\Container\AbstractStandalone { diff --git a/src/Helper/HeadTitle.php b/src/Helper/HeadTitle.php index 92ea8e54..0ee0bdd7 100644 --- a/src/Helper/HeadTitle.php +++ b/src/Helper/HeadTitle.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -16,9 +15,6 @@ /** * Helper for setting and retrieving title element for HTML head - * - * @package Zend_View - * @subpackage Helper */ class HeadTitle extends Placeholder\Container\AbstractStandalone implements TranslatorAwareInterface diff --git a/src/Helper/HelperInterface.php b/src/Helper/HelperInterface.php index 67e7fefa..f2106dc1 100644 --- a/src/Helper/HelperInterface.php +++ b/src/Helper/HelperInterface.php @@ -5,18 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; use Zend\View\Renderer\RendererInterface as Renderer; -/** - * @category Zend - * @package Zend_View - * @subpackage Helper - */ interface HelperInterface { /** diff --git a/src/Helper/HtmlFlash.php b/src/Helper/HtmlFlash.php index 163aff72..9728b7f0 100644 --- a/src/Helper/HtmlFlash.php +++ b/src/Helper/HtmlFlash.php @@ -5,16 +5,10 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; -/** - * @category Zend - * @package Zend_View - * @subpackage Helper - */ class HtmlFlash extends AbstractHtmlElement { /** diff --git a/src/Helper/HtmlList.php b/src/Helper/HtmlList.php index f50bf313..e04e3626 100644 --- a/src/Helper/HtmlList.php +++ b/src/Helper/HtmlList.php @@ -5,17 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; /** * Helper for ordered and unordered lists - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class HtmlList extends AbstractHtmlElement { diff --git a/src/Helper/HtmlObject.php b/src/Helper/HtmlObject.php index a3d91cb0..a28d14a5 100644 --- a/src/Helper/HtmlObject.php +++ b/src/Helper/HtmlObject.php @@ -5,18 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; use Zend\View\Exception\InvalidArgumentException; -/** - * @category Zend - * @package Zend_View - * @subpackage Helper - */ class HtmlObject extends AbstractHtmlElement { /** diff --git a/src/Helper/HtmlPage.php b/src/Helper/HtmlPage.php index bb0ebfed..05ac2386 100644 --- a/src/Helper/HtmlPage.php +++ b/src/Helper/HtmlPage.php @@ -5,16 +5,10 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; -/** - * @category Zend - * @package Zend_View - * @subpackage Helper - */ class HtmlPage extends AbstractHtmlElement { /** diff --git a/src/Helper/HtmlQuicktime.php b/src/Helper/HtmlQuicktime.php index 3907503c..852b3f3f 100644 --- a/src/Helper/HtmlQuicktime.php +++ b/src/Helper/HtmlQuicktime.php @@ -5,16 +5,10 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; -/** - * @category Zend - * @package Zend_View - * @subpackage Helper - */ class HtmlQuicktime extends AbstractHtmlElement { /** diff --git a/src/Helper/Identity.php b/src/Helper/Identity.php index 34dc8a23..f6d847bb 100644 --- a/src/Helper/Identity.php +++ b/src/Helper/Identity.php @@ -5,7 +5,6 @@ * @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_View */ namespace Zend\View\Helper; @@ -15,10 +14,6 @@ /** * View helper plugin to fetch the authenticated identity. - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class Identity extends AbstractHelper { diff --git a/src/Helper/InlineScript.php b/src/Helper/InlineScript.php index 2caf2118..009d501d 100644 --- a/src/Helper/InlineScript.php +++ b/src/Helper/InlineScript.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -13,9 +12,6 @@ /** * Helper for setting and retrieving script elements for inclusion in HTML body * section - * - * @package Zend_View - * @subpackage Helper */ class InlineScript extends HeadScript { diff --git a/src/Helper/Json.php b/src/Helper/Json.php index a3628519..db8572a9 100644 --- a/src/Helper/Json.php +++ b/src/Helper/Json.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -15,9 +14,6 @@ /** * Helper for simplifying JSON responses - * - * @package Zend_View - * @subpackage Helper */ class Json extends AbstractHelper { diff --git a/src/Helper/Layout.php b/src/Helper/Layout.php index a9c1e063..91f8e55b 100644 --- a/src/Helper/Layout.php +++ b/src/Helper/Layout.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -15,9 +14,6 @@ /** * View helper for retrieving layout object - * - * @package Zend_View - * @subpackage Helper */ class Layout extends AbstractHelper { diff --git a/src/Helper/Navigation.php b/src/Helper/Navigation.php index f0f7539c..f77caffc 100644 --- a/src/Helper/Navigation.php +++ b/src/Helper/Navigation.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -18,10 +17,6 @@ /** * Proxy helper for retrieving navigational helpers and forwarding calls - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class Navigation extends AbstractNavigationHelper { diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 8a798b82..e5700777 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Navigation; @@ -23,10 +22,6 @@ /** * Base class for navigational helpers - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements HelperInterface, diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php index 2bf4365e..e6ad13d7 100644 --- a/src/Helper/Navigation/Breadcrumbs.php +++ b/src/Helper/Navigation/Breadcrumbs.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Navigation; @@ -17,10 +16,6 @@ /** * Helper for printing breadcrumbs - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class Breadcrumbs extends AbstractHelper { diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index b409d94f..6c607c88 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Navigation; @@ -16,10 +15,6 @@ /** * Interface for navigational helpers - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ interface HelperInterface extends BaseHelperInterface { diff --git a/src/Helper/Navigation/Links.php b/src/Helper/Navigation/Links.php index 616ac173..3e70fa4c 100644 --- a/src/Helper/Navigation/Links.php +++ b/src/Helper/Navigation/Links.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Navigation; @@ -21,10 +20,6 @@ /** * Helper for printing elements - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class Links extends AbstractHelper { diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php index 5d6e00c6..e56864ad 100644 --- a/src/Helper/Navigation/Menu.php +++ b/src/Helper/Navigation/Menu.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Navigation; @@ -18,10 +17,6 @@ /** * Helper for rendering menus from navigation containers - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class Menu extends AbstractHelper { diff --git a/src/Helper/Navigation/PluginManager.php b/src/Helper/Navigation/PluginManager.php index 3c4c4e71..29ec3329 100644 --- a/src/Helper/Navigation/PluginManager.php +++ b/src/Helper/Navigation/PluginManager.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Navigation; @@ -19,10 +18,6 @@ * Enforces that helpers retrieved are instances of * Navigation\HelperInterface. Additionally, it registers a number of default * helpers. - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class PluginManager extends HelperPluginManager { diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index 45b8941a..32166e3e 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Navigation; @@ -23,10 +22,6 @@ * Helper for printing sitemaps * * @link http://www.sitemaps.org/protocol.php - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class Sitemap extends AbstractHelper { diff --git a/src/Helper/PaginationControl.php b/src/Helper/PaginationControl.php index 63b44c63..b4948a10 100644 --- a/src/Helper/PaginationControl.php +++ b/src/Helper/PaginationControl.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,10 +13,6 @@ use Zend\View; use Zend\View\Exception; -/** - * @category Zend - * @package Zend_View - */ class PaginationControl extends AbstractHelper { /** diff --git a/src/Helper/Partial.php b/src/Helper/Partial.php index 264d8f3c..cb2d933a 100644 --- a/src/Helper/Partial.php +++ b/src/Helper/Partial.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -15,9 +14,6 @@ /** * Helper for rendering a template fragment in its own variable scope. - * - * @package Zend_View - * @subpackage Helper */ class Partial extends AbstractHelper { diff --git a/src/Helper/PartialLoop.php b/src/Helper/PartialLoop.php index 6daf303b..51da72b5 100644 --- a/src/Helper/PartialLoop.php +++ b/src/Helper/PartialLoop.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -18,9 +17,6 @@ /** * Helper for rendering a template fragment in its own variable scope; iterates * over data provided and renders for each iteration. - * - * @package Zend_View - * @subpackage Helper */ class PartialLoop extends Partial { diff --git a/src/Helper/Placeholder.php b/src/Helper/Placeholder.php index 21be1064..32f62f8f 100644 --- a/src/Helper/Placeholder.php +++ b/src/Helper/Placeholder.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -17,9 +16,6 @@ * Placeholder to make its typical usage obvious, but can be used just as easily * for non-Placeholder things. That said, the support for this is only * guaranteed to effect subsequently rendered templates, and of course Layouts. - * - * @package Zend_View - * @subpackage Helper */ class Placeholder extends AbstractHelper { diff --git a/src/Helper/Placeholder/Container.php b/src/Helper/Placeholder/Container.php index ac1d0f08..eff1a325 100644 --- a/src/Helper/Placeholder/Container.php +++ b/src/Helper/Placeholder/Container.php @@ -5,16 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Placeholder; /** * Container for placeholder values - * - * @package Zend_View - * @subpackage Helper */ class Container extends Container\AbstractContainer { diff --git a/src/Helper/Placeholder/Container/AbstractContainer.php b/src/Helper/Placeholder/Container/AbstractContainer.php index 16096ab4..caa3668e 100644 --- a/src/Helper/Placeholder/Container/AbstractContainer.php +++ b/src/Helper/Placeholder/Container/AbstractContainer.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Placeholder\Container; @@ -14,9 +13,6 @@ /** * Abstract class representing container for placeholder values - * - * @package Zend_View - * @subpackage Helper */ abstract class AbstractContainer extends \ArrayObject { diff --git a/src/Helper/Placeholder/Container/AbstractStandalone.php b/src/Helper/Placeholder/Container/AbstractStandalone.php index 921bcf81..fc6e0238 100644 --- a/src/Helper/Placeholder/Container/AbstractStandalone.php +++ b/src/Helper/Placeholder/Container/AbstractStandalone.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Placeholder\Container; @@ -17,9 +16,6 @@ /** * Base class for targeted placeholder helpers - * - * @package Zend_View - * @subpackage Helper */ abstract class AbstractStandalone extends \Zend\View\Helper\AbstractHelper diff --git a/src/Helper/Placeholder/Registry.php b/src/Helper/Placeholder/Registry.php index e4a4f003..cb6ad672 100644 --- a/src/Helper/Placeholder/Registry.php +++ b/src/Helper/Placeholder/Registry.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Placeholder; @@ -14,9 +13,6 @@ /** * Registry for placeholder containers - * - * @package Zend_View - * @subpackage Helper */ class Registry { diff --git a/src/Helper/RenderChildModel.php b/src/Helper/RenderChildModel.php index f40c7432..153c767b 100644 --- a/src/Helper/RenderChildModel.php +++ b/src/Helper/RenderChildModel.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -18,9 +17,6 @@ * * Finds children matching "capture-to" values, and renders them using the * composed view instance. - * - * @package Zend_View - * @subpackage Helper */ class RenderChildModel extends AbstractHelper { diff --git a/src/Helper/RenderToPlaceholder.php b/src/Helper/RenderToPlaceholder.php index e0d81602..305669e7 100644 --- a/src/Helper/RenderToPlaceholder.php +++ b/src/Helper/RenderToPlaceholder.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -15,9 +14,6 @@ /** * Renders a template and stores the rendered output as a placeholder * variable for later use. - * - * @package Zend_View - * @subpackage Helper */ class RenderToPlaceholder extends AbstractHelper { diff --git a/src/Helper/ServerUrl.php b/src/Helper/ServerUrl.php index 8c91f49a..6dded929 100644 --- a/src/Helper/ServerUrl.php +++ b/src/Helper/ServerUrl.php @@ -5,17 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; /** * Helper for returning the current server URL (optionally with request URI) - * - * @category Zend - * @package Zend_View - * @subpackage Helper */ class ServerUrl extends AbstractHelper { diff --git a/src/Helper/Service/FlashMessengerFactory.php b/src/Helper/Service/FlashMessengerFactory.php index 925fb67e..7838513b 100644 --- a/src/Helper/Service/FlashMessengerFactory.php +++ b/src/Helper/Service/FlashMessengerFactory.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper\Service; @@ -14,11 +13,6 @@ use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View\Helper\FlashMessenger; -/** - * @category Zend - * @package Zend_View - * @subpackage Helper - */ class FlashMessengerFactory implements FactoryInterface { public function createService(ServiceLocatorInterface $serviceLocator) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index 4f281f8d..6cba9ceb 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -17,9 +16,6 @@ /** * Helper for making easy links and getting urls that depend on the routes and router. - * - * @package Zend_View - * @subpackage Helper */ class Url extends AbstractHelper { diff --git a/src/Helper/ViewModel.php b/src/Helper/ViewModel.php index b55ba2e8..264fc958 100644 --- a/src/Helper/ViewModel.php +++ b/src/Helper/ViewModel.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -14,9 +13,6 @@ /** * Helper for storing and retrieving the root and current view model - * - * @package Zend_View - * @subpackage Helper */ class ViewModel extends AbstractHelper { diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 80ff9faf..d5e045c4 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View; @@ -20,9 +19,6 @@ * Enforces that helpers retrieved are instances of * Helper\HelperInterface. Additionally, it registers a number of default * helpers. - * - * @category Zend - * @package Zend_View */ class HelperPluginManager extends AbstractPluginManager { diff --git a/src/Model/ClearableModelInterface.php b/src/Model/ClearableModelInterface.php index 9d88e535..50501710 100644 --- a/src/Model/ClearableModelInterface.php +++ b/src/Model/ClearableModelInterface.php @@ -5,7 +5,6 @@ * @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_View */ namespace Zend\View\Model; @@ -15,10 +14,6 @@ * * View models implementing this interface allow clearing children, options, * and variables. - * - * @category Zend - * @package Zend_View - * @subpackage Model */ interface ClearableModelInterface { diff --git a/src/Model/ConsoleModel.php b/src/Model/ConsoleModel.php index 35ccaf37..77400f14 100644 --- a/src/Model/ConsoleModel.php +++ b/src/Model/ConsoleModel.php @@ -12,9 +12,6 @@ * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * - * @category Zend - * @package Zend_View - * @subpackage Model * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -23,9 +20,6 @@ /** - * @category Zend - * @package Zend_View - * @subpackage Model * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/src/Model/FeedModel.php b/src/Model/FeedModel.php index 3791fe99..4a1cdc3f 100644 --- a/src/Model/FeedModel.php +++ b/src/Model/FeedModel.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Model; @@ -15,10 +14,6 @@ /** * Marker view model for indicating feed data. - * - * @category Zend - * @package Zend_View - * @subpackage Model */ class FeedModel extends ViewModel { diff --git a/src/Model/JsonModel.php b/src/Model/JsonModel.php index 830b4559..9bbed832 100644 --- a/src/Model/JsonModel.php +++ b/src/Model/JsonModel.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Model; @@ -14,11 +13,6 @@ use Zend\Json\Json; use Zend\Stdlib\ArrayUtils; -/** - * @category Zend - * @package Zend_View - * @subpackage Model - */ class JsonModel extends ViewModel { /** diff --git a/src/Model/ModelInterface.php b/src/Model/ModelInterface.php index 36e06983..804fdbc3 100644 --- a/src/Model/ModelInterface.php +++ b/src/Model/ModelInterface.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Model; @@ -20,10 +19,6 @@ * to the model. * * Extends "IteratorAggregate"; should allow iterating over children. - * - * @category Zend - * @package Zend_View - * @subpackage Model */ interface ModelInterface extends Countable, IteratorAggregate { diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index 5b712ed6..47f3f40a 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Model; @@ -18,11 +17,6 @@ use Zend\View\Model; use Zend\View\Variables as ViewVariables; -/** - * @category Zend - * @package Zend_View - * @subpackage Model - */ class ViewModel implements ModelInterface, ClearableModelInterface { /** diff --git a/src/Renderer/ConsoleRenderer.php b/src/Renderer/ConsoleRenderer.php index 50fc2994..6719604f 100644 --- a/src/Renderer/ConsoleRenderer.php +++ b/src/Renderer/ConsoleRenderer.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Renderer; @@ -20,9 +19,6 @@ * Note: all private variables in this class are prefixed with "__". This is to * mark them as part of the internal implementation, and thus prevent conflict * with variables injected into the renderer. - * - * @category Zend - * @package Zend_View */ class ConsoleRenderer implements RendererInterface, TreeRendererInterface { diff --git a/src/Renderer/FeedRenderer.php b/src/Renderer/FeedRenderer.php index 06486508..3e488a95 100644 --- a/src/Renderer/FeedRenderer.php +++ b/src/Renderer/FeedRenderer.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Renderer; @@ -17,10 +16,6 @@ /** * Interface class for Zend_View compatible template engine implementations - * - * @category Zend - * @package Zend_View - * @subpackage Renderer */ class FeedRenderer implements RendererInterface { diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php index 8a1ed04c..f55e9373 100644 --- a/src/Renderer/JsonRenderer.php +++ b/src/Renderer/JsonRenderer.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Renderer; @@ -22,10 +21,6 @@ /** * JSON renderer - * - * @category Zend - * @package Zend_View - * @subpackage Renderer */ class JsonRenderer implements Renderer, TreeRendererInterface { diff --git a/src/Renderer/PhpRenderer.php b/src/Renderer/PhpRenderer.php index 92901a85..29fef051 100644 --- a/src/Renderer/PhpRenderer.php +++ b/src/Renderer/PhpRenderer.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Renderer; @@ -28,9 +27,6 @@ * Note: all private variables in this class are prefixed with "__". This is to * mark them as part of the internal implementation, and thus prevent conflict * with variables injected into the renderer. - * - * @category Zend - * @package Zend_View */ class PhpRenderer implements Renderer, TreeRendererInterface { diff --git a/src/Renderer/RendererInterface.php b/src/Renderer/RendererInterface.php index f238c151..79405b63 100644 --- a/src/Renderer/RendererInterface.php +++ b/src/Renderer/RendererInterface.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Renderer; @@ -15,9 +14,6 @@ /** * Interface class for Zend_View compatible template engine implementations - * - * @category Zend - * @package Zend_View */ interface RendererInterface { diff --git a/src/Renderer/TreeRendererInterface.php b/src/Renderer/TreeRendererInterface.php index 60ba0994..3407a9fd 100644 --- a/src/Renderer/TreeRendererInterface.php +++ b/src/Renderer/TreeRendererInterface.php @@ -5,16 +5,10 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Renderer; -/** - * @category Zend - * @package Zend_View - * @subpackage Renderer - */ interface TreeRendererInterface { /** diff --git a/src/Resolver/AggregateResolver.php b/src/Resolver/AggregateResolver.php index 70d77338..2dc907ae 100644 --- a/src/Resolver/AggregateResolver.php +++ b/src/Resolver/AggregateResolver.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Resolver; @@ -16,11 +15,6 @@ use Zend\View\Renderer\RendererInterface as Renderer; use Zend\View\Resolver\ResolverInterface as Resolver; -/** - * @category Zend - * @package Zend_View - * @subpackage Resolver - */ class AggregateResolver implements Countable, IteratorAggregate, ResolverInterface { const FAILURE_NO_RESOLVERS = 'AggregateResolver_Failure_No_Resolvers'; diff --git a/src/Resolver/ResolverInterface.php b/src/Resolver/ResolverInterface.php index b5e58694..37d9dd3e 100644 --- a/src/Resolver/ResolverInterface.php +++ b/src/Resolver/ResolverInterface.php @@ -5,18 +5,12 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Resolver; use Zend\View\Renderer\RendererInterface as Renderer; -/** - * @category Zend - * @package Zend_View - * @subpackage Resolver - */ interface ResolverInterface { /** diff --git a/src/Resolver/TemplateMapResolver.php b/src/Resolver/TemplateMapResolver.php index a4fadf02..6c649def 100644 --- a/src/Resolver/TemplateMapResolver.php +++ b/src/Resolver/TemplateMapResolver.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Resolver; @@ -17,11 +16,6 @@ use Zend\View\Exception; use Zend\View\Renderer\RendererInterface as Renderer; -/** - * @category Zend - * @package Zend_View - * @subpackage Resolver - */ class TemplateMapResolver implements IteratorAggregate, ResolverInterface { /** diff --git a/src/Resolver/TemplatePathStack.php b/src/Resolver/TemplatePathStack.php index eaf19712..c5ebb487 100644 --- a/src/Resolver/TemplatePathStack.php +++ b/src/Resolver/TemplatePathStack.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Resolver; @@ -18,10 +17,6 @@ /** * Resolves view scripts based on a stack of paths - * - * @category Zend - * @package Zend_View - * @subpackage Resolver */ class TemplatePathStack implements ResolverInterface { diff --git a/src/Strategy/FeedStrategy.php b/src/Strategy/FeedStrategy.php index 4796ea27..57545f06 100644 --- a/src/Strategy/FeedStrategy.php +++ b/src/Strategy/FeedStrategy.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Strategy; @@ -18,11 +17,6 @@ use Zend\View\Renderer\FeedRenderer; use Zend\View\ViewEvent; -/** - * @category Zend - * @package Zend_View - * @subpackage Strategy - */ class FeedStrategy implements ListenerAggregateInterface { /** diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 097738b9..4a2be49d 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Strategy; @@ -17,11 +16,6 @@ use Zend\View\Renderer\JsonRenderer; use Zend\View\ViewEvent; -/** - * @category Zend - * @package Zend_View - * @subpackage Strategy - */ class JsonStrategy implements ListenerAggregateInterface { /** diff --git a/src/Strategy/PhpRendererStrategy.php b/src/Strategy/PhpRendererStrategy.php index 40c5c92a..92fe5d9d 100644 --- a/src/Strategy/PhpRendererStrategy.php +++ b/src/Strategy/PhpRendererStrategy.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Strategy; @@ -15,11 +14,6 @@ use Zend\View\Renderer\PhpRenderer; use Zend\View\ViewEvent; -/** - * @category Zend - * @package Zend_View - * @subpackage Strategy - */ class PhpRendererStrategy implements ListenerAggregateInterface { /** diff --git a/src/Stream.php b/src/Stream.php index 9aefbe0e..6fdd012c 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View; @@ -22,9 +21,6 @@ * written by * Mike Naberezny (@link http://mikenaberezny.com) * Paul M. Jones (@link http://paul-m-jones.com) - * - * @category Zend - * @package Zend_View */ class Stream { diff --git a/src/Variables.php b/src/Variables.php index 94157e09..f917389e 100644 --- a/src/Variables.php +++ b/src/Variables.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View; @@ -18,8 +17,6 @@ * @todo Allow specifying string names for manager, filter chain, variables * @todo Move escaping into variables object * @todo Move strict variables into variables object - * @category Zend - * @package Zend_View */ class Variables extends ArrayObject { diff --git a/src/View.php b/src/View.php index 246c5f83..511f406a 100644 --- a/src/View.php +++ b/src/View.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View; @@ -19,10 +18,6 @@ use Zend\View\Renderer\RendererInterface as Renderer; use Zend\View\Renderer\TreeRendererInterface; -/** - * @category Zend - * @package Zend_View - */ class View implements EventManagerAwareInterface { /** diff --git a/src/ViewEvent.php b/src/ViewEvent.php index 0c8aa390..2392f1d3 100644 --- a/src/ViewEvent.php +++ b/src/ViewEvent.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View; @@ -17,10 +16,6 @@ use Zend\View\Model\ModelInterface as Model; use Zend\View\Renderer\RendererInterface as Renderer; -/** - * @category Zend - * @package Zend_View - */ class ViewEvent extends Event { /**#@+ From 1b4a9652573f792dda443e7106ebcd225065caa7 Mon Sep 17 00:00:00 2001 From: frank87 Date: Tue, 22 Jan 2013 22:45:03 +0100 Subject: [PATCH 23/68] BugFix for hasAcl and hasRole: Both method ignore default member variables --- test/Helper/Navigation/AbstractHelperTest.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/Helper/Navigation/AbstractHelperTest.php b/test/Helper/Navigation/AbstractHelperTest.php index 4542397f..fd0b157a 100644 --- a/test/Helper/Navigation/AbstractHelperTest.php +++ b/test/Helper/Navigation/AbstractHelperTest.php @@ -1,10 +1,5 @@ Date: Wed, 23 Jan 2013 12:30:01 +0100 Subject: [PATCH 24/68] added braces to null comparison --- src/Renderer/JsonRenderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php index 1f5fd49c..0f088a7c 100644 --- a/src/Renderer/JsonRenderer.php +++ b/src/Renderer/JsonRenderer.php @@ -107,7 +107,7 @@ public function setJsonpCallback($callback) */ public function hasJsonpCallback() { - return null !== $this->jsonpCallback; + return (null !== $this->jsonpCallback); } /** From 47f3d2f3152819adf3b82715659135b1f40a416a Mon Sep 17 00:00:00 2001 From: frank87 Date: Wed, 23 Jan 2013 20:08:30 +0100 Subject: [PATCH 25/68] Refactoring as its described in https://github.com/zendframework/zf2/pull/3530 --- src/Helper/Navigation/AbstractHelper.php | 8 ++++---- test/Helper/Navigation/AbstractHelperTest.php | 20 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 828d5b2c..7c002929 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -567,8 +567,8 @@ public function hasContainer() */ public function hasAcl() { - if ($this->acl instanceof \Zend\Permissions\Acl\Acl || - static::$defaultAcl instanceof \Zend\Permissions\Acl\Acl) { + if ($this->acl instanceof Acl\Acl || + static::$defaultAcl instanceof Acl\Acl) { return true; } @@ -584,9 +584,9 @@ public function hasAcl() */ public function hasRole() { - if ($this->role instanceof \Zend\Permissions\Acl\Role\RoleInterface || + if ($this->role instanceof Acl\Role\RoleInterface || is_string($this->role) || - static::$defaultRole instanceof \Zend\Permissions\Acl\Role\RoleInterface || + static::$defaultRole instanceof Acl\Role\RoleInterface || is_string(static::$defaultRole)) { return true; } diff --git a/test/Helper/Navigation/AbstractHelperTest.php b/test/Helper/Navigation/AbstractHelperTest.php index fd0b157a..40b12d54 100644 --- a/test/Helper/Navigation/AbstractHelperTest.php +++ b/test/Helper/Navigation/AbstractHelperTest.php @@ -5,6 +5,16 @@ class AbstractHelperTest extends AbstractTest { + + protected function tearDown() + { + parent::tearDown(); + $this->_helper->setDefaultAcl(null); + $this->_helper->setAcl(null); + $this->_helper->setDefaultRole(null); + $this->_helper->setRole(null); + } + /** * Class name for view helper to test * @@ -63,14 +73,4 @@ public function testHasRoleChecksMemberVariable() $this->assertEquals(true, $this->_helper->hasRole()); } - protected function tearDown() - { - parent::tearDown(); - $this->_helper->setDefaultAcl(null); - $this->_helper->setAcl(null); - $this->_helper->setDefaultRole(null); - $this->_helper->setRole(null); - } - - } From 88eec35299cd96a6870127b94e0746719a8a6879 Mon Sep 17 00:00:00 2001 From: frank87 Date: Wed, 23 Jan 2013 20:10:27 +0100 Subject: [PATCH 26/68] Refactoring as its described in https://github.com/zendframework/zf2/pull/3530 --- test/Helper/Navigation/AbstractHelperTest.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/Helper/Navigation/AbstractHelperTest.php b/test/Helper/Navigation/AbstractHelperTest.php index 40b12d54..5a23a3bb 100644 --- a/test/Helper/Navigation/AbstractHelperTest.php +++ b/test/Helper/Navigation/AbstractHelperTest.php @@ -5,16 +5,6 @@ class AbstractHelperTest extends AbstractTest { - - protected function tearDown() - { - parent::tearDown(); - $this->_helper->setDefaultAcl(null); - $this->_helper->setAcl(null); - $this->_helper->setDefaultRole(null); - $this->_helper->setRole(null); - } - /** * Class name for view helper to test * @@ -29,6 +19,15 @@ protected function tearDown() */ protected $_helper; + protected function tearDown() + { + parent::tearDown(); + $this->_helper->setDefaultAcl(null); + $this->_helper->setAcl(null); + $this->_helper->setDefaultRole(null); + $this->_helper->setRole(null); + } + public function testHasACLChecksDefaultACL() { $aclContainer = $this->_getAcl(); From 565ff2876e2cee0069a0004ceac9d7cebbac8fdb Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 25 Jan 2013 16:40:24 +0100 Subject: [PATCH 27/68] [zendframework/zf2#3530] CS fixes - Update logical conditions; logical operators go on next line; open brace on next line when you have multi-line conditions - Add file-level docblock to test class --- src/Helper/Navigation/AbstractHelper.php | 14 ++++++++------ test/Helper/Navigation/AbstractHelperTest.php | 13 ++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 7c002929..dfd92540 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -567,8 +567,9 @@ public function hasContainer() */ public function hasAcl() { - if ($this->acl instanceof Acl\Acl || - static::$defaultAcl instanceof Acl\Acl) { + if ($this->acl instanceof Acl\Acl + || static::$defaultAcl instanceof Acl\Acl + ) { return true; } @@ -584,10 +585,11 @@ public function hasAcl() */ public function hasRole() { - if ($this->role instanceof Acl\Role\RoleInterface || - is_string($this->role) || - static::$defaultRole instanceof Acl\Role\RoleInterface || - is_string(static::$defaultRole)) { + if ($this->role instanceof Acl\Role\RoleInterface + || is_string($this->role) + || static::$defaultRole instanceof Acl\Role\RoleInterface + || is_string(static::$defaultRole) + ) { return true; } diff --git a/test/Helper/Navigation/AbstractHelperTest.php b/test/Helper/Navigation/AbstractHelperTest.php index 5a23a3bb..8c6652bd 100644 --- a/test/Helper/Navigation/AbstractHelperTest.php +++ b/test/Helper/Navigation/AbstractHelperTest.php @@ -1,4 +1,12 @@ _getAcl(); - /** @var $acl \Zend\Permissions\Acl\Acl */ $acl = $aclContainer['acl']; $this->assertEquals(false, $this->_helper->hasACL()); @@ -42,7 +49,6 @@ public function testHasACLChecksDefaultACL() public function testHasACLChecksMemberVariable() { $aclContainer = $this->_getAcl(); - /** @var $acl \Zend\Permissions\Acl\Acl */ $acl = $aclContainer['acl']; $this->assertEquals(false, $this->_helper->hasAcl()); @@ -53,7 +59,6 @@ public function testHasACLChecksMemberVariable() public function testHasRoleChecksDefaultRole() { $aclContainer = $this->_getAcl(); - /** @var $role \Zend\Permissions\Acl\Role */ $role = $aclContainer['role']; $this->assertEquals(false, $this->_helper->hasRole()); @@ -64,12 +69,10 @@ public function testHasRoleChecksDefaultRole() public function testHasRoleChecksMemberVariable() { $aclContainer = $this->_getAcl(); - /** @var $role \Zend\Permissions\Acl\Role */ $role = $aclContainer['role']; $this->assertEquals(false, $this->_helper->hasRole()); $this->_helper->setRole($role); $this->assertEquals(true, $this->_helper->hasRole()); } - } From 3cb4c0f4e07464d8065982cdb85a61c909e76227 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 25 Jan 2013 16:43:37 +0100 Subject: [PATCH 28/68] [zendframework/zf2#3530] Remove @package annotation - these are removed on the develop branch --- test/Helper/Navigation/AbstractHelperTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Helper/Navigation/AbstractHelperTest.php b/test/Helper/Navigation/AbstractHelperTest.php index 8c6652bd..b8c6d921 100644 --- a/test/Helper/Navigation/AbstractHelperTest.php +++ b/test/Helper/Navigation/AbstractHelperTest.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace ZendTest\View\Helper\Navigation; From ebe54b870f8beb70e11176c161d0a0c3685bc73d Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 25 Jan 2013 17:37:55 +0100 Subject: [PATCH 29/68] Fix test failure in PhpRenderer tests - Due to change in PHPUnit, can no longer have top-level Exception as an expected exception --- test/PhpRendererTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/PhpRendererTest.php b/test/PhpRendererTest.php index 85110957..0e66125b 100644 --- a/test/PhpRendererTest.php +++ b/test/PhpRendererTest.php @@ -340,8 +340,12 @@ public function testRendererRaisesExceptionInCaseOfExceptionInView() $model = new ViewModel(); $model->setTemplate('exception'); - $this->setExpectedException('Exception', 'thrown from view script'); - $this->renderer->render($model); + try { + $this->renderer->render($model); + $this->fail('Exception from renderer should propagate'); + } catch (\Exception $e) { + $this->assertInstanceOf('Exception', $e); + } } public function testRendererRaisesExceptionIfResolverCannotResolveTemplate() From 05edc70bf8d270a9ddc260a4bced63e9bb87a5f1 Mon Sep 17 00:00:00 2001 From: wryck7 Date: Mon, 28 Jan 2013 02:03:48 -0200 Subject: [PATCH 30/68] Fixed breakline to script with content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit it was printing:     now it is printing:      this does not affect when there is no content, it still prints:      --- src/Helper/HeadScript.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/HeadScript.php b/src/Helper/HeadScript.php index cced6c83..7928019b 100644 --- a/src/Helper/HeadScript.php +++ b/src/Helper/HeadScript.php @@ -425,7 +425,7 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd) $html .= $indent . PHP_EOL . ' ' . $escapeEnd; } - $html .= $indent; + $html .= PHP_EOL . $indent; } $html .= ''; From 05af7e983eee57c401d98a317b53b14bb4a4314d Mon Sep 17 00:00:00 2001 From: wryck7 Date: Mon, 28 Jan 2013 02:06:36 -0200 Subject: [PATCH 31/68] Removed unnecessary space --- src/Helper/HeadScript.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/HeadScript.php b/src/Helper/HeadScript.php index 7928019b..a515c01b 100644 --- a/src/Helper/HeadScript.php +++ b/src/Helper/HeadScript.php @@ -433,7 +433,7 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd) && !empty($item->attributes['conditional']) && is_string($item->attributes['conditional'])) { - $html = $indent . ''; + $html = $indent . ''; } else { $html = $indent . $html; } From 92f9c5ea52e014ef0f6e4d7ed57ed13e88880e8f Mon Sep 17 00:00:00 2001 From: wryck7 Date: Wed, 30 Jan 2013 12:28:08 -0200 Subject: [PATCH 32/68] Fix bug when $indent have some string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit assuming $ident = '¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨'; before: ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ now: ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ --- src/Helper/HeadScript.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/HeadScript.php b/src/Helper/HeadScript.php index a515c01b..5a98a1c5 100644 --- a/src/Helper/HeadScript.php +++ b/src/Helper/HeadScript.php @@ -422,7 +422,7 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd) $html .= $indent . ' ' . $item->source; if ($addScriptEscape) { - $html .= $indent . PHP_EOL . ' ' . $escapeEnd; + $html .= PHP_EOL . $indent . ' ' . $escapeEnd; } $html .= PHP_EOL . $indent; From 4bf02d7d0f594a2aeedf3ab36a5644d385481a58 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 8 Feb 2013 13:36:38 -0600 Subject: [PATCH 33/68] [zendframework/zf2#2463] Created failing test - Created a test demonstrating the issue --- test/Renderer/JsonRendererTest.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/Renderer/JsonRendererTest.php b/test/Renderer/JsonRendererTest.php index baae64cf..b0a34259 100644 --- a/test/Renderer/JsonRendererTest.php +++ b/test/Renderer/JsonRendererTest.php @@ -14,6 +14,7 @@ use PHPUnit_Framework_TestCase as TestCase; use stdClass; use Zend\View\Renderer\JsonRenderer; +use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; /** @@ -234,4 +235,30 @@ public function testRendersNonTraversableNonJsonSerializableObjectsAsJsonObjects $test = $this->renderer->render($model); $this->assertEquals($expected, $test); } + + /** + * @group 2463 + */ + public function testRecursesJsonModelChildrenWhenRendering() + { + $root = new JsonModel(array('foo' => 'bar')); + $child1 = new JsonModel(array('foo' => 'bar')); + $child2 = new JsonModel(array('foo' => 'bar')); + $child1->setCaptureTo('child1'); + $child2->setCaptureTo('child2'); + $root->addChild($child1) + ->addChild($child2); + + $expected = array( + 'foo' => 'bar', + 'child1' => array( + 'foo' => 'bar', + ), + 'child2' => array( + 'foo' => 'bar', + ), + ); + $test = $this->renderer->render($root); + $this->assertEquals(json_encode($expected), $test); + } } From d2aa2cb4ed5303ff39cc8d3884ac03ff40be69ca Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 8 Feb 2013 13:56:59 -0600 Subject: [PATCH 34/68] [zendframework/zf2#2463] Allow recursing children in JsonModels - implements behavior allowing recursion of children in json models --- src/Renderer/JsonRenderer.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php index b5f88b58..44e718e6 100644 --- a/src/Renderer/JsonRenderer.php +++ b/src/Renderer/JsonRenderer.php @@ -130,6 +130,8 @@ public function render($nameOrModel, $values = null) // Serialize variables in view model if ($nameOrModel instanceof Model) { if ($nameOrModel instanceof JsonModel) { + $children = $this->recurseModel($nameOrModel, false); + $this->injectChildren($nameOrModel, $children); $values = $nameOrModel->serialize(); } else { $values = $this->recurseModel($nameOrModel); @@ -185,9 +187,13 @@ public function canRenderTrees() * @param Model $model * @return array */ - protected function recurseModel(Model $model) + protected function recurseModel(Model $model, $mergeWithVariables = true) { - $values = $model->getVariables(); + $values = array(); + if ($mergeWithVariables) { + $values = $model->getVariables(); + } + if ($values instanceof Traversable) { $values = ArrayUtils::iteratorToArray($values); } @@ -207,7 +213,8 @@ protected function recurseModel(Model $model) $childValues = $this->recurseModel($child); if ($captureTo) { // Capturing to a specific key - //TODO please complete if append is true. must change old value to array and append to array? + // TODO please complete if append is true. must change old + // value to array and append to array? $values[$captureTo] = $childValues; } elseif ($mergeChildren) { // Merging values with parent @@ -216,4 +223,19 @@ protected function recurseModel(Model $model) } return $values; } + + /** + * Inject discovered child model values into parent model + * + * @todo detect collisions and decide whether to append and/or aggregate? + * @param Model $model + * @param array $children + */ + protected function injectChildren(Model $model, array $children) + { + foreach ($children as $child => $value) { + // TODO detect collisions and decide whether to append and/or aggregate? + $model->setVariable($child, $value); + } + } } From 0e07a55d62079b53915bfb1b4d6828e26ac6b651 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 8 Feb 2013 14:23:17 -0600 Subject: [PATCH 35/68] Updated docblock - added new param --- src/Renderer/JsonRenderer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php index 44e718e6..831210b7 100644 --- a/src/Renderer/JsonRenderer.php +++ b/src/Renderer/JsonRenderer.php @@ -185,6 +185,8 @@ public function canRenderTrees() * Retrieve values from a model and recurse its children to build a data structure * * @param Model $model + * @param bool $mergeWithVariables Whether or not to merge children with + * the variables of the $model * @return array */ protected function recurseModel(Model $model, $mergeWithVariables = true) From 017ac58b458315b047aa3a4e5bf621fbb609cf3d Mon Sep 17 00:00:00 2001 From: Francis Daigle Date: Mon, 11 Feb 2013 18:26:34 -0700 Subject: [PATCH 36/68] Add trigger to 'accept' method. Remove previous changes. --- src/Helper/Navigation/AbstractHelper.php | 226 ++++++++-------------- src/Helper/Navigation/HelperInterface.php | 17 +- 2 files changed, 81 insertions(+), 162 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 611dc36d..408cfe1c 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -10,12 +10,14 @@ namespace Zend\View\Helper\Navigation; use RecursiveIteratorIterator; +use Zend\EventManager\EventManager; +use Zend\EventManager\EventManagerAwareInterface; +use Zend\EventManager\EventManagerInterface; use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\TranslatorAwareInterface; use Zend\Navigation; use Zend\Navigation\Page\AbstractPage; use Zend\Permissions\Acl; -use Zend\Permissions\Rbac; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View; @@ -25,10 +27,16 @@ * Base class for navigational helpers */ abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements + EventManagerAwareInterface, HelperInterface, ServiceLocatorAwareInterface, TranslatorAwareInterface { + /** + * @var EventManagerInterface + */ + protected $events; + /** * @var ServiceLocatorInterface */ @@ -68,13 +76,6 @@ abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements * @var Acl\AclInterface */ protected $acl; - - /** - * RBAC to use when iterating pages - * - * @var Rbac - */ - protected $rbac; /** * Whether invisible items should be rendered by this helper @@ -84,25 +85,18 @@ abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements protected $renderInvisible = false; /** - * ACL / RBAC role(s) to use when iterating pages + * ACL role to use when iterating pages * - * @var string|array|Acl\Role\RoleInterface + * @var string|Acl\Role\RoleInterface */ protected $role; - + /** * Whether ACL should be used for filtering out pages * * @var bool */ protected $useAcl = true; - - /** - * Whether RBAC should be used for filtering out pages - * - * @var bool - */ - protected $useRbac = false; /** * Translator (optional) @@ -134,10 +128,10 @@ abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements protected static $defaultAcl; /** - * Default ACL/RBAC role(s) to use when iterating pages if not explicitly set in the + * Default ACL role to use when iterating pages if not explicitly set in the * instance by calling {@link setRole()} * - * @var string|array|Acl\Role\RoleInterface + * @var string|Acl\Role\RoleInterface */ protected static $defaultRole; @@ -163,6 +157,38 @@ public function getServiceLocator() return $this->serviceLocator; } + /** + * Set the event manager. + * + * @param EventManagerInterface $events + * @return AbstractHelper + */ + public function setEventManager(EventManagerInterface $events) + { + $events->setIdentifiers(array( + __CLASS__, + get_called_class(), + )); + + $this->events = $events; + + return $this; + } + + /** + * Get the event manager. + * + * @return EventManagerInterface + */ + public function getEventManager() + { + if (null === $this->events) { + $this->setEventManager(new EventManager()); + } + + return $this->events; + } + /** * Sets navigation container the helper operates on by default * @@ -351,27 +377,6 @@ public function getAcl() return $this->acl; } - - /** - * Sets RBAC to use when iterating pages - * - * @return AbstractHelper fluent interface, returns self - */ - public function setRbac(Rbac\Rbac $rbac = null) - { - $this->rbac = $rbac; - return $this; - } - - /** - * Returns RBAC or null if it isn't set using {@link setRbac()} - * - * @return Rbac|null RBAC object or null - */ - public function getRbac() - { - return $this->rbac; - } /** * Sets ACL role(s) to use when iterating pages @@ -386,15 +391,14 @@ public function getRbac() */ public function setRole($role = null) { - if (null === $role - || is_string($role) - || is_array($role) - || $role instanceof Acl\Role\RoleInterface + if (null === $role || is_string($role) || + $role instanceof Acl\Role\RoleInterface ) { $this->role = $role; } else { throw new Exception\InvalidArgumentException(sprintf( - '$role must be null|string|array|Zend\Permissions\Role\RoleInterface; %s given', + '$role must be a string, null, or an instance of ' + . 'Zend\Permissions\Role\RoleInterface; %s given', (is_object($role) ? get_class($role) : gettype($role)) )); } @@ -403,12 +407,12 @@ public function setRole($role = null) } /** - * Returns ACL/RBAC role(s) to use when iterating pages, or null if it isn't set + * Returns ACL role to use when iterating pages, or null if it isn't set * using {@link setRole()} or {@link setDefaultRole()} * * Implements {@link HelperInterface::getRole()}. * - * @return string|array|Acl\Role\RoleInterface|null role or null + * @return string|Acl\Role\RoleInterface|null role or null */ public function getRole() { @@ -418,7 +422,7 @@ public function getRole() return $this->role; } - + /** * Sets whether ACL should be used * @@ -444,32 +448,6 @@ public function getUseAcl() { return $this->useAcl; } - - /** - * Sets whether RBAC should be used - * - * Implements {@link HelperInterface::setUseRbac()}. - * - * @param bool $useRbac [optional] whether RBAC should be used. Default is true. - * @return AbstractHelper fluent interface, returns self - */ - public function setUseRbac($useRbac = true) - { - $this->useRbac = (bool) $useRbac; - return $this; - } - - /** - * Returns whether RBAC should be used - * - * Implements {@link HelperInterface::getUseRbac()}. - * - * @return bool whether RBAC should be used - */ - public function getUseRbac() - { - return $this->useRbac; - } /** * Return renderInvisible flag @@ -635,17 +613,16 @@ public function hasAcl() } /** - * Checks if the helper has an ACL/RBAC role + * Checks if the helper has an ACL role * * Implements {@link HelperInterface::hasRole()}. * - * @return bool whether the helper has a an ACL/RBAC role or not + * @return bool whether the helper has a an ACL role or not */ public function hasRole() { if ($this->role instanceof Acl\Role\RoleInterface || is_string($this->role) - || is_array($this->role) || static::$defaultRole instanceof Acl\Role\RoleInterface || is_string(static::$defaultRole) ) { @@ -790,40 +767,40 @@ public function getTranslatorTextDomain() * Rules: * - If a page is not visible it is not accepted, unless RenderInvisible has * been set to true. - * - If helper has no ACL/RBAC, page is accepted. - * - If helper has ACL/RBAC, but no role, page is not accepted. + * - If helper has no ACL, page is accepted + * - If helper has ACL, but no role, page is not accepted * - If helper has ACL and role: - * - Page is accepted if ACL set and it has no resource or privilege. - * - Page is accepted if ACL set and allows page's resource or privilege. - * - If helper has RBAC and role: - * - Page accepted if RBAC set and has no permission. - * - Page is accepted if RBAC set and allows page's permission. + * - Page is accepted if it has no resource or privilege + * - Page is accepted if ACL allows page's resource or privilege * - If page is accepted by the rules above and $recursive is true, the page - * will not be accepted if it is the descendant of a non-accepted page. + * will not be accepted if it is the descendant of a non-accepted page. * - * @param AbstractPage $page Page to check - * @param bool $recursive [optional] - * If true, page will not be - * accepted if it is the descendant of a - * page that is not accepted. Default is true. - * whether page should be accepted - * @return bool + * @param AbstractPage $page page to check + * @param bool $recursive [optional] if true, page will not be + * accepted if it is the descendant of a + * page that is not accepted. Default is true. + * @return bool whether page should be accepted */ public function accept(AbstractPage $page, $recursive = true) { // accept by default $accept = true; - + if (!$page->isVisible(false) && !$this->getRenderInvisible()) { // don't accept invisible pages $accept = false; } elseif ($this->getUseAcl() && !$this->acceptAcl($page)) { // acl is not amused $accept = false; - } elseif ($this->getUseRbac() && !$this->acceptRbac($page)) { - $accept = false; + } else { + $params = array('page' => $page); + + // Trigger listener + $trigger = $this->getEventManager()->trigger('isAllowed', $this, $params); + + $accept = $trigger->last(); } - + if ($accept && $recursive) { $parent = $page->getParent(); if ($parent instanceof AbstractPage) { @@ -843,8 +820,8 @@ public function accept(AbstractPage $page, $recursive = true) * if the ACL allows access to it using the helper's role * - If page has no resource or privilege, page is accepted * - * @param AbstractPage $page Page to check - * @return bool Whether page is accepted by ACL + * @param AbstractPage $page page to check + * @return bool whether page is accepted by ACL */ protected function acceptAcl(AbstractPage $page) { @@ -853,55 +830,13 @@ protected function acceptAcl(AbstractPage $page) return true; } - $roles = (array) $this->getRole(); + $role = $this->getRole(); $resource = $page->getResource(); $privilege = $page->getPrivilege(); if ($resource || $privilege) { // determine using helper role and page resource/privilege - foreach ($roles as $role) { - - if ($acl->hasResource($resource) && $acl->isAllowed($role, $resource, $privilege)) { - return true; - } - } - - return false; - } - - return true; - } - - /** - * Determines whether a page should be accepted by RBAC when iterating. - * - * Rules: - * - If helper has no RBAC, page is accepted. - * - If page has a permission defined, page is accepted. - * - If page has no permission, page is accepted. - * - * @param AbstractPage $page Page to check - * @return bool Whether page is accepted by RBAC - */ - protected function acceptRbac(AbstractPage $page) - { - if (!$rbac = $this->getRbac()) { - return true; - } - - $roles = (array) $this->getRole(); - $permission = $page->getPermission(); - - if ($roles && $permission) { - - foreach ($roles as $role) { - - if ($rbac->isGranted($role, $permission)) { - return true; - } - } - - return false; + return $acl->hasResource($resource) && $acl->isAllowed($role, $resource, $privilege); } return true; @@ -989,15 +924,14 @@ public static function setDefaultRole($role = null) { if (null === $role || is_string($role) - || is_array($role) || $role instanceof Acl\Role\RoleInterface ) { static::$defaultRole = $role; } else { throw new Exception\InvalidArgumentException(sprintf( - '$role must be null|string|array|Zend\Permissions\Role\RoleInterface; %s given', + '$role must be null|string|Zend\Permissions\Role\RoleInterface; received "%s"', (is_object($role) ? get_class($role) : gettype($role)) )); } } -} +} \ No newline at end of file diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index 60c1286f..c7bf79b9 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -85,21 +85,6 @@ public function setUseAcl($useAcl = true); * @return bool whether ACL should be used */ public function getUseAcl(); - - /** - * Sets whether RBAC should be used - * - * @param bool $useRbac [optional] whether RBAC should be used. Default is true. - * @return HelperInterface fluent interface, returns self - */ - public function setUseRBAC($useRbac = false); - - /** - * Returns whether RBAC should be used - * - * @return bool whether RBAC should be used - */ - public function getUseRBAC(); /** * Return renderInvisible flag @@ -156,4 +141,4 @@ public function __toString(); * @throws \Zend\View\Exception\ExceptionInterface if unable to render */ public function render($container = null); -} +} \ No newline at end of file From bda673f27e01632c8985a7145d5d229dfa1e72ca Mon Sep 17 00:00:00 2001 From: Francis Daigle Date: Mon, 11 Feb 2013 19:13:14 -0700 Subject: [PATCH 37/68] Amend method documentation. --- src/Helper/Navigation/AbstractHelper.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 408cfe1c..e5de38dc 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -772,6 +772,7 @@ public function getTranslatorTextDomain() * - If helper has ACL and role: * - Page is accepted if it has no resource or privilege * - Page is accepted if ACL allows page's resource or privilege + * - If ACL disabled, "isAllowed" event listener is triggered. * - If page is accepted by the rules above and $recursive is true, the page * will not be accepted if it is the descendant of a non-accepted page. * @@ -787,17 +788,14 @@ public function accept(AbstractPage $page, $recursive = true) $accept = true; if (!$page->isVisible(false) && !$this->getRenderInvisible()) { - // don't accept invisible pages + // Don't accept invisible pages $accept = false; } elseif ($this->getUseAcl() && !$this->acceptAcl($page)) { - // acl is not amused + // Acl is not amused $accept = false; } else { $params = array('page' => $page); - - // Trigger listener $trigger = $this->getEventManager()->trigger('isAllowed', $this, $params); - $accept = $trigger->last(); } From c9cde64627739cf294a6dc2b5183335b7cfc3675 Mon Sep 17 00:00:00 2001 From: Martin Keckeis Date: Wed, 6 Mar 2013 09:15:04 +0100 Subject: [PATCH 38/68] Documentation improvement Zend\View\Stream --- src/Stream.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Stream.php b/src/Stream.php index 6fdd012c..6ee6eb62 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -27,7 +27,7 @@ class Stream /** * Current stream position. * - * @var int + * @var integer */ protected $pos = 0; @@ -47,6 +47,8 @@ class Stream /** * Opens the script file and converts markup. + * + * @return bool */ public function stream_open($path, $mode, $options, &$opened_path) { @@ -92,6 +94,8 @@ public function url_stat() /** * Reads from the stream. + * + * @return string|false */ public function stream_read($count) { @@ -103,6 +107,8 @@ public function stream_read($count) /** * Tells the current position in the stream. + * + * @return integer */ public function stream_tell() { @@ -112,6 +118,8 @@ public function stream_tell() /** * Tells if we are at the end of the stream. + * + * @return bool */ public function stream_eof() { @@ -121,6 +129,8 @@ public function stream_eof() /** * Stream statistics. + * + * @return array */ public function stream_stat() { @@ -130,6 +140,8 @@ public function stream_stat() /** * Seek to a specific point in the stream. + * + * @return bool */ public function stream_seek($offset, $whence) { From fd43d553869babbfd8514ffb51808791bafea238 Mon Sep 17 00:00:00 2001 From: Martin Keckeis Date: Wed, 6 Mar 2013 10:13:12 +0100 Subject: [PATCH 39/68] Update Stream.php integer -> int --- src/Stream.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stream.php b/src/Stream.php index 6ee6eb62..9e5ea6b9 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -27,7 +27,7 @@ class Stream /** * Current stream position. * - * @var integer + * @var int */ protected $pos = 0; @@ -108,7 +108,7 @@ public function stream_read($count) /** * Tells the current position in the stream. * - * @return integer + * @return int */ public function stream_tell() { From dfc7e93ba47d6bd30664d8c773d7634b347d2714 Mon Sep 17 00:00:00 2001 From: Bram Gerritsen Date: Thu, 7 Mar 2013 14:01:19 +0100 Subject: [PATCH 40/68] Fixed typehinting FQCN --- src/Renderer/PhpRenderer.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Renderer/PhpRenderer.php b/src/Renderer/PhpRenderer.php index 89187bd6..2923589f 100644 --- a/src/Renderer/PhpRenderer.php +++ b/src/Renderer/PhpRenderer.php @@ -31,19 +31,19 @@ * Convenience methods for build in helpers (@see __call): * * @method \Zend\View\Helper\BasePath basePath($file = null) - * @method \Zend\View\Helper\Cycle cycle(array $data = array(), $name = self::DEFAULT_NAME) + * @method \Zend\View\Helper\Cycle cycle(array $data = array(), $name = \Zend\View\Helper\Cycle::DEFAULT_NAME) * @method \Zend\View\Helper\DeclareVars declareVars() * @method \Zend\View\Helper\Doctype doctype($doctype = null) - * @method mixed escapeCss($value, $recurse = self::RECURSE_NONE) - * @method mixed escapeHtml($value, $recurse = self::RECURSE_NONE) - * @method mixed escapeHtmlAttr($value, $recurse = self::RECURSE_NONE) - * @method mixed escapeJs($value, $recurse = self::RECURSE_NONE) - * @method mixed escapeUrl($value, $recurse = self::RECURSE_NONE) + * @method mixed escapeCss($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE) + * @method mixed escapeHtml($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE) + * @method mixed escapeHtmlAttr($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE) + * @method mixed escapeJs($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE) + * @method mixed escapeUrl($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE) * @method \Zend\View\Helper\FlashMessenger flashMessenger($namespace = null) * @method \Zend\View\Helper\Gravatar gravatar($email = "", $options = array(), $attribs = array()) * @method \Zend\View\Helper\HeadLink headLink(array $attributes = null, $placement = \Zend\View\Helper\Placeholder\Container\AbstractContainer::APPEND) * @method \Zend\View\Helper\HeadMeta headMeta($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = \Zend\View\Helper\Placeholder\Container\AbstractContainer::APPEND) - * @method \Zend\View\Helper\HeadScript headScript($mode = HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript') + * @method \Zend\View\Helper\HeadScript headScript($mode = \Zend\View\Helper\HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript') * @method \Zend\View\Helper\HeadStyle headStyle($content = null, $placement = 'APPEND', $attributes = array()) * @method \Zend\View\Helper\HeadTitle headTitle($title = null, $setType = null) * @method string htmlFlash($data, array $attribs = array(), array $params = array(), $content = null) @@ -52,7 +52,7 @@ * @method string htmlPage($data, array $attribs = array(), array $params = array(), $content = null) * @method string htmlQuicktime($data, array $attribs = array(), array $params = array(), $content = null) * @method mixed|null identity() - * @method \Zend\View\Helper\InlineScript inlineScript($mode = HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript') + * @method \Zend\View\Helper\InlineScript inlineScript($mode = \Zend\View\Helper\HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript') * @method string|void json($data, array $jsonOptions = array()) * @method \Zend\View\Helper\Layout layout($template = null) * @method \Zend\View\Helper\Navigation navigation($container = null) From 7e81a59644b1c55a00755491d57c5c4cfba6cdba Mon Sep 17 00:00:00 2001 From: froschdesign Date: Fri, 8 Mar 2013 16:09:05 +0100 Subject: [PATCH 41/68] Hotfix/3858 - findHelper problem in Navigation Helper - update creation of internal hash - more unit tests added --- src/Helper/Navigation.php | 2 +- test/Helper/Navigation/NavigationTest.php | 83 +++++++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/src/Helper/Navigation.php b/src/Helper/Navigation.php index b0185427..93181752 100644 --- a/src/Helper/Navigation.php +++ b/src/Helper/Navigation.php @@ -184,7 +184,7 @@ public function findHelper($proxy, $strict = true) $helper = $plugins->get($proxy); $container = $this->getContainer(); - $hash = spl_object_hash($container); + $hash = spl_object_hash($container) . spl_object_hash($helper); if (!isset($this->injected[$hash])) { $helper->setContainer(); diff --git a/test/Helper/Navigation/NavigationTest.php b/test/Helper/Navigation/NavigationTest.php index 76f01de9..f8b0b449 100644 --- a/test/Helper/Navigation/NavigationTest.php +++ b/test/Helper/Navigation/NavigationTest.php @@ -463,6 +463,89 @@ public function testMultipleNavigations() $this->assertEquals($expected, $actual); } + /** + * @group #3859 + */ + public function testMultipleNavigationsWithDifferentHelpersAndDifferentContainers() + { + $sm = new ServiceManager(); + $nav1 = new Container(); + $nav2 = new Container(); + $sm->setService('nav1', $nav1); + $sm->setService('nav2', $nav2); + + $helper = new Navigation(); + $helper->setServiceLocator($sm); + + $menu = $helper('nav1')->menu(); + $actual = spl_object_hash($nav1); + $expected = spl_object_hash($menu->getContainer()); + $this->assertEquals($expected, $actual); + + $breadcrumbs = $helper('nav2')->breadcrumbs(); + $actual = spl_object_hash($nav2); + $expected = spl_object_hash($breadcrumbs->getContainer()); + $this->assertEquals($expected, $actual); + + $links = $helper()->links(); + $expected = spl_object_hash($links->getContainer()); + $this->assertEquals($expected, $actual); + } + + /** + * @group #3859 + */ + public function testMultipleNavigationsWithDifferentHelpersAndSameContainer() + { + $sm = new ServiceManager(); + $nav1 = new Container(); + $sm->setService('nav1', $nav1); + + $helper = new Navigation(); + $helper->setServiceLocator($sm); + + // Tests + $menu = $helper('nav1')->menu(); + $actual = spl_object_hash($nav1); + $expected = spl_object_hash($menu->getContainer()); + $this->assertEquals($expected, $actual); + + $breadcrumbs = $helper('nav1')->breadcrumbs(); + $expected = spl_object_hash($breadcrumbs->getContainer()); + $this->assertEquals($expected, $actual); + + $links = $helper()->links(); + $expected = spl_object_hash($links->getContainer()); + $this->assertEquals($expected, $actual); + } + + /** + * @group #3859 + */ + public function testMultipleNavigationsWithSameHelperAndSameContainer() + { + $sm = new ServiceManager(); + $nav1 = new Container(); + $sm->setService('nav1', $nav1); + + $helper = new Navigation(); + $helper->setServiceLocator($sm); + + // Test + $menu = $helper('nav1')->menu(); + $actual = spl_object_hash($nav1); + $expected = spl_object_hash($menu->getContainer()); + $this->assertEquals($expected, $actual); + + $menu = $helper('nav1')->menu(); + $expected = spl_object_hash($menu->getContainer()); + $this->assertEquals($expected, $actual); + + $menu = $helper()->menu(); + $expected = spl_object_hash($menu->getContainer()); + $this->assertEquals($expected, $actual); + } + /** * Returns the contens of the expected $file, normalizes newlines * @param string $file From 987e244e58de886937be4d75fca50d8d37d643b9 Mon Sep 17 00:00:00 2001 From: wryck7 Date: Sat, 9 Mar 2013 14:07:31 -0400 Subject: [PATCH 42/68] Fix for issue zendframework/zf2#2459 --- src/Resolver/TemplatePathStack.php | 5 ++++- test/TemplatePathStackTest.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Resolver/TemplatePathStack.php b/src/Resolver/TemplatePathStack.php index c5ebb487..0929fa84 100644 --- a/src/Resolver/TemplatePathStack.php +++ b/src/Resolver/TemplatePathStack.php @@ -105,6 +105,9 @@ public function setOptions($options) case 'use_stream_wrapper': $this->setUseStreamWrapper($value); break; + case 'default_suffix': + $this->setDefaultSuffix($value); + break; default: break; } @@ -296,7 +299,7 @@ public function resolve($name, Renderer $renderer = null) // Ensure we have the expected file extension $defaultSuffix = $this->getDefaultSuffix(); - if (pathinfo($name, PATHINFO_EXTENSION) != $defaultSuffix) {; + if (pathinfo($name, PATHINFO_EXTENSION) == '') {; $name .= '.' . $defaultSuffix; } diff --git a/test/TemplatePathStackTest.php b/test/TemplatePathStackTest.php index 6a525bd7..0f427e22 100644 --- a/test/TemplatePathStackTest.php +++ b/test/TemplatePathStackTest.php @@ -186,6 +186,7 @@ public function validOptions() $options = array( 'lfi_protection' => false, 'use_stream_wrapper' => true, + 'default_suffix' => 'php', ); return array( array($options), @@ -205,6 +206,8 @@ public function testAllowsSettingOptions($arg) $expected = (bool) ini_get('short_open_tag'); $this->assertSame($expected, $this->stack->useStreamWrapper()); + $this->assertSame($arg['default_suffix'], $this->stack->getDefaultSuffix()); + $this->assertEquals(array_reverse($this->paths), $this->stack->getPaths()->toArray()); } From 4f849d99d47e10c6c0ec42574b7a21e109333b18 Mon Sep 17 00:00:00 2001 From: wryck7 Date: Tue, 12 Mar 2013 08:47:18 -0400 Subject: [PATCH 43/68] removed unnecessary semicolon --- src/Resolver/TemplatePathStack.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resolver/TemplatePathStack.php b/src/Resolver/TemplatePathStack.php index 0929fa84..980c84b8 100644 --- a/src/Resolver/TemplatePathStack.php +++ b/src/Resolver/TemplatePathStack.php @@ -299,7 +299,7 @@ public function resolve($name, Renderer $renderer = null) // Ensure we have the expected file extension $defaultSuffix = $this->getDefaultSuffix(); - if (pathinfo($name, PATHINFO_EXTENSION) == '') {; + if (pathinfo($name, PATHINFO_EXTENSION) == '') { $name .= '.' . $defaultSuffix; } From d0c73d0650dfe6ea59d6e61bfe5e31ca1e178dc9 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Tue, 12 Mar 2013 14:56:59 +0100 Subject: [PATCH 44/68] added tests and fixed typos --- src/Helper/HeadMeta.php | 4 +-- test/Helper/HeadMetaTest.php | 57 +++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index f433a17e..66e51b9b 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -3,7 +3,7 @@ * 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) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_View */ @@ -187,7 +187,7 @@ public function setCharset($charset) * Determine if item is valid * * @param mixed $item - * @return boolean + * @return bool */ protected function isValid($item) { diff --git a/test/Helper/HeadMetaTest.php b/test/Helper/HeadMetaTest.php index 18f3357b..cbd6e759 100644 --- a/test/Helper/HeadMetaTest.php +++ b/test/Helper/HeadMetaTest.php @@ -3,7 +3,7 @@ * 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) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_View */ @@ -475,6 +475,61 @@ public function testOverloadingSetPropertyOverwritesMetaTagStack() $this->view->doctype('XHTML1_RDFA'); $this->_testOverloadSet('property'); } + + /** + * @issue 3751 + */ + public function testItempropIsSupportedWithHtml5Doctype() + { + $this->view->doctype('HTML5'); + $this->helper->__invoke('HeadMeta with Microdata', 'description', 'itemprop'); + $this->assertEquals('', + $this->helper->toString() + ); + } + + /** + * @issue 3751 + */ + public function testItempropIsNotSupportedByDefaultDoctype() + { + try { + $this->helper->__invoke('HeadMeta with Microdata', 'description', 'itemprop'); + $this->fail('meta itemprop attribute should not be supported on default doctype'); + } catch (ViewException $e) { + $this->assertContains('Invalid value passed', $e->getMessage()); + } + } + + /** + * @issue 3751 + * @depends testItempropIsSupportedWithHtml5Doctype + */ + public function testOverloadingAppendItempropAppendsMetaTagToStack() + { + $this->view->doctype('HTML5'); + $this->_testOverloadAppend('itemprop'); + } + + /** + * @issue 3751 + * @depends testItempropIsSupportedWithHtml5Doctype + */ + public function testOverloadingPrependItempropPrependsMetaTagToStack() + { + $this->view->doctype('HTML5'); + $this->_testOverloadPrepend('itemprop'); + } + + /** + * @issue 3751 + * @depends testItempropIsSupportedWithHtml5Doctype + */ + public function testOverloadingSetItempropOverwritesMetaTagStack() + { + $this->view->doctype('HTML5'); + $this->_testOverloadSet('itemprop'); + } /** * @group ZF-11835 From 9de86661cc7bafe5693551bf893080f789761641 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 12 Mar 2013 11:19:02 -0500 Subject: [PATCH 45/68] [zendframework/zf2#3973] CS fixes - trailing whitespace --- src/Stream.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Stream.php b/src/Stream.php index 9e5ea6b9..f9f67333 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -47,7 +47,7 @@ class Stream /** * Opens the script file and converts markup. - * + * * @return bool */ public function stream_open($path, $mode, $options, &$opened_path) @@ -94,7 +94,7 @@ public function url_stat() /** * Reads from the stream. - * + * * @return string|false */ public function stream_read($count) @@ -107,7 +107,7 @@ public function stream_read($count) /** * Tells the current position in the stream. - * + * * @return int */ public function stream_tell() @@ -118,7 +118,7 @@ public function stream_tell() /** * Tells if we are at the end of the stream. - * + * * @return bool */ public function stream_eof() @@ -129,7 +129,7 @@ public function stream_eof() /** * Stream statistics. - * + * * @return array */ public function stream_stat() @@ -140,7 +140,7 @@ public function stream_stat() /** * Seek to a specific point in the stream. - * + * * @return bool */ public function stream_seek($offset, $whence) From f9b87996f2fd751a7a449f1dc6fe50e2201826f1 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 12 Mar 2013 12:37:15 -0500 Subject: [PATCH 46/68] [zendframework/zf2#4011] CS fixes - Replace tabs with spaces - Remove unnecessary annotations - Fix other CS/consistency issues as found --- src/Helper/HeadMeta.php | 47 ++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index 66e51b9b..63eed6f6 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -18,8 +17,6 @@ * Zend_Layout_View_Helper_HeadMeta * * @see http://www.w3.org/TR/xhtml1/dtds.html - * @package Zend_View - * @subpackage Helper */ class HeadMeta extends Placeholder\Container\AbstractStandalone { @@ -94,8 +91,8 @@ protected function normalizeType($type) return 'http-equiv'; case 'Property': return 'property'; - case 'Itemprop': - return 'itemprop'; + case 'Itemprop': + return 'itemprop'; default: throw new Exception\DomainException(sprintf( 'Invalid type "%s" passed to normalizeType', @@ -128,7 +125,11 @@ protected function normalizeType($type) */ public function __call($method, $args) { - if (preg_match('/^(?Pset|(pre|ap)pend|offsetSet)(?PName|HttpEquiv|Property|Itemprop)$/', $method, $matches)) { + if (preg_match( + '/^(?Pset|(pre|ap)pend|offsetSet)(?PName|HttpEquiv|Property|Itemprop)$/', + $method, + $matches) + ) { $action = $matches['action']; $type = $this->normalizeType($matches['type']); $argc = count($args); @@ -174,10 +175,10 @@ public function __call($method, $args) */ public function setCharset($charset) { - $item = new stdClass; - $item->type = 'charset'; - $item->charset = $charset; - $item->content = null; + $item = new stdClass; + $item->type = 'charset'; + $item->charset = $charset; + $item->content = null; $item->modifiers = array(); $this->set($item); return $this; @@ -193,27 +194,29 @@ protected function isValid($item) { if ((!$item instanceof stdClass) || !isset($item->type) - || !isset($item->modifiers)) - { + || !isset($item->modifiers) + ) { return false; } if (!isset($item->content) - && (! $this->view->plugin('doctype')->isHtml5() - || (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset'))) { + && (! $this->view->plugin('doctype')->isHtml5() + || (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset')) + ) { + return false; + } + + // is only supported with doctype html + if (! $this->view->plugin('doctype')->isHtml5() + && $item->type === 'itemprop' + ) { return false; } - - // is only supported with doctype html - if (! $this->view->plugin('doctype')->isHtml5() - && $item->type === 'itemprop'){ - - return false; - } // is only supported with doctype RDFa if (!$this->view->plugin('doctype')->isRdfa() - && $item->type === 'property') { + && $item->type === 'property' + ) { return false; } From 04febadf43b1dadd77dadd8721bd370d5f45ae86 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 12 Mar 2013 12:37:46 -0500 Subject: [PATCH 47/68] [zendframework/zf2#4011] CS fixes - indentation, trailing spaces --- src/Helper/HeadMeta.php | 2 +- test/Helper/HeadMetaTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index 63eed6f6..fc6d9a51 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -205,7 +205,7 @@ protected function isValid($item) ) { return false; } - + // is only supported with doctype html if (! $this->view->plugin('doctype')->isHtml5() && $item->type === 'itemprop' diff --git a/test/Helper/HeadMetaTest.php b/test/Helper/HeadMetaTest.php index 7ad7d839..b78eeda5 100644 --- a/test/Helper/HeadMetaTest.php +++ b/test/Helper/HeadMetaTest.php @@ -463,8 +463,8 @@ public function testOverloadingSetPropertyOverwritesMetaTagStack() $this->view->doctype('XHTML1_RDFA'); $this->_testOverloadSet('property'); } - - /** + + /** * @issue 3751 */ public function testItempropIsSupportedWithHtml5Doctype() From f2ffa02b5ba689a51d4015398ac5e9d8d0107f93 Mon Sep 17 00:00:00 2001 From: BinaryKitten Date: Tue, 12 Mar 2013 19:42:39 +0000 Subject: [PATCH 48/68] added extra test to check for separator configuration --- test/Helper/FlashMessengerTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/Helper/FlashMessengerTest.php b/test/Helper/FlashMessengerTest.php index b3233527..5974049f 100644 --- a/test/Helper/FlashMessengerTest.php +++ b/test/Helper/FlashMessengerTest.php @@ -149,6 +149,19 @@ public function testCanDisplayListOfMessagesCustomised() $this->assertEquals($displayInfoAssertion, $displayInfo); } + public function testCanDisplayListOfMessagesCustomisedSeparator() + { + $this->seedMessages(); + + $displayInfoAssertion = '

    foo

    bar

    '; + $displayInfo = $this->helper + ->setMessageOpenFormat('
    ') + ->setMessageSeparatorString('

    ') + ->setMessageCloseString('

    ') + ->render(PluginFlashMessenger::NAMESPACE_DEFAULT, array('foo-baz', 'foo-bar')); + $this->assertEquals($displayInfoAssertion, $displayInfo); + } + public function testCanDisplayListOfMessagesCustomisedByConfig() { $this->seedMessages(); From afd0b1847f393318cd7f5c196b474e512854e791 Mon Sep 17 00:00:00 2001 From: BinaryKitten Date: Tue, 12 Mar 2013 19:45:25 +0000 Subject: [PATCH 49/68] added config test --- test/Helper/FlashMessengerTest.php | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/Helper/FlashMessengerTest.php b/test/Helper/FlashMessengerTest.php index 5974049f..e742e3c8 100644 --- a/test/Helper/FlashMessengerTest.php +++ b/test/Helper/FlashMessengerTest.php @@ -197,6 +197,41 @@ public function testCanDisplayListOfMessagesCustomisedByConfig() $this->assertEquals($displayInfoAssertion, $displayInfo); } + public function testCanDisplayListOfMessagesCustomisedByConfigSeparator() + { + $this->seedMessages(); + + $config = array( + 'view_helper_config' => array( + 'flashmessenger' => array( + 'message_open_format' => '
      ', + 'message_separator_string' => '', + 'message_close_string' => '
    ', + ), + ), + ); + $sm = new ServiceManager(); + $sm->setService('Config', $config); + $helperPluginManager = new HelperPluginManager(new Config(array( + 'factories' => array( + 'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory', + ), + ))); + $controllerPluginManager = new PluginManager(new Config(array( + 'invokables' => array( + 'flashmessenger' => 'Zend\Mvc\Controller\Plugin\FlashMessenger', + ), + ))); + $helperPluginManager->setServiceLocator($sm); + $controllerPluginManager->setServiceLocator($sm); + $sm->setService('ControllerPluginManager', $controllerPluginManager); + $helper = $helperPluginManager->get('flashmessenger'); + + $displayInfoAssertion = '
    • foo
    • bar
    '; + $displayInfo = $helper->render(PluginFlashMessenger::NAMESPACE_DEFAULT, array('foo-baz', 'foo-bar')); + $this->assertEquals($displayInfoAssertion, $displayInfo); + } + public function testCanTranslateMessages() { $mockTranslator = $this->getMock('Zend\I18n\Translator\Translator'); From 0507f8e16e308215e80439032d5f54644fe94de3 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 25 Mar 2013 09:20:50 -0500 Subject: [PATCH 50/68] [zendframework/zf2#3693] CS fixes - Docblock additions/edits - Logic workflow --- src/Helper/Navigation/AbstractHelper.php | 24 ++++++------ .../{AcListener.php => AclListener.php} | 38 +++++++++---------- 2 files changed, 29 insertions(+), 33 deletions(-) rename src/Helper/Navigation/Listener/{AcListener.php => AclListener.php} (67%) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index dceb52f7..a59a382b 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -814,13 +814,11 @@ public function accept(AbstractPage $page, $recursive = true) * Determines whether a page should be allowed given certain parameters * * @param array $params - * * @return boolean */ protected function isAllowed($params) { $results = $this->getEventManager()->trigger(__FUNCTION__, $this, $params); - return $results->last(); } @@ -917,17 +915,19 @@ public static function setDefaultRole($role = null) } } + /** + * Attaches default ACL listeners, if ACLs are in use + */ protected function setDefaultListeners() { - if ($this->getUseAcl()) { - - $this->getEventManager()->getSharedManager()->attach( - 'Zend\View\Helper\Navigation\AbstractHelper', - 'isAllowed', - array('Zend\View\Helper\Navigation\Listener\AcListener', 'accept'), - -1 - ); + if (!$this->getUseAcl()) { + return; } + + $this->getEventManager()->getSharedManager()->attach( + 'Zend\View\Helper\Navigation\AbstractHelper', + 'isAllowed', + array('Zend\View\Helper\Navigation\Listener\AclListener', 'accept') + ); } - -} \ No newline at end of file +} diff --git a/src/Helper/Navigation/Listener/AcListener.php b/src/Helper/Navigation/Listener/AclListener.php similarity index 67% rename from src/Helper/Navigation/Listener/AcListener.php rename to src/Helper/Navigation/Listener/AclListener.php index 37febc55..e2046308 100644 --- a/src/Helper/Navigation/Listener/AcListener.php +++ b/src/Helper/Navigation/Listener/AclListener.php @@ -14,9 +14,8 @@ /** * Default Access Control Listener */ -class AcListener +class AclListener { - /** * Determines whether a page should be accepted by ACL when iterating * @@ -34,26 +33,23 @@ class AcListener public static function accept(Event $event) { $accepted = true; + $params = $event->getParams(); + $acl = $params['acl']; + $page = $params['page']; + $role = $params['role']; - $params= $event->getParams(); - - $acl = $params['acl']; - $page = $params['page']; - $role = $params['role']; - - if ($acl) { - - $resource = $page->getResource(); - $privilege = $page->getPrivilege(); + if (!$acl) { + return $accepted; + } + + $resource = $page->getResource(); + $privilege = $page->getPrivilege(); + + if ($resource || $privilege) { + $accepted = $acl->hasResource($resource) + && $acl->isAllowed($role, $resource, $privilege); + } - if ($resource || $privilege) { - $accepted = $acl->hasResource($resource) && $acl->isAllowed($role, $resource, $privilege); - } else { - $accepted = true; - } - } - return $accepted; } - -} \ No newline at end of file +} From 67dac747c32960f30a140f0fd8cd761a73c84a92 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 25 Mar 2013 09:22:52 -0500 Subject: [PATCH 51/68] [zendframework/zf2#3693] CS fixes - trailing whitespace - EOF endings --- src/Helper/Navigation/AbstractHelper.php | 50 +++++++++---------- src/Helper/Navigation/HelperInterface.php | 2 +- .../Navigation/Listener/AclListener.php | 14 +++--- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index a59a382b..62a6a977 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -33,10 +33,10 @@ abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements TranslatorAwareInterface { /** - * @var EventManagerInterface + * @var EventManagerInterface */ protected $events; - + /** * @var ServiceLocatorInterface */ @@ -159,7 +159,7 @@ public function getServiceLocator() /** * Set the event manager. - * + * * @param EventManagerInterface $events * @return AbstractHelper */ @@ -169,17 +169,17 @@ public function setEventManager(EventManagerInterface $events) __CLASS__, get_called_class(), )); - + $this->events = $events; - + $this->setDefaultListeners(); - + return $this; } /** * Get the event manager. - * + * * @return EventManagerInterface */ public function getEventManager() @@ -187,10 +187,10 @@ public function getEventManager() if (null === $this->events) { $this->setEventManager(new EventManager()); } - + return $this->events; } - + /** * Sets navigation container the helper operates on by default * @@ -765,31 +765,31 @@ public function getTranslatorTextDomain() /** * Determines whether a page should be accepted when iterating - * - * Default listener may be 'overridden' by attaching listener to 'isAllowed' - * method. Listener must be 'short circuited' if overriding default ACL - * listener. + * + * Default listener may be 'overridden' by attaching listener to 'isAllowed' + * method. Listener must be 'short circuited' if overriding default ACL + * listener. * * Rules: * - If a page is not visible it is not accepted, unless RenderInvisible has * been set to true * - If $useAcl is true (default is true): - * - Page is accepted if listener returns true, otherwise false + * - Page is accepted if listener returns true, otherwise false * - If page is accepted and $recursive is true, the page * will not be accepted if it is the descendant of a non-accepted page * * @param AbstractPage $page page to check * @param bool $recursive [optional] if true, page will not be - * accepted if it is the descendant of + * accepted if it is the descendant of * a page that is not accepted. Default * is true - * + * * @return bool Whether page should be accepted */ public function accept(AbstractPage $page, $recursive = true) { $accept = true; - + if (!$page->isVisible(false) && !$this->getRenderInvisible()) { $accept = false; } elseif ($this->getUseAcl()) { @@ -797,11 +797,11 @@ public function accept(AbstractPage $page, $recursive = true) $role = $this->getRole(); $params = array('acl' => $acl, 'page' => $page, 'role' => $role); $accept = $this->isAllowed($params); - } - + } + if ($accept && $recursive) { $parent = $page->getParent(); - + if ($parent instanceof AbstractPage) { $accept = $this->accept($parent, true); } @@ -814,7 +814,7 @@ public function accept(AbstractPage $page, $recursive = true) * Determines whether a page should be allowed given certain parameters * * @param array $params - * @return boolean + * @return boolean */ protected function isAllowed($params) { @@ -914,7 +914,7 @@ public static function setDefaultRole($role = null) )); } } - + /** * Attaches default ACL listeners, if ACLs are in use */ @@ -923,10 +923,10 @@ protected function setDefaultListeners() if (!$this->getUseAcl()) { return; } - + $this->getEventManager()->getSharedManager()->attach( - 'Zend\View\Helper\Navigation\AbstractHelper', - 'isAllowed', + 'Zend\View\Helper\Navigation\AbstractHelper', + 'isAllowed', array('Zend\View\Helper\Navigation\Listener\AclListener', 'accept') ); } diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index c7bf79b9..6c607c88 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -141,4 +141,4 @@ public function __toString(); * @throws \Zend\View\Exception\ExceptionInterface if unable to render */ public function render($container = null); -} \ No newline at end of file +} diff --git a/src/Helper/Navigation/Listener/AclListener.php b/src/Helper/Navigation/Listener/AclListener.php index e2046308..98487d2d 100644 --- a/src/Helper/Navigation/Listener/AclListener.php +++ b/src/Helper/Navigation/Listener/AclListener.php @@ -18,15 +18,15 @@ class AclListener { /** * Determines whether a page should be accepted by ACL when iterating - * + * * - If helper has no ACL, page is accepted - * - If page has a resource or privilege defined, page is accepted if the + * - If page has a resource or privilege defined, page is accepted if the * ACL allows access to it using the helper's role * - If page has no resource or privilege, page is accepted * - If helper has ACL and role: * - Page is accepted if it has no resource or privilege. * - Page is accepted if ACL allows page's resource or privilege. - * + * * @param MvcEvent $event * @return boolean */ @@ -37,7 +37,7 @@ public static function accept(Event $event) $acl = $params['acl']; $page = $params['page']; $role = $params['role']; - + if (!$acl) { return $accepted; } @@ -46,9 +46,9 @@ public static function accept(Event $event) $privilege = $page->getPrivilege(); if ($resource || $privilege) { - $accepted = $acl->hasResource($resource) - && $acl->isAllowed($role, $resource, $privilege); - } + $accepted = $acl->hasResource($resource) + && $acl->isAllowed($role, $resource, $privilege); + } return $accepted; } From 8ad125c7a6cfa09b86da316afa1c31b25497465b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 25 Mar 2013 18:26:41 +0100 Subject: [PATCH 52/68] Reverting the naming from 'callbacks' to 'listeners' for callback handlers in aggregates --- src/Strategy/FeedStrategy.php | 4 ++-- src/Strategy/JsonStrategy.php | 4 ++-- src/Strategy/PhpRendererStrategy.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Strategy/FeedStrategy.php b/src/Strategy/FeedStrategy.php index eb2b0a5b..9072d4c7 100644 --- a/src/Strategy/FeedStrategy.php +++ b/src/Strategy/FeedStrategy.php @@ -39,8 +39,8 @@ public function __construct(FeedRenderer $renderer) */ public function attach(EventManagerInterface $events, $priority = 1) { - $this->callbacks[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); - $this->callbacks[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); + $this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); + $this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); } /** diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index f4f27ff5..49d7860a 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -55,8 +55,8 @@ public function __construct(JsonRenderer $renderer) */ public function attach(EventManagerInterface $events, $priority = 1) { - $this->callbacks[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); - $this->callbacks[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); + $this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); + $this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); } /** diff --git a/src/Strategy/PhpRendererStrategy.php b/src/Strategy/PhpRendererStrategy.php index a7ca724f..9b1c8b7e 100644 --- a/src/Strategy/PhpRendererStrategy.php +++ b/src/Strategy/PhpRendererStrategy.php @@ -75,8 +75,8 @@ public function getContentPlaceholders() */ public function attach(EventManagerInterface $events, $priority = 1) { - $this->callbacks[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); - $this->callbacks[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); + $this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority); + $this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority); } /** From 52b2638cee1bc61707c3f383ac12aed8b7671089 Mon Sep 17 00:00:00 2001 From: Matej Szendi Date: Fri, 29 Mar 2013 00:57:37 +0100 Subject: [PATCH 53/68] Removed additional whitespace in short methods Properties are sorted alphabetically Methods are sorted to logical blocks: magic, renders, helper functions and setters/getters Methods in blocks are sorted alphabetically All helpers now follow this structure set*, get*, has* --- src/Helper/AbstractHelper.php | 3 +- src/Helper/AbstractHtmlElement.php | 2 +- src/Helper/BasePath.php | 3 +- src/Helper/Cycle.php | 57 +- src/Helper/Doctype.php | 35 +- src/Helper/EscapeCss.php | 3 +- src/Helper/EscapeHtml.php | 3 +- src/Helper/EscapeHtmlAttr.php | 3 +- src/Helper/EscapeJs.php | 3 +- src/Helper/EscapeUrl.php | 3 +- src/Helper/Escaper/AbstractHelper.php | 67 +- src/Helper/FlashMessenger.php | 128 ++- src/Helper/Gravatar.php | 245 +++--- src/Helper/HeadMeta.php | 262 +++---- src/Helper/HeadScript.php | 323 ++++---- src/Helper/HeadStyle.php | 224 +++--- src/Helper/HeadTitle.php | 68 +- src/Helper/Identity.php | 1 - src/Helper/Json.php | 1 - src/Helper/Layout.php | 25 +- src/Helper/Navigation.php | 108 ++- src/Helper/Navigation/AbstractHelper.php | 733 +++++++++--------- src/Helper/Navigation/Breadcrumbs.php | 186 +++-- src/Helper/Navigation/HelperInterface.php | 98 +-- src/Helper/Navigation/Links.php | 218 +++--- src/Helper/Navigation/Menu.php | 668 ++++++++-------- src/Helper/Navigation/Sitemap.php | 400 +++++----- src/Helper/PaginationControl.php | 46 +- .../Container/AbstractContainer.php | 340 ++++---- .../Container/AbstractStandalone.php | 251 +++--- src/Helper/Placeholder/Registry.php | 30 +- src/Helper/RenderChildModel.php | 8 +- src/Helper/ServerUrl.php | 296 +++---- src/Helper/Url.php | 2 - src/Helper/ViewModel.php | 40 +- 35 files changed, 2402 insertions(+), 2481 deletions(-) diff --git a/src/Helper/AbstractHelper.php b/src/Helper/AbstractHelper.php index 1775629c..6dce9330 100644 --- a/src/Helper/AbstractHelper.php +++ b/src/Helper/AbstractHelper.php @@ -15,7 +15,7 @@ abstract class AbstractHelper implements HelperInterface { /** - * View object + * View object instance * * @var Renderer */ @@ -30,7 +30,6 @@ abstract class AbstractHelper implements HelperInterface public function setView(Renderer $view) { $this->view = $view; - return $this; } diff --git a/src/Helper/AbstractHtmlElement.php b/src/Helper/AbstractHtmlElement.php index c5631b45..4932fd8a 100644 --- a/src/Helper/AbstractHtmlElement.php +++ b/src/Helper/AbstractHtmlElement.php @@ -64,7 +64,7 @@ protected function isXhtml() protected function htmlAttribs($attribs) { $xhtml = ''; - $escaper = $this->view->plugin('escapehtml'); + $escaper = $this->getView()->plugin('escapehtml'); foreach ((array) $attribs as $key => $val) { $key = $escaper($key); diff --git a/src/Helper/BasePath.php b/src/Helper/BasePath.php index e426fbe3..b2fd3d6c 100644 --- a/src/Helper/BasePath.php +++ b/src/Helper/BasePath.php @@ -17,7 +17,7 @@ class BasePath extends AbstractHelper { /** - * Base path. + * Base path * * @var string */ @@ -54,7 +54,6 @@ public function __invoke($file = null) public function setBasePath($basePath) { $this->basePath = rtrim($basePath, '/'); - return $this; } } diff --git a/src/Helper/Cycle.php b/src/Helper/Cycle.php index 83811a0b..c116b0a8 100644 --- a/src/Helper/Cycle.php +++ b/src/Helper/Cycle.php @@ -20,13 +20,6 @@ class Cycle extends AbstractHelper implements \Iterator */ const DEFAULT_NAME = 'default'; - /** - * Pointers - * - * @var array - */ - protected $pointers = array(self::DEFAULT_NAME =>-1); - /** * Array of values * @@ -41,6 +34,13 @@ class Cycle extends AbstractHelper implements \Iterator */ protected $name = self::DEFAULT_NAME; + /** + * Pointers + * + * @var array + */ + protected $pointers = array(self::DEFAULT_NAME =>-1); + /** * Add elements to alternate * @@ -55,10 +55,29 @@ public function __invoke(array $data = array(), $name = self::DEFAULT_NAME) } $this->setName($name); - return $this; } + /** + * Cast to string + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Turn helper into string + * + * @return string + */ + public function toString() + { + return (string) $this->data[$this->name][$this->key()]; + } + /** * Add elements to alternate * @@ -71,7 +90,6 @@ public function assign(Array $data , $name = self::DEFAULT_NAME) $this->setName($name); $this->data[$name] = $data; $this->rewind(); - return $this; } @@ -175,7 +193,6 @@ public function key() public function rewind() { $this->pointers[$this->name] = -1; - return $this; } @@ -198,24 +215,4 @@ public function current() { return $this->data[$this->name][$this->key()]; } - - /** - * Turn helper into string - * - * @return string - */ - public function toString() - { - return (string) $this->data[$this->name][$this->key()]; - } - - /** - * Cast to string - * - * @return string - */ - public function __toString() - { - return $this->toString(); - } } diff --git a/src/Helper/Doctype.php b/src/Helper/Doctype.php index 0d94b242..cb052ea8 100644 --- a/src/Helper/Doctype.php +++ b/src/Helper/Doctype.php @@ -36,11 +36,6 @@ class Doctype extends AbstractHelper const CUSTOM = 'CUSTOM'; /**#@-*/ - /** - * @var ArrayObject Shared doctypes to use throughout all instances - */ - protected static $registeredDoctypes; - /** * Default DocType * @@ -55,6 +50,11 @@ class Doctype extends AbstractHelper */ protected $registry; + /** + * @var ArrayObject Shared doctypes to use throughout all instances + */ + protected static $registeredDoctypes; + /** * Constructor * @@ -112,6 +112,18 @@ public function __invoke($doctype = null) return $this; } + /** + * String representation of doctype + * + * @return string + */ + public function __toString() + { + $doctypes = $this->getDoctypes(); + + return $doctypes[$this->getDoctype()]; + } + /** * Register the default doctypes we understand * @@ -159,7 +171,6 @@ public static function unsetDoctypeRegistry() public function setDoctype($doctype) { $this->registry['doctype'] = $doctype; - return $this; } @@ -216,16 +227,4 @@ public function isRdfa() { return ($this->isHtml5() || stristr($this->getDoctype(), 'rdfa') ? true : false); } - - /** - * String representation of doctype - * - * @return string - */ - public function __toString() - { - $doctypes = $this->getDoctypes(); - - return $doctypes[$this->getDoctype()]; - } } diff --git a/src/Helper/EscapeCss.php b/src/Helper/EscapeCss.php index adc4c4ca..c3396a4c 100644 --- a/src/Helper/EscapeCss.php +++ b/src/Helper/EscapeCss.php @@ -16,11 +16,10 @@ */ class EscapeCss extends Escaper\AbstractHelper { - /** * Escape a value for current escaping strategy * - * @param string $value + * @param string $value * @return string */ protected function escape($value) diff --git a/src/Helper/EscapeHtml.php b/src/Helper/EscapeHtml.php index c27a3289..3e16cf21 100644 --- a/src/Helper/EscapeHtml.php +++ b/src/Helper/EscapeHtml.php @@ -16,11 +16,10 @@ */ class EscapeHtml extends Escaper\AbstractHelper { - /** * Escape a value for current escaping strategy * - * @param string $value + * @param string $value * @return string */ protected function escape($value) diff --git a/src/Helper/EscapeHtmlAttr.php b/src/Helper/EscapeHtmlAttr.php index cf242a67..d94883f3 100644 --- a/src/Helper/EscapeHtmlAttr.php +++ b/src/Helper/EscapeHtmlAttr.php @@ -16,11 +16,10 @@ */ class EscapeHtmlAttr extends Escaper\AbstractHelper { - /** * Escape a value for current escaping strategy * - * @param string $value + * @param string $value * @return string */ protected function escape($value) diff --git a/src/Helper/EscapeJs.php b/src/Helper/EscapeJs.php index 2b47793d..590e457b 100644 --- a/src/Helper/EscapeJs.php +++ b/src/Helper/EscapeJs.php @@ -16,11 +16,10 @@ */ class EscapeJs extends Escaper\AbstractHelper { - /** * Escape a value for current escaping strategy * - * @param string $value + * @param string $value * @return string */ protected function escape($value) diff --git a/src/Helper/EscapeUrl.php b/src/Helper/EscapeUrl.php index e21bb95c..90e845e7 100644 --- a/src/Helper/EscapeUrl.php +++ b/src/Helper/EscapeUrl.php @@ -16,11 +16,10 @@ */ class EscapeUrl extends Escaper\AbstractHelper { - /** * Escape a value for current escaping strategy * - * @param string $value + * @param string $value * @return string */ protected function escape($value) diff --git a/src/Helper/Escaper/AbstractHelper.php b/src/Helper/Escaper/AbstractHelper.php index 8f093c44..2fbdfa51 100644 --- a/src/Helper/Escaper/AbstractHelper.php +++ b/src/Helper/Escaper/AbstractHelper.php @@ -26,14 +26,14 @@ abstract class AbstractHelper extends Helper\AbstractHelper const RECURSE_OBJECT = 0x02; /** - * @var Escaper\Escaper + * @var string Encoding */ - protected $escaper = null; + protected $encoding = 'UTF-8'; /** - * @var string Encoding + * @var Escaper\Escaper */ - protected $encoding = 'UTF-8'; + protected $escaper = null; /** * Invoke this helper: escape a value @@ -77,37 +77,16 @@ public function __invoke($value, $recurse = self::RECURSE_NONE) return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); } - // At this point, we have a scalar; simply return it return $value; } /** - * Set instance of Escaper - * - * @param Escaper\Escaper $escaper - * @return AbstractHelper - */ - public function setEscaper(Escaper\Escaper $escaper) - { - $this->escaper = $escaper; - $this->encoding = $escaper->getEncoding(); - - return $this; - } - - /** - * Get instance of Escaper + * Escape a value for current escaping strategy * - * @return null|Escaper\Escaper + * @param string $value + * @return string */ - public function getEscaper() - { - if (null === $this->escaper) { - $this->setEscaper(new Escaper\Escaper($this->getEncoding())); - } - - return $this->escaper; - } + abstract protected function escape($value); /** * Set the encoding to use for escape operations @@ -121,7 +100,7 @@ public function setEncoding($encoding) if (null !== $this->escaper) { throw new Exception\InvalidArgumentException( 'Character encoding settings cannot be changed once the Helper has been used or ' - . ' if a Zend\Escaper\Escaper object (with preset encoding option) is set.' + . ' if a Zend\Escaper\Escaper object (with preset encoding option) is set.' ); } @@ -141,10 +120,30 @@ public function getEncoding() } /** - * Escape a value for current escaping strategy + * Set instance of Escaper * - * @param string $value - * @return string + * @param Escaper\Escaper $escaper + * @return AbstractHelper */ - abstract protected function escape($value); + public function setEscaper(Escaper\Escaper $escaper) + { + $this->escaper = $escaper; + $this->encoding = $escaper->getEncoding(); + + return $this; + } + + /** + * Get instance of Escaper + * + * @return null|Escaper\Escaper + */ + public function getEscaper() + { + if (null === $this->escaper) { + $this->setEscaper(new Escaper\Escaper($this->getEncoding())); + } + + return $this->escaper; + } } diff --git a/src/Helper/FlashMessenger.php b/src/Helper/FlashMessenger.php index 527b58ad..4b27314a 100644 --- a/src/Helper/FlashMessenger.php +++ b/src/Helper/FlashMessenger.php @@ -9,7 +9,7 @@ namespace Zend\View\Helper; -use Zend\Mvc\Controller\Plugin\FlashMessenger as PluginFlashMessenger; +use Zend\Mvc\Controller\Plugin\FlashMessenger as FlashMessengerPlugin; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View\Helper\AbstractHelper; @@ -27,10 +27,10 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA * @var array */ protected $classMessages = array( - PluginFlashMessenger::NAMESPACE_INFO => 'info', - PluginFlashMessenger::NAMESPACE_ERROR => 'error', - PluginFlashMessenger::NAMESPACE_SUCCESS => 'success', - PluginFlashMessenger::NAMESPACE_DEFAULT => 'default', + FlashMessengerPlugin::NAMESPACE_INFO => 'info', + FlashMessengerPlugin::NAMESPACE_ERROR => 'error', + FlashMessengerPlugin::NAMESPACE_SUCCESS => 'success', + FlashMessengerPlugin::NAMESPACE_DEFAULT => 'default', ); /** @@ -52,9 +52,9 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA /** * Flash messenger plugin * - * @var PluginFlashMessenger + * @var FlashMessengerPlugin */ - protected $pluginFlashMessenger; + protected $flashMessengerPlugin; /** * Service locator @@ -67,14 +67,14 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA * Returns the flash messenger plugin controller * * @param string|null $namespace - * @return FlashMessenger|PluginFlashMessenger + * @return FlashMessenger|FlashMessengerPlugin */ public function __invoke($namespace = null) { if (null === $namespace) { return $this; } - $flashMessenger = $this->getPluginFlashMessenger(); + $flashMessenger = $this->getFlashMessengerPlugin(); return $flashMessenger->getMessagesFromNamespace($namespace); } @@ -88,8 +88,7 @@ public function __invoke($namespace = null) */ public function __call($method, $argv) { - $flashMessenger = $this->getPluginFlashMessenger(); - + $flashMessenger = $this->getFlashMessengerPlugin(); return call_user_func_array(array($flashMessenger, $method), $argv); } @@ -100,15 +99,15 @@ public function __call($method, $argv) * @param array $classes * @return string */ - public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array()) + public function render($namespace = FlashMessengerPlugin::NAMESPACE_DEFAULT, array $classes = array()) { - $flashMessenger = $this->getPluginFlashMessenger(); + $flashMessenger = $this->getFlashMessengerPlugin(); $messages = $flashMessenger->getMessagesFromNamespace($namespace); // Prepare classes for opening tag if (empty($classes)) { $classes = isset($this->classMessages[$namespace]) ? - $this->classMessages[$namespace] : $this->classMessages[PluginFlashMessenger::NAMESPACE_DEFAULT]; + $this->classMessages[$namespace] : $this->classMessages[FlashMessengerPlugin::NAMESPACE_DEFAULT]; $classes = array($classes); } @@ -140,6 +139,32 @@ public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, arr return $markup; } + /** + * Set the flash messenger plugin + * + * @param FlashMessengerPlugin $flashMessengerPlugin + * @return FlashMessenger + */ + public function setFlashMessengerPlugin(FlashMessengerPlugin $flashMessengerPlugin) + { + $this->flashMessengerPlugin = $flashMessengerPlugin; + return $this; + } + + /** + * Get the flash messenger plugin + * + * @return FlashMessengerPlugin + */ + public function getFlashMessengerPlugin() + { + if (null === $this->flashMessengerPlugin) { + $this->setFlashMessengerPlugin(new FlashMessengerPlugin()); + } + + return $this->flashMessengerPlugin; + } + /** * Set the string used to close message representation * @@ -149,7 +174,6 @@ public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, arr public function setMessageCloseString($messageCloseString) { $this->messageCloseString = (string) $messageCloseString; - return $this; } @@ -172,7 +196,6 @@ public function getMessageCloseString() public function setMessageOpenFormat($messageOpenFormat) { $this->messageOpenFormat = (string) $messageOpenFormat; - return $this; } @@ -195,7 +218,6 @@ public function getMessageOpenFormat() public function setMessageSeparatorString($messageSeparatorString) { $this->messageSeparatorString = (string) $messageSeparatorString; - return $this; } @@ -209,55 +231,6 @@ public function getMessageSeparatorString() return $this->messageSeparatorString; } - /** - * Retrieve the escapeHtml helper - * - * @return EscapeHtml - */ - protected function getEscapeHtmlHelper() - { - if ($this->escapeHtmlHelper) { - return $this->escapeHtmlHelper; - } - - if (method_exists($this->view, 'plugin')) { - $this->escapeHtmlHelper = $this->view->plugin('escapehtml'); - } - - if (!$this->escapeHtmlHelper instanceof EscapeHtml) { - $this->escapeHtmlHelper = new EscapeHtml(); - } - - return $this->escapeHtmlHelper; - } - - /** - * Get the flash messenger plugin - * - * @return PluginFlashMessenger - */ - public function getPluginFlashMessenger() - { - if (null === $this->pluginFlashMessenger) { - $this->setPluginFlashMessenger(new PluginFlashMessenger()); - } - - return $this->pluginFlashMessenger; - } - - /** - * Set the flash messenger plugin - * - * @param PluginFlashMessenger $pluginFlashMessenger - * @return FlashMessenger - */ - public function setPluginFlashMessenger(PluginFlashMessenger $pluginFlashMessenger) - { - $this->pluginFlashMessenger = $pluginFlashMessenger; - - return $this; - } - /** * Set the service locator. * @@ -267,7 +240,6 @@ public function setPluginFlashMessenger(PluginFlashMessenger $pluginFlashMesseng public function setServiceLocator(ServiceLocatorInterface $serviceLocator) { $this->serviceLocator = $serviceLocator; - return $this; } @@ -280,4 +252,26 @@ public function getServiceLocator() { return $this->serviceLocator; } + + /** + * Retrieve the escapeHtml helper + * + * @return EscapeHtml + */ + protected function getEscapeHtmlHelper() + { + if ($this->escapeHtmlHelper) { + return $this->escapeHtmlHelper; + } + + if (method_exists($this->getView(), 'plugin')) { + $this->escapeHtmlHelper = $this->view->plugin('escapehtml'); + } + + if (!$this->escapeHtmlHelper instanceof EscapeHtml) { + $this->escapeHtmlHelper = new EscapeHtml(); + } + + return $this->escapeHtmlHelper; + } } diff --git a/src/Helper/Gravatar.php b/src/Helper/Gravatar.php index db2bb2da..a37330ed 100644 --- a/src/Helper/Gravatar.php +++ b/src/Helper/Gravatar.php @@ -43,16 +43,11 @@ class Gravatar extends AbstractHtmlElement const DEFAULT_WAVATAR = 'wavatar'; /** - * Options + * Attributes for HTML image tag * * @var array */ - protected $options = array( - 'img_size' => 80, - 'default_img' => self::DEFAULT_MM, - 'rating' => self::RATING_G, - 'secure' => null, - ); + protected $attribs; /** * Email Address @@ -62,11 +57,16 @@ class Gravatar extends AbstractHtmlElement protected $email; /** - * Attributes for HTML image tag + * Options * * @var array */ - protected $attribs; + protected $options = array( + 'img_size' => 80, + 'default_img' => self::DEFAULT_MM, + 'rating' => self::RATING_G, + 'secure' => null, + ); /** * Returns an avatar from gravatar's service. @@ -99,6 +99,16 @@ public function __invoke($email = "", $options = array(), $attribs = array()) return $this; } + /** + * Return valid image tag + * + * @return string + */ + public function __toString() + { + return $this->getImgTag(); + } + /** * Configure state * @@ -118,91 +128,99 @@ public function setOptions(array $options) } /** - * Get img size + * Get avatar url (including size, rating and default image options) * - * @return int The img size + * @return string */ - public function getImgSize() + protected function getAvatarUrl() { - return $this->options['img_size']; + $src = $this->getGravatarUrl() + . '/' . md5($this->getEmail()) + . '?s=' . $this->getImgSize() + . '&d=' . $this->getDefaultImg() + . '&r=' . $this->getRating(); + return $src; } /** - * Set img size in pixels + * Get URL to gravatar's service. * - * @param int $imgSize Size of img must be between 1 and 512 - * @return Gravatar + * @return string URL */ - public function setImgSize($imgSize) + protected function getGravatarUrl() { - $this->options['img_size'] = (int) $imgSize; - - return $this; + return ($this->getSecure() === false) ? self::GRAVATAR_URL : self::GRAVATAR_URL_SECURE; } /** - * Get default img + * Return valid image tag * * @return string */ - public function getDefaultImg() + public function getImgTag() { - return $this->options['default_img']; + $this->setSrcAttribForImg(); + $html = 'htmlAttribs($this->getAttribs()) + . $this->getClosingBracket(); + + return $html; } /** - * Set default img + * Set attribs for image tag * - * Can be either an absolute URL to an image, or one of the DEFAULT_* constants + * Warning! You shouldn't set src attrib for image tag. + * This attrib is overwritten in protected method setSrcAttribForImg(). + * This method(_setSrcAttribForImg) is called in public method getImgTag(). * - * @link http://pl.gravatar.com/site/implement/url More information about default image. - * @param string $defaultImg + * @param array $attribs * @return Gravatar */ - public function setDefaultImg($defaultImg) + public function setAttribs(array $attribs) { - $this->options['default_img'] = urlencode($defaultImg); - + $this->attribs = $attribs; return $this; } /** - * Set rating value + * Get attribs of image * - * Must be one of the RATING_* constants + * Warning! + * If you set src attrib, you get it, but this value will be overwritten in + * protected method setSrcAttribForImg(). And finally your get other src + * value! * - * @link http://pl.gravatar.com/site/implement/url More information about rating. - * @param string $rating Value for rating. Allowed values are: g, px, r,x - * @return Gravatar - * @throws Exception\DomainException + * @return array */ - public function setRating($rating) + public function getAttribs() { - switch ($rating) { - case self::RATING_G: - case self::RATING_PG: - case self::RATING_R: - case self::RATING_X: - $this->options['rating'] = $rating; - break; - default: - throw new Exception\DomainException(sprintf( - 'The rating value "%s" is not allowed', - $rating - )); - } + return $this->attribs; + } + /** + * Set default img + * + * Can be either an absolute URL to an image, or one of the DEFAULT_* constants + * + * @link http://pl.gravatar.com/site/implement/url More information about default image. + * @param string $defaultImg + * @return Gravatar + */ + public function setDefaultImg($defaultImg) + { + $this->options['default_img'] = urlencode($defaultImg); return $this; } /** - * Get rating value + * Get default img * * @return string */ - public function getRating() + public function getDefaultImg() { - return $this->options['rating']; + return $this->options['default_img']; } /** @@ -211,10 +229,9 @@ public function getRating() * @param string $email * @return Gravatar */ - public function setEmail( $email ) + public function setEmail($email) { $this->email = $email; - return $this; } @@ -229,87 +246,90 @@ public function getEmail() } /** - * Load from an SSL or No-SSL location? + * Set img size in pixels * - * @param bool $flag + * @param int $imgSize Size of img must be between 1 and 512 * @return Gravatar */ - public function setSecure($flag) + public function setImgSize($imgSize) { - $this->options['secure'] = ($flag === null) ? null : (bool) $flag; - + $this->options['img_size'] = (int) $imgSize; return $this; } /** - * Get an SSL or a No-SSL location + * Get img size * - * @return bool + * @return int The img size */ - public function getSecure() + public function getImgSize() { - if ($this->options['secure'] === null) { - return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); - } - - return $this->options['secure']; + return $this->options['img_size']; } /** - * Get attribs of image + * Set rating value * - * Warning! - * If you set src attrib, you get it, but this value will be overwritten in - * protected method setSrcAttribForImg(). And finally your get other src - * value! + * Must be one of the RATING_* constants * - * @return array + * @link http://pl.gravatar.com/site/implement/url More information about rating. + * @param string $rating Value for rating. Allowed values are: g, px, r,x + * @return Gravatar + * @throws Exception\DomainException */ - public function getAttribs() + public function setRating($rating) { - return $this->attribs; + switch ($rating) { + case self::RATING_G: + case self::RATING_PG: + case self::RATING_R: + case self::RATING_X: + $this->options['rating'] = $rating; + break; + default: + throw new Exception\DomainException(sprintf( + 'The rating value "%s" is not allowed', + $rating + )); + } + + return $this; } /** - * Set attribs for image tag - * - * Warning! You shouldn't set src attrib for image tag. - * This attrib is overwritten in protected method setSrcAttribForImg(). - * This method(_setSrcAttribForImg) is called in public method getImgTag(). + * Get rating value * - * @param array $attribs - * @return Gravatar + * @return string */ - public function setAttribs(array $attribs) + public function getRating() { - $this->attribs = $attribs; - - return $this; + return $this->options['rating']; } /** - * Get URL to gravatar's service. + * Load from an SSL or No-SSL location? * - * @return string URL + * @param bool $flag + * @return Gravatar */ - protected function getGravatarUrl() + public function setSecure($flag) { - return ($this->getSecure() === false) ? self::GRAVATAR_URL : self::GRAVATAR_URL_SECURE; + $this->options['secure'] = ($flag === null) ? null : (bool) $flag; + return $this; } /** - * Get avatar url (including size, rating and default image options) + * Get an SSL or a No-SSL location * - * @return string + * @return bool */ - protected function getAvatarUrl() + public function getSecure() { - $src = $this->getGravatarUrl() - . '/' . md5($this->getEmail()) - . '?s=' . $this->getImgSize() - . '&d=' . $this->getDefaultImg() - . '&r=' . $this->getRating(); - return $src; + if ($this->options['secure'] === null) { + return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); + } + + return $this->options['secure']; } /** @@ -328,29 +348,4 @@ protected function setSrcAttribForImg() $attribs['src'] = $this->getAvatarUrl(); $this->setAttribs($attribs); } - - /** - * Return valid image tag - * - * @return string - */ - public function getImgTag() - { - $this->setSrcAttribForImg(); - $html = 'htmlAttribs($this->getAttribs()) - . $this->getClosingBracket(); - - return $html; - } - - /** - * Return valid image tag - * - * @return string - */ - public function __toString() - { - return $this->getImgTag(); - } } diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index 39024c8a..c41e1d05 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -152,6 +152,125 @@ public function __call($method, $args) return parent::__call($method, $args); } + /** + * Render placeholder as string + * + * @param string|int $indent + * @return string + */ + public function toString($indent = null) + { + $indent = (null !== $indent) + ? $this->getWhitespace($indent) + : $this->getIndent(); + + $items = array(); + $this->getContainer()->ksort(); + + try { + foreach ($this as $item) { + $items[] = $this->itemToString($item); + } + } catch (Exception\InvalidArgumentException $e) { + trigger_error($e->getMessage(), E_USER_WARNING); + return ''; + } + + return $indent . implode($this->escape($this->getSeparator()) . $indent, $items); + } + + /** + * Create data item for inserting into stack + * + * @param string $type + * @param string $typeValue + * @param string $content + * @param array $modifiers + * @return stdClass + */ + public function createData($type, $typeValue, $content, array $modifiers) + { + $data = new stdClass; + $data->type = $type; + $data->$type = $typeValue; + $data->content = $content; + $data->modifiers = $modifiers; + + return $data; + } + + /** + * Build meta HTML string + * + * @param stdClass $item + * @throws Exception\InvalidArgumentException + * @return string + */ + public function itemToString(stdClass $item) + { + if (!in_array($item->type, $this->typeKeys)) { + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid type "%s" provided for meta', + $item->type + )); + } + $type = $item->type; + + $modifiersString = ''; + foreach ($item->modifiers as $key => $value) { + if ($this->view->plugin('doctype')->isHtml5() + && $key == 'scheme' + ) { + throw new Exception\InvalidArgumentException( + 'Invalid modifier "scheme" provided; not supported by HTML5' + ); + } + if (!in_array($key, $this->modifierKeys)) { + continue; + } + $modifiersString .= $key . '="' . $this->escape($value) . '" '; + } + + $modifiersString = rtrim($modifiersString); + + if ('' != $modifiersString) { + $modifiersString = ' ' . $modifiersString; + } + + if (method_exists($this->view, 'plugin')) { + if ($this->view->plugin('doctype')->isHtml5() + && $type == 'charset' + ) { + $tpl = ($this->view->plugin('doctype')->isXhtml()) + ? '' + : ''; + } elseif ($this->view->plugin('doctype')->isXhtml()) { + $tpl = ''; + } else { + $tpl = ''; + } + } else { + $tpl = ''; + } + + $meta = sprintf( + $tpl, + $type, + $this->escape($item->$type), + $this->escape($item->content), + $modifiersString + ); + + if (isset($item->modifiers['conditional']) + && !empty($item->modifiers['conditional']) + && is_string($item->modifiers['conditional'])) + { + $meta = ''; + } + + return $meta; + } + /** * Normalize type attribute of meta * @@ -176,26 +295,6 @@ protected function normalizeType($type) } } - /** - * Create an HTML5-style meta charset tag. Something like - * - * Not valid in a non-HTML5 doctype - * - * @param string $charset - * @return HeadMeta Provides a fluent interface - */ - public function setCharset($charset) - { - $item = new stdClass; - $item->type = 'charset'; - $item->charset = $charset; - $item->content = null; - $item->modifiers = array(); - $this->set($item); - - return $this; - } - /** * Determine if item is valid * @@ -321,121 +420,22 @@ public function set($value) } /** - * Build meta HTML string - * - * @param stdClass $item - * @throws Exception\InvalidArgumentException - * @return string - */ - public function itemToString(stdClass $item) - { - if (!in_array($item->type, $this->typeKeys)) { - throw new Exception\InvalidArgumentException(sprintf( - 'Invalid type "%s" provided for meta', - $item->type - )); - } - $type = $item->type; - - $modifiersString = ''; - foreach ($item->modifiers as $key => $value) { - if ($this->view->plugin('doctype')->isHtml5() - && $key == 'scheme' - ) { - throw new Exception\InvalidArgumentException( - 'Invalid modifier "scheme" provided; not supported by HTML5' - ); - } - if (!in_array($key, $this->modifierKeys)) { - continue; - } - $modifiersString .= $key . '="' . $this->escape($value) . '" '; - } - - $modifiersString = rtrim($modifiersString); - - if ('' != $modifiersString) { - $modifiersString = ' ' . $modifiersString; - } - - if (method_exists($this->view, 'plugin')) { - if ($this->view->plugin('doctype')->isHtml5() - && $type == 'charset' - ) { - $tpl = ($this->view->plugin('doctype')->isXhtml()) - ? '' - : ''; - } elseif ($this->view->plugin('doctype')->isXhtml()) { - $tpl = ''; - } else { - $tpl = ''; - } - } else { - $tpl = ''; - } - - $meta = sprintf( - $tpl, - $type, - $this->escape($item->$type), - $this->escape($item->content), - $modifiersString - ); - - if (isset($item->modifiers['conditional']) - && !empty($item->modifiers['conditional']) - && is_string($item->modifiers['conditional'])) - { - $meta = ''; - } - - return $meta; - } - - /** - * Render placeholder as string + * Create an HTML5-style meta charset tag. Something like * - * @param string|int $indent - * @return string - */ - public function toString($indent = null) - { - $indent = (null !== $indent) - ? $this->getWhitespace($indent) - : $this->getIndent(); - - $items = array(); - $this->getContainer()->ksort(); - - try { - foreach ($this as $item) { - $items[] = $this->itemToString($item); - } - } catch (Exception\InvalidArgumentException $e) { - trigger_error($e->getMessage(), E_USER_WARNING); - return ''; - } - - return $indent . implode($this->escape($this->getSeparator()) . $indent, $items); - } - - /** - * Create data item for inserting into stack + * Not valid in a non-HTML5 doctype * - * @param string $type - * @param string $typeValue - * @param string $content - * @param array $modifiers - * @return stdClass + * @param string $charset + * @return HeadMeta Provides a fluent interface */ - public function createData($type, $typeValue, $content, array $modifiers) + public function setCharset($charset) { - $data = new stdClass; - $data->type = $type; - $data->$type = $typeValue; - $data->content = $content; - $data->modifiers = $modifiers; + $item = new stdClass; + $item->type = 'charset'; + $item->charset = $charset; + $item->content = null; + $item->modifiers = array(); + $this->set($item); - return $data; + return $this; } } diff --git a/src/Helper/HeadScript.php b/src/Helper/HeadScript.php index e7009e03..30609be1 100644 --- a/src/Helper/HeadScript.php +++ b/src/Helper/HeadScript.php @@ -136,56 +136,6 @@ public function __invoke($mode = HeadScript::FILE, $spec = null, $placement = 'A return $this; } - /** - * Start capture action - * - * @param mixed $captureType Type of capture - * @param string $type Type of script - * @param array $attrs Attributes of capture - * @throws Exception\RuntimeException - * @return void - */ - public function captureStart($captureType = Placeholder\Container\AbstractContainer::APPEND, $type = 'text/javascript', $attrs = array()) - { - if ($this->captureLock) { - throw new Exception\RuntimeException('Cannot nest headScript captures'); - } - - $this->captureLock = true; - $this->captureType = $captureType; - $this->captureScriptType = $type; - $this->captureScriptAttrs = $attrs; - ob_start(); - } - - /** - * End capture action and store - * - * @return void - */ - public function captureEnd() - { - $content = ob_get_clean(); - $type = $this->captureScriptType; - $attrs = $this->captureScriptAttrs; - $this->captureScriptType = null; - $this->captureScriptAttrs = null; - $this->captureLock = false; - - switch ($this->captureType) { - case Placeholder\Container\AbstractContainer::SET: - case Placeholder\Container\AbstractContainer::PREPEND: - case Placeholder\Container\AbstractContainer::APPEND: - $action = strtolower($this->captureType) . 'Script'; - break; - default: - $action = 'appendScript'; - break; - } - - $this->$action($content, $type, $attrs); - } - /** * Overload method access * @@ -267,6 +217,108 @@ public function __call($method, $args) return parent::__call($method, $args); } + /** + * Retrieve string representation + * + * @param string|int $indent Amount of whitespaces or string to use for indention + * @return string + */ + public function toString($indent = null) + { + $indent = (null !== $indent) + ? $this->getWhitespace($indent) + : $this->getIndent(); + + if ($this->view) { + $useCdata = $this->view->plugin('doctype')->isXhtml() ? true : false; + } else { + $useCdata = $this->useCdata ? true : false; + } + + $escapeStart = ($useCdata) ? '//' : '//-->'; + + $items = array(); + $this->getContainer()->ksort(); + foreach ($this as $item) { + if (!$this->isValid($item)) { + continue; + } + + $items[] = $this->itemToString($item, $indent, $escapeStart, $escapeEnd); + } + + return implode($this->getSeparator(), $items); + } + + /** + * Start capture action + * + * @param mixed $captureType Type of capture + * @param string $type Type of script + * @param array $attrs Attributes of capture + * @throws Exception\RuntimeException + * @return void + */ + public function captureStart($captureType = Placeholder\Container\AbstractContainer::APPEND, $type = 'text/javascript', $attrs = array()) + { + if ($this->captureLock) { + throw new Exception\RuntimeException('Cannot nest headScript captures'); + } + + $this->captureLock = true; + $this->captureType = $captureType; + $this->captureScriptType = $type; + $this->captureScriptAttrs = $attrs; + ob_start(); + } + + /** + * End capture action and store + * + * @return void + */ + public function captureEnd() + { + $content = ob_get_clean(); + $type = $this->captureScriptType; + $attrs = $this->captureScriptAttrs; + $this->captureScriptType = null; + $this->captureScriptAttrs = null; + $this->captureLock = false; + + switch ($this->captureType) { + case Placeholder\Container\AbstractContainer::SET: + case Placeholder\Container\AbstractContainer::PREPEND: + case Placeholder\Container\AbstractContainer::APPEND: + $action = strtolower($this->captureType) . 'Script'; + break; + default: + $action = 'appendScript'; + break; + } + + $this->$action($content, $type, $attrs); + } + + /** + * Create data item containing all necessary components of script + * + * @param string $type Type of data + * @param array $attributes Attributes of data + * @param string $content Content of data + * @return stdClass + */ + public function createData($type, array $attributes, $content = null) + { + $data = new stdClass(); + $data->type = $type; + $data->attributes = $attributes; + $data->source = $content; + + return $data; + } + /** * Is the file specified a duplicate? * @@ -305,6 +357,65 @@ protected function isValid($value) return true; } + /** + * Create script HTML + * + * @param mixed $item Item to convert + * @param string $indent String to add before the item + * @param string $escapeStart Starting sequence + * @param string $escapeEnd Ending sequence + * @return string + */ + public function itemToString($item, $indent, $escapeStart, $escapeEnd) + { + $attrString = ''; + if (!empty($item->attributes)) { + foreach ($item->attributes as $key => $value) { + if ((!$this->arbitraryAttributesAllowed() && !in_array($key, $this->optionalAttributes)) + || in_array($key, array('conditional', 'noescape'))) + { + continue; + } + if ('defer' == $key) { + $value = 'defer'; + } + $attrString .= sprintf(' %s="%s"', $key, ($this->autoEscape) ? $this->escape($value) : $value); + } + } + + $addScriptEscape = !(isset($item->attributes['noescape']) && filter_var($item->attributes['noescape'], FILTER_VALIDATE_BOOLEAN)); + + $type = ($this->autoEscape) ? $this->escape($item->type) : $item->type; + $html = ''; + + if (isset($item->attributes['conditional']) + && !empty($item->attributes['conditional']) + && is_string($item->attributes['conditional'])) + { + $html = $indent . ''; + } else { + $html = $indent . $html; + } + + return $html; + } + /** * Override append * @@ -387,7 +498,6 @@ public function offsetSet($index, $value) public function setAllowArbitraryAttributes($flag) { $this->arbitraryAttributes = (bool) $flag; - return $this; } @@ -400,115 +510,4 @@ public function arbitraryAttributesAllowed() { return $this->arbitraryAttributes; } - - /** - * Create script HTML - * - * @param mixed $item Item to convert - * @param string $indent String to add before the item - * @param string $escapeStart Starting sequence - * @param string $escapeEnd Ending sequence - * @return string - */ - public function itemToString($item, $indent, $escapeStart, $escapeEnd) - { - $attrString = ''; - if (!empty($item->attributes)) { - foreach ($item->attributes as $key => $value) { - if ((!$this->arbitraryAttributesAllowed() && !in_array($key, $this->optionalAttributes)) - || in_array($key, array('conditional', 'noescape'))) - { - continue; - } - if ('defer' == $key) { - $value = 'defer'; - } - $attrString .= sprintf(' %s="%s"', $key, ($this->autoEscape) ? $this->escape($value) : $value); - } - } - - $addScriptEscape = !(isset($item->attributes['noescape']) && filter_var($item->attributes['noescape'], FILTER_VALIDATE_BOOLEAN)); - - $type = ($this->autoEscape) ? $this->escape($item->type) : $item->type; - $html = ''; - - if (isset($item->attributes['conditional']) - && !empty($item->attributes['conditional']) - && is_string($item->attributes['conditional'])) - { - $html = $indent . ''; - } else { - $html = $indent . $html; - } - - return $html; - } - - /** - * Retrieve string representation - * - * @param string|int $indent Amount of whitespaces or string to use for indention - * @return string - */ - public function toString($indent = null) - { - $indent = (null !== $indent) - ? $this->getWhitespace($indent) - : $this->getIndent(); - - if ($this->view) { - $useCdata = $this->view->plugin('doctype')->isXhtml() ? true : false; - } else { - $useCdata = $this->useCdata ? true : false; - } - - $escapeStart = ($useCdata) ? '//' : '//-->'; - - $items = array(); - $this->getContainer()->ksort(); - foreach ($this as $item) { - if (!$this->isValid($item)) { - continue; - } - - $items[] = $this->itemToString($item, $indent, $escapeStart, $escapeEnd); - } - - return implode($this->getSeparator(), $items); - } - - /** - * Create data item containing all necessary components of script - * - * @param string $type Type of data - * @param array $attributes Attributes of data - * @param string $content Content of data - * @return stdClass - */ - public function createData($type, array $attributes, $content = null) - { - $data = new stdClass(); - $data->type = $type; - $data->attributes = $attributes; - $data->source = $content; - - return $data; - } } diff --git a/src/Helper/HeadStyle.php b/src/Helper/HeadStyle.php index 1064bfb5..66e2103e 100644 --- a/src/Helper/HeadStyle.php +++ b/src/Helper/HeadStyle.php @@ -162,92 +162,30 @@ public function __call($method, $args) } /** - * Determine if a value is a valid style tag - * - * @param mixed $value - * @return bool - */ - protected function isValid($value) - { - if ((!$value instanceof stdClass) - || !isset($value->content) - || !isset($value->attributes)) - { - return false; - } - - return true; - } - - /** - * Override append to enforce style creation - * - * @param mixed $value - * @throws Exception\InvalidArgumentException - * @return void - */ - public function append($value) - { - if (!$this->isValid($value)) { - throw new Exception\InvalidArgumentException( - 'Invalid value passed to append; please use appendStyle()' - ); - } - - return $this->getContainer()->append($value); - } - - /** - * Override offsetSet to enforce style creation + * Create string representation of placeholder * - * @param string|int $index - * @param mixed $value - * @throws Exception\InvalidArgumentException - * @return void + * @param string|int $indent + * @return string */ - public function offsetSet($index, $value) + public function toString($indent = null) { - if (!$this->isValid($value)) { - throw new Exception\InvalidArgumentException( - 'Invalid value passed to offsetSet; please use offsetSetStyle()' - ); - } - - return $this->getContainer()->offsetSet($index, $value); - } + $indent = (null !== $indent) + ? $this->getWhitespace($indent) + : $this->getIndent(); - /** - * Override prepend to enforce style creation - * - * @param mixed $value - * @throws Exception\InvalidArgumentException - * @return void - */ - public function prepend($value) - { - if (!$this->isValid($value)) { - throw new Exception\InvalidArgumentException( - 'Invalid value passed to prepend; please use prependStyle()' - ); + $items = array(); + $this->getContainer()->ksort(); + foreach ($this as $item) { + if (!$this->isValid($item)) { + continue; + } + $items[] = $this->itemToString($item, $indent); } - return $this->getContainer()->prepend($value); - } - - /** - * Override set to enforce style creation - * - * @param mixed $value - * @throws Exception\InvalidArgumentException - * @return void - */ - public function set($value) - { - if (!$this->isValid($value)) { - throw new Exception\InvalidArgumentException('Invalid value passed to set; please use setStyle()'); - } + $return = $indent . implode($this->getSeparator() . $indent, $items); + $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return); - return $this->getContainer()->set($value); + return $return; } /** @@ -296,6 +234,46 @@ public function captureEnd() } } + /** + * Create data item for use in stack + * + * @param string $content + * @param array $attributes + * @return stdClass + */ + public function createData($content, array $attributes) + { + if (!isset($attributes['media'])) { + $attributes['media'] = 'screen'; + } elseif (is_array($attributes['media'])) { + $attributes['media'] = implode(',', $attributes['media']); + } + + $data = new stdClass(); + $data->content = $content; + $data->attributes = $attributes; + + return $data; + } + + /** + * Determine if a value is a valid style tag + * + * @param mixed $value + * @return bool + */ + protected function isValid($value) + { + if ((!$value instanceof stdClass) + || !isset($value->content) + || !isset($value->attributes)) + { + return false; + } + + return true; + } + /** * Convert content and attributes into valid style tag * @@ -351,8 +329,8 @@ public function itemToString(stdClass $item, $indent) } $html = ''; + . $escapeStart . $indent . $item->content . PHP_EOL . $escapeEnd + . ''; if (null == $escapeStart && null == $escapeEnd) { $html = ''; @@ -362,51 +340,73 @@ public function itemToString(stdClass $item, $indent) } /** - * Create string representation of placeholder + * Override append to enforce style creation * - * @param string|int $indent - * @return string + * @param mixed $value + * @throws Exception\InvalidArgumentException + * @return void */ - public function toString($indent = null) + public function append($value) { - $indent = (null !== $indent) - ? $this->getWhitespace($indent) - : $this->getIndent(); - - $items = array(); - $this->getContainer()->ksort(); - foreach ($this as $item) { - if (!$this->isValid($item)) { - continue; - } - $items[] = $this->itemToString($item, $indent); + if (!$this->isValid($value)) { + throw new Exception\InvalidArgumentException( + 'Invalid value passed to append; please use appendStyle()' + ); } - $return = $indent . implode($this->getSeparator() . $indent, $items); - $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return); + return $this->getContainer()->append($value); + } - return $return; + /** + * Override offsetSet to enforce style creation + * + * @param string|int $index + * @param mixed $value + * @throws Exception\InvalidArgumentException + * @return void + */ + public function offsetSet($index, $value) + { + if (!$this->isValid($value)) { + throw new Exception\InvalidArgumentException( + 'Invalid value passed to offsetSet; please use offsetSetStyle()' + ); + } + + return $this->getContainer()->offsetSet($index, $value); } /** - * Create data item for use in stack + * Override prepend to enforce style creation * - * @param string $content - * @param array $attributes - * @return stdClass + * @param mixed $value + * @throws Exception\InvalidArgumentException + * @return void */ - public function createData($content, array $attributes) + public function prepend($value) { - if (!isset($attributes['media'])) { - $attributes['media'] = 'screen'; - } elseif (is_array($attributes['media'])) { - $attributes['media'] = implode(',', $attributes['media']); + if (!$this->isValid($value)) { + throw new Exception\InvalidArgumentException( + 'Invalid value passed to prepend; please use prependStyle()' + ); } - $data = new stdClass(); - $data->content = $content; - $data->attributes = $attributes; + return $this->getContainer()->prepend($value); + } - return $data; + /** + * Override set to enforce style creation + * + * @param mixed $value + * @throws Exception\InvalidArgumentException + * @return void + */ + public function set($value) + { + if (!$this->isValid($value)) { + throw new Exception\InvalidArgumentException('Invalid value passed to set; please use setStyle()'); + } + + return $this->getContainer()->set($value); } } diff --git a/src/Helper/HeadTitle.php b/src/Helper/HeadTitle.php index b800d379..cf41b062 100644 --- a/src/Helper/HeadTitle.php +++ b/src/Helper/HeadTitle.php @@ -83,39 +83,6 @@ public function __invoke($title = null, $setType = null) return $this; } - /** - * Set a default order to add titles - * - * @param string $setType - * @throws Exception\DomainException - * @return HeadTitle - */ - public function setDefaultAttachOrder($setType) - { - if (!in_array($setType, array( - Placeholder\Container\AbstractContainer::APPEND, - Placeholder\Container\AbstractContainer::SET, - Placeholder\Container\AbstractContainer::PREPEND - ))) { - throw new Exception\DomainException( - "You must use a valid attach order: 'PREPEND', 'APPEND' or 'SET'" - ); - } - $this->defaultAttachOrder = $setType; - - return $this; - } - - /** - * Get the default attach order, if any. - * - * @return mixed - */ - public function getDefaultAttachOrder() - { - return $this->defaultAttachOrder; - } - /** * Turn helper into string * @@ -162,6 +129,39 @@ public function toString($indent = null) return $indent . '' . $output . ''; } + /** + * Set a default order to add titles + * + * @param string $setType + * @throws Exception\DomainException + * @return HeadTitle + */ + public function setDefaultAttachOrder($setType) + { + if (!in_array($setType, array( + Placeholder\Container\AbstractContainer::APPEND, + Placeholder\Container\AbstractContainer::SET, + Placeholder\Container\AbstractContainer::PREPEND + ))) { + throw new Exception\DomainException( + "You must use a valid attach order: 'PREPEND', 'APPEND' or 'SET'" + ); + } + $this->defaultAttachOrder = $setType; + + return $this; + } + + /** + * Get the default attach order, if any. + * + * @return mixed + */ + public function getDefaultAttachOrder() + { + return $this->defaultAttachOrder; + } + // Translator methods - Good candidate to refactor as a trait with PHP 5.4 /** @@ -216,7 +216,6 @@ public function hasTranslator() public function setTranslatorEnabled($enabled = true) { $this->translatorEnabled = (bool) $enabled; - return $this; } @@ -239,7 +238,6 @@ public function isTranslatorEnabled() public function setTranslatorTextDomain($textDomain = 'default') { $this->translatorTextDomain = $textDomain; - return $this; } diff --git a/src/Helper/Identity.php b/src/Helper/Identity.php index 2de4e35f..b4b9c635 100644 --- a/src/Helper/Identity.php +++ b/src/Helper/Identity.php @@ -54,7 +54,6 @@ public function __invoke() public function setAuthenticationService(AuthenticationService $authenticationService) { $this->authenticationService = $authenticationService; - return $this; } diff --git a/src/Helper/Json.php b/src/Helper/Json.php index b4c19349..b555e80f 100644 --- a/src/Helper/Json.php +++ b/src/Helper/Json.php @@ -50,7 +50,6 @@ public function __invoke($data, array $jsonOptions = array()) public function setResponse(Response $response) { $this->response = $response; - return $this; } } diff --git a/src/Helper/Layout.php b/src/Helper/Layout.php index fc752975..e98c10ca 100644 --- a/src/Helper/Layout.php +++ b/src/Helper/Layout.php @@ -50,19 +50,6 @@ public function getLayout() return $this->getRoot()->getTemplate(); } - /** - * Set layout template - * - * @param string $template - * @return Layout - */ - public function setTemplate($template) - { - $this->getRoot()->setTemplate((string) $template); - - return $this; - } - /** * Get the root view model * @@ -83,6 +70,18 @@ protected function getRoot() return $helper->getRoot(); } + /** + * Set layout template + * + * @param string $template + * @return Layout + */ + public function setTemplate($template) + { + $this->getRoot()->setTemplate((string) $template); + return $this; + } + /** * Retrieve the view model helper * diff --git a/src/Helper/Navigation.php b/src/Helper/Navigation.php index 8b398f14..ec86d56f 100644 --- a/src/Helper/Navigation.php +++ b/src/Helper/Navigation.php @@ -27,11 +27,6 @@ class Navigation extends AbstractNavigationHelper */ const NS = 'Zend\View\Helper\Navigation'; - /** - * @var Navigation\PluginManager - */ - protected $plugins; - /** * Default proxy to use in {@link render()} * @@ -47,18 +42,18 @@ class Navigation extends AbstractNavigationHelper protected $injected = array(); /** - * Whether container should be injected when proxying + * Whether ACL should be injected when proxying * * @var bool */ - protected $injectContainer = true; + protected $injectAcl = true; /** - * Whether ACL should be injected when proxying + * Whether container should be injected when proxying * * @var bool */ - protected $injectAcl = true; + protected $injectContainer = true; /** * Whether translator should be injected when proxying @@ -67,6 +62,11 @@ class Navigation extends AbstractNavigationHelper */ protected $injectTranslator = true; + /** + * @var Navigation\PluginManager + */ + protected $plugins; + /** * Helper entry point * @@ -130,43 +130,7 @@ public function __call($method, array $arguments = array()) */ public function render($container = null) { - $helper = $this->findHelper($this->getDefaultProxy()); - - return $helper->render($container); - } - - /** - * Set manager for retrieving navigation helpers - * - * @param Navigation\PluginManager $plugins - * @return Navigation - */ - public function setPluginManager(Navigation\PluginManager $plugins) - { - $renderer = $this->getView(); - if ($renderer) { - $plugins->setRenderer($renderer); - } - $this->plugins = $plugins; - - return $this; - } - - /** - * Retrieve plugin loader for navigation helpers - * - * Lazy-loads an instance of Navigation\HelperLoader if none currently - * registered. - * - * @return Navigation\PluginManager - */ - public function getPluginManager() - { - if (null === $this->plugins) { - $this->setPluginManager(new Navigation\PluginManager()); - } - - return $this->plugins; + return $this->findHelper($this->getDefaultProxy())->render($container); } /** @@ -237,8 +201,6 @@ protected function inject(NavigationHelper $helper) } } - // Accessors: - /** * Sets the default proxy to use in {@link render()} * @@ -248,7 +210,6 @@ protected function inject(NavigationHelper $helper) public function setDefaultProxy($proxy) { $this->defaultProxy = (string) $proxy; - return $this; } @@ -265,20 +226,19 @@ public function getDefaultProxy() /** * Sets whether container should be injected when proxying * - * @param bool $injectContainer [optional] whether container should be injected when proxying. + * @param bool $injectContainer * @return Navigation */ public function setInjectContainer($injectContainer = true) { $this->injectContainer = (bool) $injectContainer; - return $this; } /** * Returns whether container should be injected when proxying * - * @return bool whether container should be injected when proxying + * @return bool */ public function getInjectContainer() { @@ -288,20 +248,19 @@ public function getInjectContainer() /** * Sets whether ACL should be injected when proxying * - * @param bool $injectAcl [optional] whether ACL should be injected when proxying. + * @param bool $injectAcl * @return Navigation */ public function setInjectAcl($injectAcl = true) { $this->injectAcl = (bool) $injectAcl; - return $this; } /** * Returns whether ACL should be injected when proxying * - * @return bool whether ACL should be injected when proxying + * @return bool */ public function getInjectAcl() { @@ -311,23 +270,56 @@ public function getInjectAcl() /** * Sets whether translator should be injected when proxying * - * @param bool $injectTranslator [optional] whether translator should be injected when proxying. + * @param bool $injectTranslator * @return Navigation */ public function setInjectTranslator($injectTranslator = true) { $this->injectTranslator = (bool) $injectTranslator; - return $this; } /** * Returns whether translator should be injected when proxying * - * @return bool whether translator should be injected when proxying + * @return bool */ public function getInjectTranslator() { return $this->injectTranslator; } + + /** + * Set manager for retrieving navigation helpers + * + * @param Navigation\PluginManager $plugins + * @return Navigation + */ + public function setPluginManager(Navigation\PluginManager $plugins) + { + $renderer = $this->getView(); + if ($renderer) { + $plugins->setRenderer($renderer); + } + $this->plugins = $plugins; + + return $this; + } + + /** + * Retrieve plugin loader for navigation helpers + * + * Lazy-loads an instance of Navigation\HelperLoader if none currently + * registered. + * + * @return Navigation\PluginManager + */ + public function getPluginManager() + { + if (null === $this->plugins) { + $this->setPluginManager(new Navigation\PluginManager()); + } + + return $this->plugins; + } } diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index fd9ffe0f..cf88b647 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -127,61 +127,110 @@ abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements protected static $defaultRole; /** - * Set the service locator. + * Magic overload: Proxy calls to the navigation container * - * @param ServiceLocatorInterface $serviceLocator - * @return AbstractHelper + * @param string $method method name in container + * @param array $arguments rguments to pass + * @return mixed + * @throws Navigation\Exception\ExceptionInterface */ - public function setServiceLocator(ServiceLocatorInterface $serviceLocator) + public function __call($method, array $arguments = array()) { - $this->serviceLocator = $serviceLocator; - - return $this; + return call_user_func_array( + array($this->getContainer(), $method), + $arguments); } /** - * Get the service locator. + * Magic overload: Proxy to {@link render()}. * - * @return ServiceLocatorInterface + * This method will trigger an E_USER_ERROR if rendering the helper causes + * an exception to be thrown. + * + * Implements {@link HelperInterface::__toString()}. + * + * @return string */ - public function getServiceLocator() + public function __toString() { - return $this->serviceLocator; + try { + return $this->render(); + } catch (\Exception $e) { + $msg = get_class($e) . ': ' . $e->getMessage(); + trigger_error($msg, E_USER_ERROR); + return ''; + } } /** - * Sets navigation container the helper operates on by default - * - * Implements {@link HelperInterface::setContainer()}. + * Finds the deepest active page in the given container * - * @param string|Navigation\AbstractContainer $container Default is null, meaning container will be reset. - * @return AbstractHelper + * @param Navigation\AbstractContainer $container container to search + * @param int|null $minDepth [optional] minimum depth + * required for page to be + * valid. Default is to use + * {@link getMinDepth()}. A + * null value means no minimum + * depth required. + * @param int|null $maxDepth [optional] maximum depth + * a page can have to be + * valid. Default is to use + * {@link getMaxDepth()}. A + * null value means no maximum + * depth required. + * @return array an associative array with + * the values 'depth' and + * 'page', or an empty array + * if not found */ - public function setContainer($container = null) + public function findActive($container, $minDepth = null, $maxDepth = -1) { $this->parseContainer($container); - $this->container = $container; + if (!is_int($minDepth)) { + $minDepth = $this->getMinDepth(); + } + if ((!is_int($maxDepth) || $maxDepth < 0) && null !== $maxDepth) { + $maxDepth = $this->getMaxDepth(); + } - return $this; - } + $found = null; + $foundDepth = -1; + $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::CHILD_FIRST); - /** - * Returns the navigation container helper operates on by default - * - * Implements {@link HelperInterface::getContainer()}. - * - * If no container is set, a new container will be instantiated and - * stored in the helper. - * - * @return Navigation\AbstractContainer navigation container - */ - public function getContainer() - { - if (null === $this->container) { - $this->container = new Navigation\Navigation(); + foreach ($iterator as $page) { + $currDepth = $iterator->getDepth(); + if ($currDepth < $minDepth || !$this->accept($page)) { + // page is not accepted + continue; + } + + if ($page->isActive(false) && $currDepth > $foundDepth) { + // found an active page at a deeper level than before + $found = $page; + $foundDepth = $currDepth; + } } - return $this->container; + if (is_int($maxDepth) && $foundDepth > $maxDepth) { + while ($foundDepth > $maxDepth) { + if (--$foundDepth < $minDepth) { + $found = null; + break; + } + + $found = $found->getParent(); + if (!$found instanceof AbstractPage) { + $found = null; + break; + } + } + } + + if ($found) { + return array('page' => $found, 'depth' => $foundDepth); + } + + return array(); } /** @@ -227,86 +276,170 @@ protected function parseContainer(&$container = null) } } + // Iterator filter methods: + /** - * Sets the minimum depth a page must have to be included when rendering + * Determines whether a page should be accepted when iterating * - * @param int $minDepth Default is null, which sets no minimum depth. - * @return AbstractHelper + * Rules: + * - If a page is not visible it is not accepted, unless RenderInvisible has + * been set to true. + * - If helper has no ACL, page is accepted + * - If helper has ACL, but no role, page is not accepted + * - If helper has ACL and role: + * - Page is accepted if it has no resource or privilege + * - Page is accepted if ACL allows page's resource or privilege + * - If page is accepted by the rules above and $recursive is true, the page + * will not be accepted if it is the descendant of a non-accepted page. + * + * @param AbstractPage $page page to check + * @param bool $recursive [optional] if true, page will not be + * accepted if it is the descendant of a + * page that is not accepted. Default is true. + * @return bool */ - public function setMinDepth($minDepth = null) + public function accept(AbstractPage $page, $recursive = true) { - if (null === $minDepth || is_int($minDepth)) { - $this->minDepth = $minDepth; - } else { - $this->minDepth = (int) $minDepth; + // accept by default + $accept = true; + + if (!$page->isVisible(false) && !$this->getRenderInvisible()) { + // don't accept invisible pages + $accept = false; + } elseif ($this->getUseAcl() && !$this->acceptAcl($page)) { + // acl is not amused + $accept = false; } - return $this; + if ($accept && $recursive) { + $parent = $page->getParent(); + if ($parent instanceof AbstractPage) { + $accept = $this->accept($parent, true); + } + } + + return $accept; } /** - * Returns minimum depth a page must have to be included when rendering + * Determines whether a page should be accepted by ACL when iterating * - * @return int|null + * Rules: + * - If helper has no ACL, page is accepted + * - If page has a resource or privilege defined, page is accepted + * if the ACL allows access to it using the helper's role + * - If page has no resource or privilege, page is accepted + * + * @param AbstractPage $page page to check + * @return bool */ - public function getMinDepth() + protected function acceptAcl(AbstractPage $page) { - if (!is_int($this->minDepth) || $this->minDepth < 0) { - return 0; + if (!$acl = $this->getAcl()) { + // no acl registered means don't use acl + return true; } - return $this->minDepth; + $role = $this->getRole(); + $resource = $page->getResource(); + $privilege = $page->getPrivilege(); + + if ($resource || $privilege) { + // determine using helper role and page resource/privilege + return $acl->hasResource($resource) && $acl->isAllowed($role, $resource, $privilege); + } + + return true; } + // Util methods: + /** - * Sets the maximum depth a page can have to be included when rendering + * Retrieve whitespace representation of $indent * - * @param int $maxDepth Default is null, which sets no maximum depth. - * @return AbstractHelper + * @param int|string $indent + * @return string */ - public function setMaxDepth($maxDepth = null) + protected function getWhitespace($indent) { - if (null === $maxDepth || is_int($maxDepth)) { - $this->maxDepth = $maxDepth; - } else { - $this->maxDepth = (int) $maxDepth; + if (is_int($indent)) { + $indent = str_repeat(' ', $indent); } - return $this; + return (string) $indent; } /** - * Returns maximum depth a page can have to be included when rendering + * Converts an associative array to a string of tag attributes. * - * @return int|null + * Overloads {@link View\Helper\AbstractHtmlElement::htmlAttribs()}. + * + * @param array $attribs an array where each key-value pair is converted + * to an attribute name and value + * @return string */ - public function getMaxDepth() + protected function htmlAttribs($attribs) { - return $this->maxDepth; + // filter out null values and empty string values + foreach ($attribs as $key => $value) { + if ($value === null || (is_string($value) && !strlen($value))) { + unset($attribs[$key]); + } + } + + return parent::htmlAttribs($attribs); } /** - * Set the indentation string for using in {@link render()}, optionally a - * number of spaces to indent with + * Returns an HTML string containing an 'a' element for the given page * - * @param string|int $indent - * @return AbstractHelper + * @param AbstractPage $page page to generate HTML for + * @return string */ - public function setIndent($indent) + public function htmlify(AbstractPage $page) { - $this->indent = $this->getWhitespace($indent); + // get label and title for translating + $label = $page->getLabel(); + $title = $page->getTitle(); - return $this; + if (null !== ($translator = $this->getTranslator())) { + $textDomain = $this->getTranslatorTextDomain(); + if (is_string($label) && !empty($label)) { + $label = $translator->translate($label, $textDomain); + } + if (is_string($title) && !empty($title)) { + $title = $translator->translate($title, $textDomain); + } + } + + // get attribs for anchor element + $attribs = array( + 'id' => $page->getId(), + 'title' => $title, + 'class' => $page->getClass(), + 'href' => $page->getHref(), + 'target' => $page->getTarget() + ); + + $escaper = $this->view->plugin('escapeHtml'); + + return 'htmlAttribs($attribs) . '>' . $escaper($label) . ''; } /** - * Returns indentation + * Normalize an ID + * + * Overrides {@link View\Helper\AbstractHtmlElement::normalizeId()}. * + * @param string $value * @return string */ - public function getIndent() + protected function normalizeId($value) { - return $this->indent; + $prefix = get_class($this); + $prefix = strtolower(trim(substr($prefix, strrpos($prefix, '\\')), '\\')); + + return $prefix . '-' . $value; } /** @@ -320,7 +453,6 @@ public function getIndent() public function setAcl(Acl\AclInterface $acl = null) { $this->acl = $acl; - return $this; } @@ -342,239 +474,216 @@ public function getAcl() } /** - * Sets ACL role(s) to use when iterating pages + * Checks if the helper has an ACL instance * - * Implements {@link HelperInterface::setRole()}. + * Implements {@link HelperInterface::hasAcl()}. * - * @param mixed $role [optional] role to set. Expects a string, an - * instance of type {@link Acl\Role\RoleInterface}, or null. Default - * is null, which will set no role. - * @return AbstractHelper - * @throws Exception\InvalidArgumentException + * @return bool */ - public function setRole($role = null) + public function hasAcl() { - if (null === $role || is_string($role) || - $role instanceof Acl\Role\RoleInterface + if ($this->acl instanceof Acl\Acl + || static::$defaultAcl instanceof Acl\Acl ) { - $this->role = $role; - } else { - throw new Exception\InvalidArgumentException(sprintf( - '$role must be a string, null, or an instance of ' - . 'Zend\Permissions\Role\RoleInterface; %s given', - (is_object($role) ? get_class($role) : gettype($role)) - )); - } - - return $this; - } - - /** - * Returns ACL role to use when iterating pages, or null if it isn't set - * using {@link setRole()} or {@link setDefaultRole()} - * - * Implements {@link HelperInterface::getRole()}. - * - * @return string|Acl\Role\RoleInterface|null - */ - public function getRole() - { - if ($this->role === null && static::$defaultRole !== null) { - return static::$defaultRole; + return true; } - return $this->role; + return false; } /** - * Sets whether ACL should be used + * Sets navigation container the helper operates on by default * - * Implements {@link HelperInterface::setUseAcl()}. + * Implements {@link HelperInterface::setContainer()}. * - * @param bool $useAcl Whether ACL should be used. + * @param string|Navigation\AbstractContainer $container Default is null, meaning container will be reset. * @return AbstractHelper */ - public function setUseAcl($useAcl = true) + public function setContainer($container = null) { - $this->useAcl = (bool) $useAcl; + $this->parseContainer($container); + $this->container = $container; return $this; } /** - * Returns whether ACL should be used + * Returns the navigation container helper operates on by default * - * Implements {@link HelperInterface::getUseAcl()}. + * Implements {@link HelperInterface::getContainer()}. * - * @return bool + * If no container is set, a new container will be instantiated and + * stored in the helper. + * + * @return Navigation\AbstractContainer navigation container */ - public function getUseAcl() + public function getContainer() { - return $this->useAcl; + if (null === $this->container) { + $this->container = new Navigation\Navigation(); + } + + return $this->container; } /** - * Return renderInvisible flag + * Checks if the helper has a container + * + * Implements {@link HelperInterface::hasContainer()}. * * @return bool */ - public function getRenderInvisible() + public function hasContainer() { - return $this->renderInvisible; + return null !== $this->container; } /** - * Render invisible items? + * Set the indentation string for using in {@link render()}, optionally a + * number of spaces to indent with * - * @param bool $renderInvisible + * @param string|int $indent * @return AbstractHelper */ - public function setRenderInvisible($renderInvisible = true) + public function setIndent($indent) { - $this->renderInvisible = (bool) $renderInvisible; - + $this->indent = $this->getWhitespace($indent); return $this; } - // Magic overloads: - /** - * Magic overload: Proxy calls to the navigation container + * Returns indentation * - * @param string $method method name in container - * @param array $arguments rguments to pass - * @return mixed - * @throws Navigation\Exception\ExceptionInterface + * @return string */ - public function __call($method, array $arguments = array()) + public function getIndent() { - return call_user_func_array( - array($this->getContainer(), $method), - $arguments); + return $this->indent; } /** - * Magic overload: Proxy to {@link render()}. - * - * This method will trigger an E_USER_ERROR if rendering the helper causes - * an exception to be thrown. - * - * Implements {@link HelperInterface::__toString()}. + * Sets the maximum depth a page can have to be included when rendering * - * @return string + * @param int $maxDepth Default is null, which sets no maximum depth. + * @return AbstractHelper */ - public function __toString() + public function setMaxDepth($maxDepth = null) { - try { - return $this->render(); - } catch (\Exception $e) { - $msg = get_class($e) . ': ' . $e->getMessage(); - trigger_error($msg, E_USER_ERROR); - return ''; + if (null === $maxDepth || is_int($maxDepth)) { + $this->maxDepth = $maxDepth; + } else { + $this->maxDepth = (int) $maxDepth; } - } - // Public methods: + return $this; + } /** - * Finds the deepest active page in the given container + * Returns maximum depth a page can have to be included when rendering * - * @param Navigation\AbstractContainer $container container to search - * @param int|null $minDepth [optional] minimum depth - * required for page to be - * valid. Default is to use - * {@link getMinDepth()}. A - * null value means no minimum - * depth required. - * @param int|null $maxDepth [optional] maximum depth - * a page can have to be - * valid. Default is to use - * {@link getMaxDepth()}. A - * null value means no maximum - * depth required. - * @return array an associative array with - * the values 'depth' and - * 'page', or an empty array - * if not found + * @return int|null */ - public function findActive($container, $minDepth = null, $maxDepth = -1) + public function getMaxDepth() { - $this->parseContainer($container); - if (!is_int($minDepth)) { - $minDepth = $this->getMinDepth(); - } - if ((!is_int($maxDepth) || $maxDepth < 0) && null !== $maxDepth) { - $maxDepth = $this->getMaxDepth(); - } - - $found = null; - $foundDepth = -1; - $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::CHILD_FIRST); - - foreach ($iterator as $page) { - $currDepth = $iterator->getDepth(); - if ($currDepth < $minDepth || !$this->accept($page)) { - // page is not accepted - continue; - } - - if ($page->isActive(false) && $currDepth > $foundDepth) { - // found an active page at a deeper level than before - $found = $page; - $foundDepth = $currDepth; - } - } - - if (is_int($maxDepth) && $foundDepth > $maxDepth) { - while ($foundDepth > $maxDepth) { - if (--$foundDepth < $minDepth) { - $found = null; - break; - } + return $this->maxDepth; + } - $found = $found->getParent(); - if (!$found instanceof AbstractPage) { - $found = null; - break; - } - } + /** + * Sets the minimum depth a page must have to be included when rendering + * + * @param int $minDepth Default is null, which sets no minimum depth. + * @return AbstractHelper + */ + public function setMinDepth($minDepth = null) + { + if (null === $minDepth || is_int($minDepth)) { + $this->minDepth = $minDepth; + } else { + $this->minDepth = (int) $minDepth; } - if ($found) { - return array('page' => $found, 'depth' => $foundDepth); + return $this; + } + + /** + * Returns minimum depth a page must have to be included when rendering + * + * @return int|null + */ + public function getMinDepth() + { + if (!is_int($this->minDepth) || $this->minDepth < 0) { + return 0; } - return array(); + return $this->minDepth; } /** - * Checks if the helper has a container + * Render invisible items? * - * Implements {@link HelperInterface::hasContainer()}. + * @param bool $renderInvisible + * @return AbstractHelper + */ + public function setRenderInvisible($renderInvisible = true) + { + $this->renderInvisible = (bool) $renderInvisible; + return $this; + } + + /** + * Return renderInvisible flag * * @return bool */ - public function hasContainer() + public function getRenderInvisible() { - return null !== $this->container; + return $this->renderInvisible; } /** - * Checks if the helper has an ACL instance + * Sets ACL role(s) to use when iterating pages * - * Implements {@link HelperInterface::hasAcl()}. + * Implements {@link HelperInterface::setRole()}. * - * @return bool + * @param mixed $role [optional] role to set. Expects a string, an + * instance of type {@link Acl\Role\RoleInterface}, or null. Default + * is null, which will set no role. + * @return AbstractHelper + * @throws Exception\InvalidArgumentException */ - public function hasAcl() + public function setRole($role = null) { - if ($this->acl instanceof Acl\Acl - || static::$defaultAcl instanceof Acl\Acl + if (null === $role || is_string($role) || + $role instanceof Acl\Role\RoleInterface ) { - return true; + $this->role = $role; + } else { + throw new Exception\InvalidArgumentException(sprintf( + '$role must be a string, null, or an instance of ' + . 'Zend\Permissions\Role\RoleInterface; %s given', + (is_object($role) ? get_class($role) : gettype($role)) + )); } - return false; + return $this; + } + + /** + * Returns ACL role to use when iterating pages, or null if it isn't set + * using {@link setRole()} or {@link setDefaultRole()} + * + * Implements {@link HelperInterface::getRole()}. + * + * @return string|Acl\Role\RoleInterface|null + */ + public function getRole() + { + if ($this->role === null && static::$defaultRole !== null) { + return static::$defaultRole; + } + + return $this->role; } /** @@ -598,39 +707,25 @@ public function hasRole() } /** - * Returns an HTML string containing an 'a' element for the given page + * Set the service locator. * - * @param AbstractPage $page page to generate HTML for - * @return string + * @param ServiceLocatorInterface $serviceLocator + * @return AbstractHelper */ - public function htmlify(AbstractPage $page) + public function setServiceLocator(ServiceLocatorInterface $serviceLocator) { - // get label and title for translating - $label = $page->getLabel(); - $title = $page->getTitle(); - - if (null !== ($translator = $this->getTranslator())) { - $textDomain = $this->getTranslatorTextDomain(); - if (is_string($label) && !empty($label)) { - $label = $translator->translate($label, $textDomain); - } - if (is_string($title) && !empty($title)) { - $title = $translator->translate($title, $textDomain); - } - } - - // get attribs for anchor element - $attribs = array( - 'id' => $page->getId(), - 'title' => $title, - 'class' => $page->getClass(), - 'href' => $page->getHref(), - 'target' => $page->getTarget() - ); - - $escaper = $this->view->plugin('escapeHtml'); + $this->serviceLocator = $serviceLocator; + return $this; + } - return 'htmlAttribs($attribs) . '>' . $escaper($label) . ''; + /** + * Get the service locator. + * + * @return ServiceLocatorInterface + */ + public function getServiceLocator() + { + return $this->serviceLocator; } // Translator methods - Good candidate to refactor as a trait with PHP 5.4 @@ -687,7 +782,6 @@ public function hasTranslator() public function setTranslatorEnabled($enabled = true) { $this->translatorEnabled = (bool) $enabled; - return $this; } @@ -710,7 +804,6 @@ public function isTranslatorEnabled() public function setTranslatorTextDomain($textDomain = 'default') { $this->translatorTextDomain = $textDomain; - return $this; } @@ -724,134 +817,30 @@ public function getTranslatorTextDomain() return $this->translatorTextDomain; } - // Iterator filter methods: - /** - * Determines whether a page should be accepted when iterating + * Sets whether ACL should be used * - * Rules: - * - If a page is not visible it is not accepted, unless RenderInvisible has - * been set to true. - * - If helper has no ACL, page is accepted - * - If helper has ACL, but no role, page is not accepted - * - If helper has ACL and role: - * - Page is accepted if it has no resource or privilege - * - Page is accepted if ACL allows page's resource or privilege - * - If page is accepted by the rules above and $recursive is true, the page - * will not be accepted if it is the descendant of a non-accepted page. + * Implements {@link HelperInterface::setUseAcl()}. * - * @param AbstractPage $page page to check - * @param bool $recursive [optional] if true, page will not be - * accepted if it is the descendant of a - * page that is not accepted. Default is true. - * @return bool + * @param bool $useAcl + * @return AbstractHelper */ - public function accept(AbstractPage $page, $recursive = true) + public function setUseAcl($useAcl = true) { - // accept by default - $accept = true; - - if (!$page->isVisible(false) && !$this->getRenderInvisible()) { - // don't accept invisible pages - $accept = false; - } elseif ($this->getUseAcl() && !$this->acceptAcl($page)) { - // acl is not amused - $accept = false; - } - - if ($accept && $recursive) { - $parent = $page->getParent(); - if ($parent instanceof AbstractPage) { - $accept = $this->accept($parent, true); - } - } - - return $accept; + $this->useAcl = (bool) $useAcl; + return $this; } /** - * Determines whether a page should be accepted by ACL when iterating + * Returns whether ACL should be used * - * Rules: - * - If helper has no ACL, page is accepted - * - If page has a resource or privilege defined, page is accepted - * if the ACL allows access to it using the helper's role - * - If page has no resource or privilege, page is accepted + * Implements {@link HelperInterface::getUseAcl()}. * - * @param AbstractPage $page page to check * @return bool */ - protected function acceptAcl(AbstractPage $page) - { - if (!$acl = $this->getAcl()) { - // no acl registered means don't use acl - return true; - } - - $role = $this->getRole(); - $resource = $page->getResource(); - $privilege = $page->getPrivilege(); - - if ($resource || $privilege) { - // determine using helper role and page resource/privilege - return $acl->hasResource($resource) && $acl->isAllowed($role, $resource, $privilege); - } - - return true; - } - - // Util methods: - - /** - * Retrieve whitespace representation of $indent - * - * @param int|string $indent - * @return string - */ - protected function getWhitespace($indent) - { - if (is_int($indent)) { - $indent = str_repeat(' ', $indent); - } - - return (string) $indent; - } - - /** - * Converts an associative array to a string of tag attributes. - * - * Overloads {@link View\Helper\AbstractHtmlElement::htmlAttribs()}. - * - * @param array $attribs an array where each key-value pair is converted - * to an attribute name and value - * @return string - */ - protected function htmlAttribs($attribs) - { - // filter out null values and empty string values - foreach ($attribs as $key => $value) { - if ($value === null || (is_string($value) && !strlen($value))) { - unset($attribs[$key]); - } - } - - return parent::htmlAttribs($attribs); - } - - /** - * Normalize an ID - * - * Overrides {@link View\Helper\AbstractHtmlElement::normalizeId()}. - * - * @param string $value - * @return string - */ - protected function normalizeId($value) + public function getUseAcl() { - $prefix = get_class($this); - $prefix = strtolower(trim(substr($prefix, strrpos($prefix, '\\')), '\\')); - - return $prefix . '-' . $value; + return $this->useAcl; } // Static methods: diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php index dfb9e4b3..a52350ee 100644 --- a/src/Helper/Navigation/Breadcrumbs.php +++ b/src/Helper/Navigation/Breadcrumbs.php @@ -20,11 +20,11 @@ class Breadcrumbs extends AbstractHelper { /** - * Breadcrumbs separator string + * Whether last page in breadcrumb should be hyperlinked * - * @var string + * @var bool */ - protected $separator = ' > '; + protected $linkLast = false; /** * The minimum depth a page must have to be included when rendering @@ -34,18 +34,18 @@ class Breadcrumbs extends AbstractHelper protected $minDepth = 1; /** - * Whether last page in breadcrumb should be hyperlinked + * Partial view script to use for rendering menu * - * @var bool + * @var string|array */ - protected $linkLast = false; + protected $partial; /** - * Partial view script to use for rendering menu + * Breadcrumbs separator string * - * @var string|array + * @var string */ - protected $partial; + protected $separator = ' > '; /** * Helper entry point @@ -63,89 +63,30 @@ public function __invoke($container = null) } /** - * Sets breadcrumb separator - * - * @param string $separator separator string - * @return Breadcrumbs - */ - public function setSeparator($separator) - { - if (is_string($separator)) { - $this->separator = $separator; - } - - return $this; - } - - /** - * Returns breadcrumb separator - * - * @return string breadcrumb separator - */ - public function getSeparator() - { - return $this->separator; - } - - /** - * Sets whether last page in breadcrumbs should be hyperlinked - * - * @param bool $linkLast whether last page should be hyperlinked - * @return Breadcrumbs - */ - public function setLinkLast($linkLast) - { - $this->linkLast = (bool) $linkLast; - return $this; - } - - /** - * Returns whether last page in breadcrumbs should be hyperlinked + * Renders helper * - * @return bool - */ - public function getLinkLast() - { - return $this->linkLast; - } - - /** - * Sets which partial view script to use for rendering menu + * Implements {@link HelperInterface::render()}. * - * @param string|array $partial partial view script or null. If an array is - * given, it is expected to contain two - * values; the partial view script to use, - * and the module where the script can be - * found. - * @return Breadcrumbs + * @param AbstractContainer $container [optional] container to render. Default is + * to render the container registered in the helper. + * @return string */ - public function setPartial($partial) + public function render($container = null) { - if (null === $partial || is_string($partial) || is_array($partial)) { - $this->partial = $partial; + $partial = $this->getPartial(); + if ($partial) { + return $this->renderPartial($container, $partial); } - return $this; - } - - /** - * Returns partial view script to use for rendering menu - * - * @return string|array|null - */ - public function getPartial() - { - return $this->partial; + return $this->renderStraight($container); } - // Render methods: - /** * Renders breadcrumbs by chaining 'a' elements with the separator * registered in the helper * * @param AbstractContainer $container [optional] container to render. Default is - * to render the container registered in the helper. + * to render the container registered in the helper. * @return string */ public function renderStraight($container = null) @@ -179,8 +120,8 @@ public function renderStraight($container = null) if ($parent instanceof AbstractPage) { // prepend crumb to html $html = $this->htmlify($parent) - . $this->getSeparator() - . $html; + . $this->getSeparator() + . $html; } if ($parent === $container) { @@ -209,9 +150,9 @@ public function renderStraight($container = null) * is expected to contain two values; the * partial view script to use, and the module * where the script can be found. - * @return string helper output * @throws Exception\RuntimeException if no partial provided * @throws Exception\InvalidArgumentException if partial is invalid array + * @return string helper output */ public function renderPartial($container = null, $partial = null) { @@ -257,8 +198,8 @@ public function renderPartial($container = null, $partial = null) if (count($partial) != 2) { throw new Exception\InvalidArgumentException( 'Unable to render menu: A view partial supplied as ' - . 'an array must contain two values: partial view ' - . 'script and module where script can be found' + . 'an array must contain two values: partial view ' + . 'script and module where script can be found' ); } @@ -270,24 +211,79 @@ public function renderPartial($container = null, $partial = null) return $partialHelper($partial, $model); } - // Zend\View\Helper\Navigation\Helper: + /** + * Sets whether last page in breadcrumbs should be hyperlinked + * + * @param bool $linkLast whether last page should be hyperlinked + * @return Breadcrumbs + */ + public function setLinkLast($linkLast) + { + $this->linkLast = (bool) $linkLast; + return $this; + } /** - * Renders helper + * Returns whether last page in breadcrumbs should be hyperlinked * - * Implements {@link HelperInterface::render()}. + * @return bool + */ + public function getLinkLast() + { + return $this->linkLast; + } + + /** + * Sets which partial view script to use for rendering menu * - * @param AbstractContainer $container [optional] container to render. Default is - * to render the container registered in the helper. - * @return string + * @param string|array $partial partial view script or null. If an array is + * given, it is expected to contain two + * values; the partial view script to use, + * and the module where the script can be + * found. + * @return Breadcrumbs */ - public function render($container = null) + public function setPartial($partial) { - $partial = $this->getPartial(); - if ($partial) { - return $this->renderPartial($container, $partial); + if (null === $partial || is_string($partial) || is_array($partial)) { + $this->partial = $partial; } - return $this->renderStraight($container); + return $this; + } + + /** + * Returns partial view script to use for rendering menu + * + * @return string|array|null + */ + public function getPartial() + { + return $this->partial; + } + + /** + * Sets breadcrumb separator + * + * @param string $separator separator string + * @return Breadcrumbs + */ + public function setSeparator($separator) + { + if (is_string($separator)) { + $this->separator = $separator; + } + + return $this; + } + + /** + * Returns breadcrumb separator + * + * @return string breadcrumb separator + */ + public function getSeparator() + { + return $this->separator; } } diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index ee6bfa21..06a47f7e 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -19,22 +19,24 @@ interface HelperInterface extends BaseHelperInterface { /** - * Sets navigation container the helper should operate on by default + * Magic overload: Should proxy to {@link render()}. * - * @param string|Navigation\AbstractContainer $container [optional] container to operate - * on. Default is null, which - * indicates that the container - * should be reset. - * @return HelperInterface + * @return string */ - public function setContainer($container = null); + public function __toString(); /** - * Returns the navigation container the helper operates on by default + * Renders helper * - * @return Navigation\AbstractContainer navigation container + * @param string|Navigation\AbstractContainer $container [optional] container to render. + * Default is null, which indicates + * that the helper should render + * the container returned by {@link + * getContainer()}. + * @return string helper output + * @throws \Zend\View\Exception\ExceptionInterface */ - public function getContainer(); + public function render($container = null); /** * Sets ACL to use when iterating pages @@ -53,44 +55,36 @@ public function setAcl(Acl\AclInterface $acl = null); public function getAcl(); /** - * Sets ACL role to use when iterating pages - * - * @param mixed $role [optional] role to set. Expects a string, an - * instance of type {@link Acl\Role}, or null. Default - * is null. - * @throws \Zend\View\Exception\ExceptionInterface if $role is invalid - * @return HelperInterface - */ - public function setRole($role = null); - - /** - * Returns ACL role to use when iterating pages, or null if it isn't set + * Checks if the helper has an ACL instance * - * @return string|Acl\Role\RoleInterface|null + * @return bool */ - public function getRole(); + public function hasAcl(); /** - * Sets whether ACL should be used + * Sets navigation container the helper should operate on by default * - * @param bool $useAcl [optional] whether ACL should be used. Default is true. + * @param string|Navigation\AbstractContainer $container [optional] container to operate + * on. Default is null, which + * indicates that the container + * should be reset. * @return HelperInterface */ - public function setUseAcl($useAcl = true); + public function setContainer($container = null); /** - * Returns whether ACL should be used + * Returns the navigation container the helper operates on by default * - * @return bool + * @return Navigation\AbstractContainer navigation container */ - public function getUseAcl(); + public function getContainer(); /** - * Return renderInvisible flag + * Checks if the helper has a container * * @return bool */ - public function getRenderInvisible(); + public function hasContainer(); /** * Render invisible items? @@ -101,18 +95,29 @@ public function getRenderInvisible(); public function setRenderInvisible($renderInvisible = true); /** - * Checks if the helper has a container + * Return renderInvisible flag * * @return bool */ - public function hasContainer(); + public function getRenderInvisible(); /** - * Checks if the helper has an ACL instance + * Sets ACL role to use when iterating pages * - * @return bool + * @param mixed $role [optional] role to set. Expects a string, an + * instance of type {@link Acl\Role}, or null. Default + * is null. + * @throws \Zend\View\Exception\ExceptionInterface if $role is invalid + * @return HelperInterface */ - public function hasAcl(); + public function setRole($role = null); + + /** + * Returns ACL role to use when iterating pages, or null if it isn't set + * + * @return string|Acl\Role\RoleInterface|null + */ + public function getRole(); /** * Checks if the helper has an ACL role @@ -122,22 +127,17 @@ public function hasAcl(); public function hasRole(); /** - * Magic overload: Should proxy to {@link render()}. + * Sets whether ACL should be used * - * @return string + * @param bool $useAcl [optional] whether ACL should be used. Default is true. + * @return HelperInterface */ - public function __toString(); + public function setUseAcl($useAcl = true); /** - * Renders helper + * Returns whether ACL should be used * - * @param string|Navigation\AbstractContainer $container [optional] container to render. - * Default is null, which indicates - * that the helper should render - * the container returned by {@link - * getContainer()}. - * @return string helper output - * @throws \Zend\View\Exception\ExceptionInterface + * @return bool */ - public function render($container = null); + public function getUseAcl(); } diff --git a/src/Helper/Navigation/Links.php b/src/Helper/Navigation/Links.php index 1672755d..a974586e 100644 --- a/src/Helper/Navigation/Links.php +++ b/src/Helper/Navigation/Links.php @@ -135,48 +135,92 @@ public function __call($method, array $arguments = array()) } /** - * Sets the helper's render flag - * - * The helper uses the bitwise '&' operator against the hex values of the - * render constants. This means that the flag can is "bitwised" value of - * the render constants. Examples: - * - * // render all links except glossary - * $flag = Links:RENDER_ALL ^ Links:RENDER_GLOSSARY; - * $helper->setRenderFlag($flag); - * - * // render only chapters and sections - * $flag = Links:RENDER_CHAPTER | Links:RENDER_SECTION; - * $helper->setRenderFlag($flag); - * - * // render only relations that are not native W3C relations - * $helper->setRenderFlag(Links:RENDER_CUSTOM); - * - * // render all relations (default) - * $helper->setRenderFlag(Links:RENDER_ALL); - * + * Renders helper * - * Note that custom relations can also be rendered directly using the - * {@link renderLink()} method. + * Implements {@link HelperInterface::render()}. * - * @param int $renderFlag - * @return Links + * @param AbstractContainer|string|null $container [optional] container to render. + * Default is to render the + * container registered in the + * helper. + * @return string */ - public function setRenderFlag($renderFlag) + public function render($container = null) { - $this->renderFlag = (int) $renderFlag; + $this->parseContainer($container); + if (null === $container) { + $container = $this->getContainer(); + } - return $this; + $active = $this->findActive($container); + if ($active) { + $active = $active['page']; + } else { + // no active page + return ''; + } + + $output = ''; + $indent = $this->getIndent(); + $this->root = $container; + + $result = $this->findAllRelations($active, $this->getRenderFlag()); + foreach ($result as $attrib => $types) { + foreach ($types as $relation => $pages) { + foreach ($pages as $page) { + $r = $this->renderLink($page, $attrib, $relation); + if ($r) { + $output .= $indent . $r . self::EOL; + } + } + } + } + + $this->root = null; + + // return output (trim last newline by spec) + return strlen($output) ? rtrim($output, self::EOL) : ''; } /** - * Returns the helper's render flag + * Renders the given $page as a link element, with $attrib = $relation * - * @return int + * @param AbstractPage $page the page to render the link for + * @param string $attrib the attribute to use for $type, + * either 'rel' or 'rev' + * @param string $relation relation type, muse be one of; + * alternate, appendix, bookmark, + * chapter, contents, copyright, + * glossary, help, home, index, next, + * prev, section, start, stylesheet, + * subsection + * @return string + * @throws Exception\DomainException */ - public function getRenderFlag() + public function renderLink(AbstractPage $page, $attrib, $relation) { - return $this->renderFlag; + if (!in_array($attrib, array('rel', 'rev'))) { + throw new Exception\DomainException(sprintf( + 'Invalid relation attribute "%s", must be "rel" or "rev"', + $attrib + )); + } + + if (!$href = $page->getHref()) { + return ''; + } + + // TODO: add more attribs + // http://www.w3.org/TR/html401/struct/links.html#h-12.2 + $attribs = array( + $attrib => $relation, + 'href' => $href, + 'title' => $page->getLabel() + ); + + return 'htmlAttribs($attribs) . + $this->getClosingBracket(); } // Finder methods: @@ -673,96 +717,48 @@ protected function convertToPages($mixed, $recursive = true) return null; } - // Render methods: - /** - * Renders the given $page as a link element, with $attrib = $relation + * Sets the helper's render flag * - * @param AbstractPage $page the page to render the link for - * @param string $attrib the attribute to use for $type, - * either 'rel' or 'rev' - * @param string $relation relation type, muse be one of; - * alternate, appendix, bookmark, - * chapter, contents, copyright, - * glossary, help, home, index, next, - * prev, section, start, stylesheet, - * subsection - * @return string - * @throws Exception\DomainException + * The helper uses the bitwise '&' operator against the hex values of the + * render constants. This means that the flag can is "bitwised" value of + * the render constants. Examples: + * + * // render all links except glossary + * $flag = Links:RENDER_ALL ^ Links:RENDER_GLOSSARY; + * $helper->setRenderFlag($flag); + * + * // render only chapters and sections + * $flag = Links:RENDER_CHAPTER | Links:RENDER_SECTION; + * $helper->setRenderFlag($flag); + * + * // render only relations that are not native W3C relations + * $helper->setRenderFlag(Links:RENDER_CUSTOM); + * + * // render all relations (default) + * $helper->setRenderFlag(Links:RENDER_ALL); + * + * + * Note that custom relations can also be rendered directly using the + * {@link renderLink()} method. + * + * @param int $renderFlag + * @return Links */ - public function renderLink(AbstractPage $page, $attrib, $relation) + public function setRenderFlag($renderFlag) { - if (!in_array($attrib, array('rel', 'rev'))) { - throw new Exception\DomainException(sprintf( - 'Invalid relation attribute "%s", must be "rel" or "rev"', - $attrib - )); - } - - if (!$href = $page->getHref()) { - return ''; - } - - // TODO: add more attribs - // http://www.w3.org/TR/html401/struct/links.html#h-12.2 - $attribs = array( - $attrib => $relation, - 'href' => $href, - 'title' => $page->getLabel() - ); + $this->renderFlag = (int) $renderFlag; - return 'htmlAttribs($attribs) . - $this->getClosingBracket(); + return $this; } - // Zend\View\Helper\Navigation\Helper: - /** - * Renders helper - * - * Implements {@link HelperInterface::render()}. + * Returns the helper's render flag * - * @param AbstractContainer|string|null $container [optional] container to render. - * Default is to render the - * container registered in the - * helper. - * @return string + * @return int */ - public function render($container = null) + public function getRenderFlag() { - $this->parseContainer($container); - if (null === $container) { - $container = $this->getContainer(); - } - - $active = $this->findActive($container); - if ($active) { - $active = $active['page']; - } else { - // no active page - return ''; - } - - $output = ''; - $indent = $this->getIndent(); - $this->root = $container; - - $result = $this->findAllRelations($active, $this->getRenderFlag()); - foreach ($result as $attrib => $types) { - foreach ($types as $relation => $pages) { - foreach ($pages as $page) { - $r = $this->renderLink($page, $attrib, $relation); - if ($r) { - $output .= $indent . $r . self::EOL; - } - } - } - } - - $this->root = null; - - // return output (trim last newline by spec) - return strlen($output) ? rtrim($output, self::EOL) : ''; + return $this->renderFlag; } } diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php index ef46c297..c6570966 100644 --- a/src/Helper/Navigation/Menu.php +++ b/src/Helper/Navigation/Menu.php @@ -21,11 +21,11 @@ class Menu extends AbstractHelper { /** - * CSS class to use for the ul element + * Whether labels should be escaped * - * @var string + * @var bool */ - protected $ulClass = 'navigation'; + protected $escapeLabels = true; /** * Whether only active branch should be rendered @@ -35,11 +35,11 @@ class Menu extends AbstractHelper protected $onlyActiveBranch = false; /** - * Whether labels should be escaped + * Partial view script to use for rendering menu * - * @var bool + * @var string|array */ - protected $escapeLabels = true; + protected $partial = null; /** * Whether parents should be rendered when only rendering active branch @@ -49,11 +49,11 @@ class Menu extends AbstractHelper protected $renderParents = true; /** - * Partial view script to use for rendering menu + * CSS class to use for the ul element * - * @var string|array + * @var string */ - protected $partial = null; + protected $ulClass = 'navigation'; /** * View helper entry point: @@ -72,241 +72,31 @@ public function __invoke($container = null) } /** - * Sets CSS class to use for the first 'ul' element when rendering - * - * @param string $ulClass CSS class to set - * @return Menu - */ - public function setUlClass($ulClass) - { - if (is_string($ulClass)) { - $this->ulClass = $ulClass; - } - - return $this; - } - - /** - * Returns CSS class to use for the first 'ul' element when rendering - * - * @return string - */ - public function getUlClass() - { - return $this->ulClass; - } - - /** - * Sets a flag indicating whether only active branch should be rendered - * - * @param bool $flag [optional] render only active branch. - * @return Menu - */ - public function setOnlyActiveBranch($flag = true) - { - $this->onlyActiveBranch = (bool) $flag; - - return $this; - } - - /** - * Returns a flag indicating whether only active branch should be rendered - * - * By default, this value is false, meaning the entire menu will be - * be rendered. - * - * @return bool - */ - public function getOnlyActiveBranch() - { - return $this->onlyActiveBranch; - } - - /** - * Sets a flag indicating whether labels should be escaped - * - * @param bool $flag [optional] escape labels - * @return Menu - */ - public function escapeLabels($flag = true) - { - $this->escapeLabels = (bool) $flag; - - return $this; - } - - /** - * Enables/disables rendering of parents when only rendering active branch - * - * See {@link setOnlyActiveBranch()} for more information. - * - * @param bool $flag [optional] render parents when rendering active branch. - * @return Menu - */ - public function setRenderParents($flag = true) - { - $this->renderParents = (bool) $flag; - - return $this; - } - - /** - * Returns flag indicating whether parents should be rendered when rendering - * only the active branch - * - * By default, this value is true. - * - * @return bool - */ - public function getRenderParents() - { - return $this->renderParents; - } - - /** - * Sets which partial view script to use for rendering menu + * Renders menu * - * @param string|array $partial partial view script or null. If an array is - * given, it is expected to contain two - * values; the partial view script to use, - * and the module where the script can be - * found. - * @return Menu - */ - public function setPartial($partial) - { - if (null === $partial || is_string($partial) || is_array($partial)) { - $this->partial = $partial; - } - - return $this; - } - - /** - * Returns partial view script to use for rendering menu + * Implements {@link HelperInterface::render()}. * - * @return string|array|null - */ - public function getPartial() - { - return $this->partial; - } - - // Public methods: - - /** - * Returns an HTML string containing an 'a' element for the given page if - * the page's href is not empty, and a 'span' element if it is empty + * If a partial view is registered in the helper, the menu will be rendered + * using the given partial script. If no partial is registered, the menu + * will be rendered as an 'ul' element by the helper's internal method. * - * Overrides {@link AbstractHelper::htmlify()}. + * @see renderPartial() + * @see renderMenu() * - * @param AbstractPage $page page to generate HTML for - * @param bool $escapeLabel Whether or not to escape the label + * @param AbstractContainer $container [optional] container to render. Default is + * to render the container registered in the helper. * @return string */ - public function htmlify(AbstractPage $page, $escapeLabel = true) - { - // get label and title for translating - $label = $page->getLabel(); - $title = $page->getTitle(); - - // translate label and title? - if (null !== ($translator = $this->getTranslator())) { - $textDomain = $this->getTranslatorTextDomain(); - if (is_string($label) && !empty($label)) { - $label = $translator->translate($label, $textDomain); - } - if (is_string($title) && !empty($title)) { - $title = $translator->translate($title, $textDomain); - } - } - - // get attribs for element - $attribs = array( - 'id' => $page->getId(), - 'title' => $title, - 'class' => $page->getClass() - ); - - // does page have a href? - $href = $page->getHref(); - if ($href) { - $element = 'a'; - $attribs['href'] = $href; - $attribs['target'] = $page->getTarget(); - } else { - $element = 'span'; - } - - $html = '<' . $element . $this->htmlAttribs($attribs) . '>'; - if ($escapeLabel === true) { - $escaper = $this->view->plugin('escapeHtml'); - $html .= $escaper($label); - } else { - $html .= $label; - } - $html .= ''; - - return $html; - } - - /** - * Normalizes given render options - * - * @param array $options [optional] options to normalize - * @return array - */ - protected function normalizeOptions(array $options = array()) + public function render($container = null) { - if (isset($options['indent'])) { - $options['indent'] = $this->getWhitespace($options['indent']); - } else { - $options['indent'] = $this->getIndent(); - } - - if (isset($options['ulClass']) && $options['ulClass'] !== null) { - $options['ulClass'] = (string) $options['ulClass']; - } else { - $options['ulClass'] = $this->getUlClass(); - } - - if (array_key_exists('minDepth', $options)) { - if (null !== $options['minDepth']) { - $options['minDepth'] = (int) $options['minDepth']; - } - } else { - $options['minDepth'] = $this->getMinDepth(); - } - - if ($options['minDepth'] < 0 || $options['minDepth'] === null) { - $options['minDepth'] = 0; - } - - if (array_key_exists('maxDepth', $options)) { - if (null !== $options['maxDepth']) { - $options['maxDepth'] = (int) $options['maxDepth']; - } - } else { - $options['maxDepth'] = $this->getMaxDepth(); - } - - if (!isset($options['onlyActiveBranch'])) { - $options['onlyActiveBranch'] = $this->getOnlyActiveBranch(); - } - - if (!isset($options['escapeLabels'])) { - $options['escapeLabels'] = $this->escapeLabels; - } - - if (!isset($options['renderParents'])) { - $options['renderParents'] = $this->getRenderParents(); + $partial = $this->getPartial(); + if ($partial) { + return $this->renderPartial($container, $partial); } - return $options; + return $this->renderMenu($container); } - // Render methods: - /** * Renders the deepest active menu within [$minDepth, $maxDepth], (called * from {@link renderMenu()}) @@ -319,12 +109,13 @@ protected function normalizeOptions(array $options = array()) * @param bool $escapeLabels Whether or not to escape the labels * @return string */ - protected function renderDeepestMenu(AbstractContainer $container, - $ulClass, - $indent, - $minDepth, - $maxDepth, - $escapeLabels + protected function renderDeepestMenu( + AbstractContainer $container, + $ulClass, + $indent, + $minDepth, + $maxDepth, + $escapeLabels ) { if (!$active = $this->findActive($container, $minDepth - 1, $maxDepth)) { return ''; @@ -362,7 +153,52 @@ protected function renderDeepestMenu(AbstractContainer $container, } /** - * Renders a normal menu (called from {@link renderMenu()}) + * Renders helper + * + * Renders a HTML 'ul' for the given $container. If $container is not given, + * the container registered in the helper will be used. + * + * Available $options: + * + * + * @param AbstractContainer $container [optional] container to create menu from. + * Default is to use the container retrieved + * from {@link getContainer()}. + * @param array $options [optional] options for controlling rendering + * @return string + */ + public function renderMenu($container = null, array $options = array()) + { + $this->parseContainer($container); + if (null === $container) { + $container = $this->getContainer(); + } + + + $options = $this->normalizeOptions($options); + + if ($options['onlyActiveBranch'] && !$options['renderParents']) { + $html = $this->renderDeepestMenu($container, + $options['ulClass'], + $options['indent'], + $options['minDepth'], + $options['maxDepth'], + $options['escapeLabels']); + } else { + $html = $this->renderNormalMenu($container, + $options['ulClass'], + $options['indent'], + $options['minDepth'], + $options['maxDepth'], + $options['onlyActiveBranch'], + $options['escapeLabels']); + } + + return $html; + } + + /** + * Renders a normal menu (called from {@link renderMenu()}) * * @param AbstractContainer $container container to render * @param string $ulClass CSS class for first UL @@ -373,13 +209,14 @@ protected function renderDeepestMenu(AbstractContainer $container, * @param bool $escapeLabels Whether or not to escape the labels * @return string */ - protected function renderNormalMenu(AbstractContainer $container, - $ulClass, - $indent, - $minDepth, - $maxDepth, - $onlyActive, - $escapeLabels + protected function renderNormalMenu( + AbstractContainer $container, + $ulClass, + $indent, + $minDepth, + $maxDepth, + $onlyActive, + $escapeLabels ) { $html = ''; @@ -394,7 +231,7 @@ protected function renderNormalMenu(AbstractContainer $container, // create iterator $iterator = new RecursiveIteratorIterator($container, - RecursiveIteratorIterator::SELF_FIRST); + RecursiveIteratorIterator::SELF_FIRST); if (is_int($maxDepth)) { $iterator->setMaxDepth($maxDepth); } @@ -459,7 +296,7 @@ protected function renderNormalMenu(AbstractContainer $container, // render li tag and page $liClass = $isActive ? ' class="active"' : ''; $html .= $myIndent . ' ' . self::EOL - . $myIndent . ' ' . $this->htmlify($page, $escapeLabels) . self::EOL; + . $myIndent . ' ' . $this->htmlify($page, $escapeLabels) . self::EOL; // store as previous depth for next iteration $prevDepth = $depth; @@ -470,7 +307,7 @@ protected function renderNormalMenu(AbstractContainer $container, for ($i = $prevDepth+1; $i > 0; $i--) { $myIndent = $indent . str_repeat(' ', $i-1); $html .= $myIndent . '
  • ' . self::EOL - . $myIndent . '
' . self::EOL; + . $myIndent . '' . self::EOL; } $html = rtrim($html, self::EOL); } @@ -479,48 +316,62 @@ protected function renderNormalMenu(AbstractContainer $container, } /** - * Renders helper - * - * Renders a HTML 'ul' for the given $container. If $container is not given, - * the container registered in the helper will be used. - * - * Available $options: + * Renders the given $container by invoking the partial view helper * + * The container will simply be passed on as a model to the view script + * as-is, and will be available in the partial script as 'container', e.g. + * echo 'Number of pages: ', count($this->container);. * - * @param AbstractContainer $container [optional] container to create menu from. - * Default is to use the container retrieved - * from {@link getContainer()}. - * @param array $options [optional] options for controlling rendering + * @param AbstractContainer $container [optional] container to pass to view + * script. Default is to use the container + * registered in the helper. + * @param string|array $partial [optional] partial view script to use. + * Default is to use the partial + * registered in the helper. If an array + * is given, it is expected to contain two + * values; the partial view script to use, + * and the module where the script can be + * found. * @return string + * @throws Exception\RuntimeException if no partial provided + * @throws Exception\InvalidArgumentException if partial is invalid array */ - public function renderMenu($container = null, array $options = array()) + public function renderPartial($container = null, $partial = null) { $this->parseContainer($container); if (null === $container) { $container = $this->getContainer(); } + if (null === $partial) { + $partial = $this->getPartial(); + } - $options = $this->normalizeOptions($options); + if (empty($partial)) { + throw new Exception\RuntimeException( + 'Unable to render menu: No partial view script provided' + ); + } - if ($options['onlyActiveBranch'] && !$options['renderParents']) { - $html = $this->renderDeepestMenu($container, - $options['ulClass'], - $options['indent'], - $options['minDepth'], - $options['maxDepth'], - $options['escapeLabels']); - } else { - $html = $this->renderNormalMenu($container, - $options['ulClass'], - $options['indent'], - $options['minDepth'], - $options['maxDepth'], - $options['onlyActiveBranch'], - $options['escapeLabels']); + $model = array( + 'container' => $container + ); + + if (is_array($partial)) { + if (count($partial) != 2) { + throw new Exception\InvalidArgumentException( + 'Unable to render menu: A view partial supplied as ' + . 'an array must contain two values: partial view ' + . 'script and module where script can be found' + ); + } + + $partialHelper = $this->view->plugin('partial'); + return $partialHelper($partial[0], /*$partial[1], */$model); } - return $html; + $partialHelper = $this->view->plugin('partial'); + return $partialHelper($partial, $model); } /** @@ -553,9 +404,10 @@ public function renderMenu($container = null, array $options = array()) * {@link getIndent()}. * @return string */ - public function renderSubMenu(AbstractContainer $container = null, - $ulClass = null, - $indent = null + public function renderSubMenu( + AbstractContainer $container = null, + $ulClass = null, + $indent = null ) { return $this->renderMenu($container, array( 'indent' => $indent, @@ -569,89 +421,231 @@ public function renderSubMenu(AbstractContainer $container = null, } /** - * Renders the given $container by invoking the partial view helper + * Returns an HTML string containing an 'a' element for the given page if + * the page's href is not empty, and a 'span' element if it is empty * - * The container will simply be passed on as a model to the view script - * as-is, and will be available in the partial script as 'container', e.g. - * echo 'Number of pages: ', count($this->container);. + * Overrides {@link AbstractHelper::htmlify()}. * - * @param AbstractContainer $container [optional] container to pass to view - * script. Default is to use the container - * registered in the helper. - * @param string|array $partial [optional] partial view script to use. - * Default is to use the partial - * registered in the helper. If an array - * is given, it is expected to contain two - * values; the partial view script to use, - * and the module where the script can be - * found. + * @param AbstractPage $page page to generate HTML for + * @param bool $escapeLabel Whether or not to escape the label * @return string - * @throws Exception\RuntimeException if no partial provided - * @throws Exception\InvalidArgumentException if partial is invalid array */ - public function renderPartial($container = null, $partial = null) + public function htmlify(AbstractPage $page, $escapeLabel = true) { - $this->parseContainer($container); - if (null === $container) { - $container = $this->getContainer(); + // get label and title for translating + $label = $page->getLabel(); + $title = $page->getTitle(); + + // translate label and title? + if (null !== ($translator = $this->getTranslator())) { + $textDomain = $this->getTranslatorTextDomain(); + if (is_string($label) && !empty($label)) { + $label = $translator->translate($label, $textDomain); + } + if (is_string($title) && !empty($title)) { + $title = $translator->translate($title, $textDomain); + } } - if (null === $partial) { - $partial = $this->getPartial(); + // get attribs for element + $attribs = array( + 'id' => $page->getId(), + 'title' => $title, + 'class' => $page->getClass() + ); + + // does page have a href? + $href = $page->getHref(); + if ($href) { + $element = 'a'; + $attribs['href'] = $href; + $attribs['target'] = $page->getTarget(); + } else { + $element = 'span'; } - if (empty($partial)) { - throw new Exception\RuntimeException( - 'Unable to render menu: No partial view script provided' - ); + $html = '<' . $element . $this->htmlAttribs($attribs) . '>'; + if ($escapeLabel === true) { + $escaper = $this->view->plugin('escapeHtml'); + $html .= $escaper($label); + } else { + $html .= $label; } + $html .= ''; - $model = array( - 'container' => $container - ); + return $html; + } - if (is_array($partial)) { - if (count($partial) != 2) { - throw new Exception\InvalidArgumentException( - 'Unable to render menu: A view partial supplied as ' - . 'an array must contain two values: partial view ' - . 'script and module where script can be found' - ); + /** + * Normalizes given render options + * + * @param array $options [optional] options to normalize + * @return array + */ + protected function normalizeOptions(array $options = array()) + { + if (isset($options['indent'])) { + $options['indent'] = $this->getWhitespace($options['indent']); + } else { + $options['indent'] = $this->getIndent(); + } + + if (isset($options['ulClass']) && $options['ulClass'] !== null) { + $options['ulClass'] = (string) $options['ulClass']; + } else { + $options['ulClass'] = $this->getUlClass(); + } + + if (array_key_exists('minDepth', $options)) { + if (null !== $options['minDepth']) { + $options['minDepth'] = (int) $options['minDepth']; } + } else { + $options['minDepth'] = $this->getMinDepth(); + } - $partialHelper = $this->view->plugin('partial'); - return $partialHelper($partial[0], /*$partial[1], */$model); + if ($options['minDepth'] < 0 || $options['minDepth'] === null) { + $options['minDepth'] = 0; } - $partialHelper = $this->view->plugin('partial'); - return $partialHelper($partial, $model); + if (array_key_exists('maxDepth', $options)) { + if (null !== $options['maxDepth']) { + $options['maxDepth'] = (int) $options['maxDepth']; + } + } else { + $options['maxDepth'] = $this->getMaxDepth(); + } + + if (!isset($options['onlyActiveBranch'])) { + $options['onlyActiveBranch'] = $this->getOnlyActiveBranch(); + } + + if (!isset($options['escapeLabels'])) { + $options['escapeLabels'] = $this->escapeLabels; + } + + if (!isset($options['renderParents'])) { + $options['renderParents'] = $this->getRenderParents(); + } + + return $options; } - // Zend\View\Helper\Navigation\Helper: + /** + * Sets a flag indicating whether labels should be escaped + * + * @param bool $flag [optional] escape labels + * @return Menu + */ + public function escapeLabels($flag = true) + { + $this->escapeLabels = (bool) $flag; + return $this; + } /** - * Renders menu + * Sets a flag indicating whether only active branch should be rendered * - * Implements {@link HelperInterface::render()}. + * @param bool $flag [optional] render only active branch. + * @return Menu + */ + public function setOnlyActiveBranch($flag = true) + { + $this->onlyActiveBranch = (bool) $flag; + return $this; + } + + /** + * Returns a flag indicating whether only active branch should be rendered * - * If a partial view is registered in the helper, the menu will be rendered - * using the given partial script. If no partial is registered, the menu - * will be rendered as an 'ul' element by the helper's internal method. + * By default, this value is false, meaning the entire menu will be + * be rendered. * - * @see renderPartial() - * @see renderMenu() + * @return bool + */ + public function getOnlyActiveBranch() + { + return $this->onlyActiveBranch; + } + + /** + * Sets which partial view script to use for rendering menu * - * @param AbstractContainer $container [optional] container to render. Default is - * to render the container registered in the helper. - * @return string + * @param string|array $partial partial view script or null. If an array is + * given, it is expected to contain two + * values; the partial view script to use, + * and the module where the script can be + * found. + * @return Menu */ - public function render($container = null) + public function setPartial($partial) { - $partial = $this->getPartial(); - if ($partial) { - return $this->renderPartial($container, $partial); + if (null === $partial || is_string($partial) || is_array($partial)) { + $this->partial = $partial; } - return $this->renderMenu($container); + return $this; + } + + /** + * Returns partial view script to use for rendering menu + * + * @return string|array|null + */ + public function getPartial() + { + return $this->partial; + } + + /** + * Enables/disables rendering of parents when only rendering active branch + * + * See {@link setOnlyActiveBranch()} for more information. + * + * @param bool $flag [optional] render parents when rendering active branch. + * @return Menu + */ + public function setRenderParents($flag = true) + { + $this->renderParents = (bool) $flag; + return $this; + } + + /** + * Returns flag indicating whether parents should be rendered when rendering + * only the active branch + * + * By default, this value is true. + * + * @return bool + */ + public function getRenderParents() + { + return $this->renderParents; + } + + /** + * Sets CSS class to use for the first 'ul' element when rendering + * + * @param string $ulClass CSS class to set + * @return Menu + */ + public function setUlClass($ulClass) + { + if (is_string($ulClass)) { + $this->ulClass = $ulClass; + } + + return $this; + } + + /** + * Returns CSS class to use for the first 'ul' element when rendering + * + * @return string + */ + public function getUlClass() + { + return $this->ulClass; } } diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index 1e58a7e0..f8243de2 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -47,11 +47,18 @@ class Sitemap extends AbstractHelper protected $formatOutput = false; /** - * Whether the XML declaration should be included in XML output + * Server url * - * @var bool + * @var string */ - protected $useXmlDeclaration = true; + protected $serverUrl; + + /** + * List of urls in the sitemap + * + * @var array + */ + protected $urls = array(); /** * Whether sitemap should be validated using Zend\Validate\Sitemap\* @@ -68,18 +75,11 @@ class Sitemap extends AbstractHelper protected $useSchemaValidation = false; /** - * Server url - * - * @var string - */ - protected $serverUrl; - - /** - * List of urls in the sitemap + * Whether the XML declaration should be included in XML output * - * @var array + * @var bool */ - protected $urls = array(); + protected $useXmlDeclaration = true; /** * Helper entry point @@ -97,192 +97,22 @@ public function __invoke($container = null) } /** - * Sets whether XML output should be formatted - * - * @param bool $formatOutput - * @return Sitemap - */ - public function setFormatOutput($formatOutput = true) - { - $this->formatOutput = (bool) $formatOutput; - - return $this; - } - - /** - * Returns whether XML output should be formatted - * - * @return bool - */ - public function getFormatOutput() - { - return $this->formatOutput; - } - - /** - * Sets whether the XML declaration should be used in output - * - * @param bool $useXmlDecl - * @return Sitemap - */ - public function setUseXmlDeclaration($useXmlDecl) - { - $this->useXmlDeclaration = (bool) $useXmlDecl; - - return $this; - } - - /** - * Returns whether the XML declaration should be used in output - * - * @return bool - */ - public function getUseXmlDeclaration() - { - return $this->useXmlDeclaration; - } - - /** - * Sets whether sitemap should be validated using Zend\Validate\Sitemap_* - * - * @param bool $useSitemapValidators - * @return Sitemap - */ - public function setUseSitemapValidators($useSitemapValidators) - { - $this->useSitemapValidators = (bool) $useSitemapValidators; - - return $this; - } - - /** - * Returns whether sitemap should be validated using Zend\Validate\Sitemap_* - * - * @return bool - */ - public function getUseSitemapValidators() - { - return $this->useSitemapValidators; - } - - /** - * Sets whether sitemap should be schema validated when generated - * - * @param bool $schemaValidation - * @return Sitemap - */ - public function setUseSchemaValidation($schemaValidation) - { - $this->useSchemaValidation = (bool) $schemaValidation; - - return $this; - } - - /** - * Returns true if sitemap should be schema validated when generated - * - * @return bool - */ - public function getUseSchemaValidation() - { - return $this->useSchemaValidation; - } - - /** - * Sets server url (scheme and host-related stuff without request URI) - * - * E.g. http://www.example.com - * - * @param string $serverUrl - * @return Sitemap - * @throws Exception\InvalidArgumentException - */ - public function setServerUrl($serverUrl) - { - $uri = Uri\UriFactory::factory($serverUrl); - $uri->setFragment(''); - $uri->setPath(''); - $uri->setQuery(''); - - if ($uri->isValid()) { - $this->serverUrl = $uri->toString(); - } else { - throw new Exception\InvalidArgumentException(sprintf( - 'Invalid server URL: "%s"', - $serverUrl - )); - } - - return $this; - } - - /** - * Returns server URL - * - * @return string - */ - public function getServerUrl() - { - if (!isset($this->serverUrl)) { - $serverUrlHelper = $this->getView()->plugin('serverUrl'); - $this->serverUrl = $serverUrlHelper(); - } - - return $this->serverUrl; - } - - // Helper methods: - - /** - * Escapes string for XML usage + * Renders helper * - * @param string $string - * @return string - */ - protected function xmlEscape($string) - { - $escaper = $this->view->plugin('escapeHtml'); - return $escaper($string); - } - - // Public methods: - - /** - * Returns an escaped absolute URL for the given page + * Implements {@link HelperInterface::render()}. * - * @param AbstractPage $page + * @param AbstractContainer $container [optional] container to render. Default is + * to render the container registered in the helper. * @return string */ - public function url(AbstractPage $page) + public function render($container = null) { - $href = $page->getHref(); - - if (!isset($href{0})) { - // no href - return ''; - } elseif ($href{0} == '/') { - // href is relative to root; use serverUrl helper - $url = $this->getServerUrl() . $href; - } elseif (preg_match('/^[a-z]+:/im', (string) $href)) { - // scheme is given in href; assume absolute URL already - $url = (string) $href; - } else { - // href is relative to current document; use url helpers - $basePathHelper = $this->getView()->plugin('basepath'); - $curDoc = $basePathHelper(); - $curDoc = ('/' == $curDoc) ? '' : trim($curDoc, '/'); - $url = rtrim($this->getServerUrl(), '/') . '/' - . $curDoc - . (empty($curDoc) ? '' : '/') . $href; - } - - if (! in_array($url, $this->urls)) { - - $this->urls[] = $url; - return $this->xmlEscape($url); - } + $dom = $this->getDomSitemap($container); + $xml = $this->getUseXmlDeclaration() ? + $dom->saveXML() : + $dom->saveXML($dom->documentElement); - return null; + return rtrim($xml, PHP_EOL); } /** @@ -369,7 +199,7 @@ public function getDomSitemap(AbstractContainer $container = null) // put url in 'loc' element $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, - 'loc', $url)); + 'loc', $url)); // add 'lastmod' element if a valid lastmod is set in page if (isset($page->lastmod)) { @@ -430,24 +260,184 @@ public function getDomSitemap(AbstractContainer $container = null) return $dom; } - // Zend_View_Helper_Navigation_Helper: + /** + * Returns an escaped absolute URL for the given page + * + * @param AbstractPage $page + * @return string + */ + public function url(AbstractPage $page) + { + $href = $page->getHref(); + + if (!isset($href{0})) { + // no href + return ''; + } elseif ($href{0} == '/') { + // href is relative to root; use serverUrl helper + $url = $this->getServerUrl() . $href; + } elseif (preg_match('/^[a-z]+:/im', (string) $href)) { + // scheme is given in href; assume absolute URL already + $url = (string) $href; + } else { + // href is relative to current document; use url helpers + $basePathHelper = $this->getView()->plugin('basepath'); + $curDoc = $basePathHelper(); + $curDoc = ('/' == $curDoc) ? '' : trim($curDoc, '/'); + $url = rtrim($this->getServerUrl(), '/') . '/' + . $curDoc + . (empty($curDoc) ? '' : '/') . $href; + } + + if (! in_array($url, $this->urls)) { + + $this->urls[] = $url; + return $this->xmlEscape($url); + } + + return null; + } /** - * Renders helper + * Escapes string for XML usage * - * Implements {@link HelperInterface::render()}. + * @param string $string + * @return string + */ + protected function xmlEscape($string) + { + $escaper = $this->view->plugin('escapeHtml'); + return $escaper($string); + } + + /** + * Sets whether XML output should be formatted + * + * @param bool $formatOutput + * @return Sitemap + */ + public function setFormatOutput($formatOutput = true) + { + $this->formatOutput = (bool) $formatOutput; + return $this; + } + + /** + * Returns whether XML output should be formatted + * + * @return bool + */ + public function getFormatOutput() + { + return $this->formatOutput; + } + + /** + * Sets server url (scheme and host-related stuff without request URI) + * + * E.g. http://www.example.com + * + * @param string $serverUrl + * @return Sitemap + * @throws Exception\InvalidArgumentException + */ + public function setServerUrl($serverUrl) + { + $uri = Uri\UriFactory::factory($serverUrl); + $uri->setFragment(''); + $uri->setPath(''); + $uri->setQuery(''); + + if ($uri->isValid()) { + $this->serverUrl = $uri->toString(); + } else { + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid server URL: "%s"', + $serverUrl + )); + } + + return $this; + } + + /** + * Returns server URL * - * @param AbstractContainer $container [optional] container to render. Default is - * to render the container registered in the helper. * @return string */ - public function render($container = null) + public function getServerUrl() { - $dom = $this->getDomSitemap($container); - $xml = $this->getUseXmlDeclaration() ? - $dom->saveXML() : - $dom->saveXML($dom->documentElement); + if (!isset($this->serverUrl)) { + $serverUrlHelper = $this->getView()->plugin('serverUrl'); + $this->serverUrl = $serverUrlHelper(); + } - return rtrim($xml, PHP_EOL); + return $this->serverUrl; + } + + /** + * Sets whether sitemap should be validated using Zend\Validate\Sitemap_* + * + * @param bool $useSitemapValidators + * @return Sitemap + */ + public function setUseSitemapValidators($useSitemapValidators) + { + $this->useSitemapValidators = (bool) $useSitemapValidators; + return $this; + } + + /** + * Returns whether sitemap should be validated using Zend\Validate\Sitemap_* + * + * @return bool + */ + public function getUseSitemapValidators() + { + return $this->useSitemapValidators; + } + + /** + * Sets whether sitemap should be schema validated when generated + * + * @param bool $schemaValidation + * @return Sitemap + */ + public function setUseSchemaValidation($schemaValidation) + { + $this->useSchemaValidation = (bool) $schemaValidation; + return $this; + } + + /** + * Returns true if sitemap should be schema validated when generated + * + * @return bool + */ + public function getUseSchemaValidation() + { + return $this->useSchemaValidation; + } + + /** + * Sets whether the XML declaration should be used in output + * + * @param bool $useXmlDecl + * @return Sitemap + */ + public function setUseXmlDeclaration($useXmlDecl) + { + $this->useXmlDeclaration = (bool) $useXmlDecl; + return $this; + } + + /** + * Returns whether the XML declaration should be used in output + * + * @return bool + */ + public function getUseXmlDeclaration() + { + return $this->useXmlDeclaration; } } diff --git a/src/Helper/PaginationControl.php b/src/Helper/PaginationControl.php index b0049cf2..b35cd682 100644 --- a/src/Helper/PaginationControl.php +++ b/src/Helper/PaginationControl.php @@ -16,18 +16,18 @@ class PaginationControl extends AbstractHelper { /** - * Default view partial + * Default Scrolling Style * - * @var string|array + * @var string */ - protected static $defaultViewPartial = null; + protected static $defaultScrollingStyle = 'sliding'; /** - * Default Scrolling Style + * Default view partial * - * @var string + * @var string|array */ - protected static $defaultScrollingStyle = 'sliding'; + protected static $defaultViewPartial = null; /** * Render the provided pages. This checks if $view->paginator is set and, @@ -90,42 +90,42 @@ public function __invoke(Paginator\Paginator $paginator = null, $scrollingStyle } /** - * Sets the default view partial. + * Sets the default Scrolling Style * - * @param string|array $partial View partial + * @param string $style string 'all' | 'elastic' | 'sliding' | 'jumping' */ - public static function setDefaultViewPartial($partial) + public static function setDefaultScrollingStyle($style) { - static::$defaultViewPartial = $partial; + static::$defaultScrollingStyle = $style; } /** - * Gets the default view partial + * Gets the default scrolling style * - * @return string|array + * @return string */ - public static function getDefaultViewPartial() + public static function getDefaultScrollingStyle() { - return static::$defaultViewPartial; + return static::$defaultScrollingStyle; } - /** - * Gets the default scrolling style + /** + * Sets the default view partial. * - * @return string + * @param string|array $partial View partial */ - public static function getDefaultScrollingStyle() + public static function setDefaultViewPartial($partial) { - return static::$defaultScrollingStyle; + static::$defaultViewPartial = $partial; } /** - * Sets the default Scrolling Style + * Gets the default view partial * - * @param string $style string 'all' | 'elastic' | 'sliding' | 'jumping' + * @return string|array */ - public static function setDefaultScrollingStyle($style) + public static function getDefaultViewPartial() { - static::$defaultScrollingStyle = $style; + return static::$defaultViewPartial; } } diff --git a/src/Helper/Placeholder/Container/AbstractContainer.php b/src/Helper/Placeholder/Container/AbstractContainer.php index ee4d7766..6ff12bf3 100644 --- a/src/Helper/Placeholder/Container/AbstractContainer.php +++ b/src/Helper/Placeholder/Container/AbstractContainer.php @@ -21,7 +21,7 @@ abstract class AbstractContainer extends \ArrayObject * * @const string */ - const SET = 'SET'; + const SET = 'SET'; /** * Whether or not to append contents to placeholder @@ -38,25 +38,25 @@ abstract class AbstractContainer extends \ArrayObject const PREPEND = 'PREPEND'; /** - * What text to prefix the placeholder with when rendering + * Key to which to capture content * * @var string */ - protected $prefix = ''; + protected $captureKey; /** - * What text to append the placeholder with when rendering + * Whether or not we're already capturing for this given container * - * @var string + * @var bool */ - protected $postfix = ''; + protected $captureLock = false; /** - * What string to use between individual items in the placeholder when rendering + * What type of capture (overwrite (set), append, prepend) to use * * @var string */ - protected $separator = ''; + protected $captureType; /** * What string to use as the indentation of output, this will typically be spaces. Eg: ' ' @@ -66,25 +66,25 @@ abstract class AbstractContainer extends \ArrayObject protected $indent = ''; /** - * Whether or not we're already capturing for this given container + * What text to append the placeholder with when rendering * - * @var bool + * @var string */ - protected $captureLock = false; + protected $postfix = ''; /** - * What type of capture (overwrite (set), append, prepend) to use + * What text to prefix the placeholder with when rendering * * @var string */ - protected $captureType; + protected $prefix = ''; /** - * Key to which to capture content + * What string to use between individual items in the placeholder when rendering * * @var string */ - protected $captureKey; + protected $separator = ''; /** * Constructor - This is needed so that we can attach a class member as the ArrayObject container @@ -95,160 +95,35 @@ public function __construct() } /** - * Set a single value - * - * @param mixed $value - * @return void - */ - public function set($value) - { - $this->exchangeArray(array($value)); - - return $this; - } - - /** - * Prepend a value to the top of the container - * - * @param mixed $value - * @return void - */ - public function prepend($value) - { - $values = $this->getArrayCopy(); - array_unshift($values, $value); - $this->exchangeArray($values); - - return $this; - } - - /** - * Retrieve container value - * - * If single element registered, returns that element; otherwise, - * serializes to array. - * - * @return mixed - */ - public function getValue() - { - if (1 == count($this)) { - $keys = $this->getKeys(); - $key = array_shift($keys); - return $this[$key]; - } - - return $this->getArrayCopy(); - } - - /** - * Set prefix for __toString() serialization - * - * @param string $prefix - * @return AbstractContainer - */ - public function setPrefix($prefix) - { - $this->prefix = (string) $prefix; - - return $this; - } - - /** - * Retrieve prefix - * - * @return string - */ - public function getPrefix() - { - return $this->prefix; - } - - /** - * Set postfix for __toString() serialization - * - * @param string $postfix - * @return AbstractContainer - */ - public function setPostfix($postfix) - { - $this->postfix = (string) $postfix; - - return $this; - } - - /** - * Retrieve postfix - * - * @return string - */ - public function getPostfix() - { - return $this->postfix; - } - - /** - * Set separator for __toString() serialization - * - * Used to implode elements in container - * - * @param string $separator - * @return AbstractContainer - */ - public function setSeparator($separator) - { - $this->separator = (string) $separator; - - return $this; - } - - /** - * Retrieve separator + * Serialize object to string * * @return string */ - public function getSeparator() - { - return $this->separator; - } - - /** - * Set the indentation string for __toString() serialization, - * optionally, if a number is passed, it will be the number of spaces - * - * @param string|int $indent - * @return AbstractContainer - */ - public function setIndent($indent) + public function __toString() { - $this->indent = $this->getWhitespace($indent); - - return $this; + return $this->toString(); } /** - * Retrieve indentation + * Render the placeholder * + * @param null|int|string $indent * @return string */ - public function getIndent() + public function toString($indent = null) { - return $this->indent; - } + $indent = ($indent !== null) + ? $this->getWhitespace($indent) + : $this->getIndent(); - /** - * Retrieve whitespace representation of $indent - * - * @param int|string $indent - * @return string - */ - public function getWhitespace($indent) - { - if (is_int($indent)) { - $indent = str_repeat(' ', $indent); - } + $items = $this->getArrayCopy(); + $return = $indent + . $this->getPrefix() + . implode($this->getSeparator(), $items) + . $this->getPostfix(); + $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return); - return (string) $indent; + return $return; } /** @@ -333,6 +208,68 @@ public function getKeys() return array_keys($array); } + /** + * Retrieve container value + * + * If single element registered, returns that element; otherwise, + * serializes to array. + * + * @return mixed + */ + public function getValue() + { + if (1 == count($this)) { + $keys = $this->getKeys(); + $key = array_shift($keys); + return $this[$key]; + } + + return $this->getArrayCopy(); + } + + /** + * Retrieve whitespace representation of $indent + * + * @param int|string $indent + * @return string + */ + public function getWhitespace($indent) + { + if (is_int($indent)) { + $indent = str_repeat(' ', $indent); + } + + return (string) $indent; + } + + /** + * Set a single value + * + * @param mixed $value + * @return void + */ + public function set($value) + { + $this->exchangeArray(array($value)); + + return $this; + } + + /** + * Prepend a value to the top of the container + * + * @param mixed $value + * @return void + */ + public function prepend($value) + { + $values = $this->getArrayCopy(); + array_unshift($values, $value); + $this->exchangeArray($values); + + return $this; + } + /** * Next Index as defined by the PHP manual * @@ -349,34 +286,93 @@ public function nextIndex() } /** - * Render the placeholder + * Set the indentation string for __toString() serialization, + * optionally, if a number is passed, it will be the number of spaces + * + * @param string|int $indent + * @return AbstractContainer + */ + public function setIndent($indent) + { + $this->indent = $this->getWhitespace($indent); + return $this; + } + + /** + * Retrieve indentation * - * @param null|int|string $indent * @return string */ - public function toString($indent = null) + public function getIndent() { - $indent = ($indent !== null) - ? $this->getWhitespace($indent) - : $this->getIndent(); + return $this->indent; + } - $items = $this->getArrayCopy(); - $return = $indent - . $this->getPrefix() - . implode($this->getSeparator(), $items) - . $this->getPostfix(); - $return = preg_replace("/(\r\n?|\n)/", '$1' . $indent, $return); + /** + * Set postfix for __toString() serialization + * + * @param string $postfix + * @return AbstractContainer + */ + public function setPostfix($postfix) + { + $this->postfix = (string) $postfix; + return $this; + } - return $return; + /** + * Retrieve postfix + * + * @return string + */ + public function getPostfix() + { + return $this->postfix; } /** - * Serialize object to string + * Set prefix for __toString() serialization + * + * @param string $prefix + * @return AbstractContainer + */ + public function setPrefix($prefix) + { + $this->prefix = (string) $prefix; + return $this; + } + + /** + * Retrieve prefix * * @return string */ - public function __toString() + public function getPrefix() { - return $this->toString(); + return $this->prefix; + } + + /** + * Set separator for __toString() serialization + * + * Used to implode elements in container + * + * @param string $separator + * @return AbstractContainer + */ + public function setSeparator($separator) + { + $this->separator = (string) $separator; + return $this; + } + + /** + * Retrieve separator + * + * @return string + */ + public function getSeparator() + { + return $this->separator; } } diff --git a/src/Helper/Placeholder/Container/AbstractStandalone.php b/src/Helper/Placeholder/Container/AbstractStandalone.php index 7a6f2c80..bae1b217 100644 --- a/src/Helper/Placeholder/Container/AbstractStandalone.php +++ b/src/Helper/Placeholder/Container/AbstractStandalone.php @@ -9,18 +9,29 @@ namespace Zend\View\Helper\Placeholder\Container; +use ArrayAccess; +use Countable; +use IteratorAggregate; use Zend\Escaper\Escaper; use Zend\View\Exception; +use Zend\View\Helper\AbstractHelper; use Zend\View\Helper\Placeholder\Registry; use Zend\View\Renderer\RendererInterface; /** * Base class for targeted placeholder helpers */ -abstract class AbstractStandalone - extends \Zend\View\Helper\AbstractHelper - implements \IteratorAggregate, \Countable, \ArrayAccess +abstract class AbstractStandalone extends AbstractHelper + implements IteratorAggregate, Countable, ArrayAccess { + /** + * Flag whether to automatically escape output, must also be + * enforced in the child class if __toString/toString is overridden + * + * @var bool + */ + protected $autoEscape = true; + /** * @var AbstractContainer */ @@ -43,14 +54,6 @@ abstract class AbstractStandalone */ protected $regKey; - /** - * Flag whether to automatically escape output, must also be - * enforced in the child class if __toString/toString is overridden - * - * @var bool - */ - protected $autoEscape = true; - /** * Constructor */ @@ -61,81 +64,103 @@ public function __construct() } /** - * Retrieve registry + * Overload * - * @return Registry + * Proxy to container methods + * + * @param string $method + * @param array $args + * @throws Exception\BadMethodCallException + * @return mixed */ - public function getRegistry() + public function __call($method, $args) { - return $this->registry; + $container = $this->getContainer(); + if (method_exists($container, $method)) { + $return = call_user_func_array(array($container, $method), $args); + if ($return === $container) { + // If the container is returned, we really want the current object + return $this; + } + return $return; + } + + throw new Exception\BadMethodCallException('Method "' . $method . '" does not exist'); } /** - * Set registry object + * Overloading: set property value * - * @param Registry $registry - * @return AbstractStandalone + * @param string $key + * @param mixed $value + * @return void */ - public function setRegistry(Registry $registry) + public function __set($key, $value) { - $this->registry = $registry; - - return $this; + $container = $this->getContainer(); + $container[$key] = $value; } /** - * Set Escaper instance + * Overloading: retrieve property * - * @param Escaper $escaper - * @return AbstractStandalone + * @param string $key + * @return mixed */ - public function setEscaper(Escaper $escaper) + public function __get($key) { - $encoding = $escaper->getEncoding(); - $this->escapers[$encoding] = $escaper; + $container = $this->getContainer(); + if (isset($container[$key])) { + return $container[$key]; + } - return $this; + return null; } /** - * Get Escaper instance + * Overloading: check if property is set * - * Lazy-loads one if none available + * @param string $key + * @return bool + */ + public function __isset($key) + { + $container = $this->getContainer(); + return isset($container[$key]); + } + + /** + * Overloading: unset property * - * @param string|null $enc Encoding to use - * @return mixed + * @param string $key + * @return void */ - public function getEscaper($enc = 'UTF-8') + public function __unset($key) { - $enc = strtolower($enc); - if (!isset($this->escapers[$enc])) { - $this->setEscaper(new Escaper($enc)); + $container = $this->getContainer(); + if (isset($container[$key])) { + unset($container[$key]); } - - return $this->escapers[$enc]; } /** - * Set whether or not auto escaping should be used + * Cast to string representation * - * @param bool $autoEscape whether or not to auto escape output - * @return AbstractStandalone + * @return string */ - public function setAutoEscape($autoEscape = true) + public function __toString() { - $this->autoEscape = ($autoEscape) ? true : false; - - return $this; + return $this->toString(); } /** - * Return whether autoEscaping is enabled or disabled + * String representation * - * return bool + * @return string */ - public function getAutoEscape() + public function toString() { - return $this->autoEscape; + return $this->getContainer()->toString(); } /** @@ -146,140 +171,113 @@ public function getAutoEscape() */ protected function escape($string) { - if ($this->view instanceof RendererInterface - && method_exists($this->view, 'getEncoding') + if ($this->getView() instanceof RendererInterface + && method_exists($this->getView(), 'getEncoding') ) { - $enc = $this->view->getEncoding(); - $escaper = $this->view->plugin('escapeHtml'); + $enc = $this->getView()->getEncoding(); + $escaper = $this->getView()->plugin('escapeHtml'); return $escaper((string) $string); } - $escaper = $this->getEscaper(); - - return $escaper->escapeHtml((string) $string); + return $this->getEscaper()->escapeHtml((string) $string); } /** - * Set container on which to operate + * Set whether or not auto escaping should be used * - * @param AbstractContainer $container + * @param bool $autoEscape whether or not to auto escape output * @return AbstractStandalone */ - public function setContainer(AbstractContainer $container) + public function setAutoEscape($autoEscape = true) { - $this->container = $container; - + $this->autoEscape = ($autoEscape) ? true : false; return $this; } /** - * Retrieve placeholder container + * Return whether autoEscaping is enabled or disabled * - * @return AbstractContainer + * return bool */ - public function getContainer() + public function getAutoEscape() { - return $this->container; + return $this->autoEscape; } /** - * Overloading: set property value + * Set container on which to operate * - * @param string $key - * @param mixed $value - * @return void + * @param AbstractContainer $container + * @return AbstractStandalone */ - public function __set($key, $value) + public function setContainer(AbstractContainer $container) { - $container = $this->getContainer(); - $container[$key] = $value; + $this->container = $container; + return $this; } /** - * Overloading: retrieve property + * Retrieve placeholder container * - * @param string $key - * @return mixed + * @return AbstractContainer */ - public function __get($key) + public function getContainer() { - $container = $this->getContainer(); - if (isset($container[$key])) { - return $container[$key]; - } - - return null; + return $this->container; } /** - * Overloading: check if property is set + * Set Escaper instance * - * @param string $key - * @return bool + * @param Escaper $escaper + * @return AbstractStandalone */ - public function __isset($key) + public function setEscaper(Escaper $escaper) { - $container = $this->getContainer(); - return isset($container[$key]); - } + $encoding = $escaper->getEncoding(); + $this->escapers[$encoding] = $escaper; - /** - * Overloading: unset property - * - * @param string $key - * @return void - */ - public function __unset($key) - { - $container = $this->getContainer(); - if (isset($container[$key])) { - unset($container[$key]); - } + return $this; } /** - * Overload + * Get Escaper instance * - * Proxy to container methods + * Lazy-loads one if none available * - * @param string $method - * @param array $args - * @throws Exception\BadMethodCallException + * @param string|null $enc Encoding to use * @return mixed */ - public function __call($method, $args) + public function getEscaper($enc = 'UTF-8') { - $container = $this->getContainer(); - if (method_exists($container, $method)) { - $return = call_user_func_array(array($container, $method), $args); - if ($return === $container) { - // If the container is returned, we really want the current object - return $this; - } - return $return; + $enc = strtolower($enc); + if (!isset($this->escapers[$enc])) { + $this->setEscaper(new Escaper($enc)); } - throw new Exception\BadMethodCallException('Method "' . $method . '" does not exist'); + return $this->escapers[$enc]; } /** - * String representation + * Set registry object * - * @return string + * @param Registry $registry + * @return AbstractStandalone */ - public function toString() + public function setRegistry(Registry $registry) { - return $this->getContainer()->toString(); + $this->registry = $registry; + return $this; } /** - * Cast to string representation + * Retrieve registry * - * @return string + * @return Registry */ - public function __toString() + public function getRegistry() { - return $this->toString(); + return $this->registry; } /** @@ -290,7 +288,6 @@ public function __toString() public function count() { $container = $this->getContainer(); - return count($container); } @@ -342,7 +339,7 @@ public function offsetUnset($offset) /** * IteratorAggregate: get Iterator * - * @return \Iterator + * @return Iterator */ public function getIterator() { diff --git a/src/Helper/Placeholder/Registry.php b/src/Helper/Placeholder/Registry.php index 777ad604..990f624b 100644 --- a/src/Helper/Placeholder/Registry.php +++ b/src/Helper/Placeholder/Registry.php @@ -64,19 +64,18 @@ public static function unsetRegistry() } /** - * createContainer + * Set the container for an item in the registry * - * @param string $key - * @param array $value - * @return Container\AbstractContainer + * @param string $key + * @param Container\AbstractContainer $container + * @return Registry */ - public function createContainer($key, array $value = array()) + public function setContainer($key, Container\AbstractContainer $container) { $key = (string) $key; + $this->items[$key] = $container; - $this->items[$key] = new $this->containerClass($value); - - return $this->items[$key]; + return $this; } /** @@ -111,18 +110,19 @@ public function containerExists($key) } /** - * Set the container for an item in the registry + * createContainer * - * @param string $key - * @param Container\AbstractContainer $container - * @return Registry + * @param string $key + * @param array $value + * @return Container\AbstractContainer */ - public function setContainer($key, Container\AbstractContainer $container) + public function createContainer($key, array $value = array()) { $key = (string) $key; - $this->items[$key] = $container; - return $this; + $this->items[$key] = new $this->containerClass($value); + + return $this->items[$key]; } /** diff --git a/src/Helper/RenderChildModel.php b/src/Helper/RenderChildModel.php index 6663758c..62fab196 100644 --- a/src/Helper/RenderChildModel.php +++ b/src/Helper/RenderChildModel.php @@ -120,8 +120,12 @@ protected function getCurrent() */ protected function getViewModelHelper() { - if (null === $this->viewModelHelper) { - $this->viewModelHelper = $this->getView()->plugin('view_model'); + if ($this->viewModelHelper) { + return $this->viewModelHelper; + } + + if (method_exists($this->getView(), 'plugin')) { + $this->viewModelHelper = $this->view->plugin('view_model'); } return $this->viewModelHelper; diff --git a/src/Helper/ServerUrl.php b/src/Helper/ServerUrl.php index a2fe3cea..4cc0e721 100644 --- a/src/Helper/ServerUrl.php +++ b/src/Helper/ServerUrl.php @@ -14,6 +14,13 @@ */ class ServerUrl extends AbstractHelper { + /** + * Host (including port) + * + * @var string + */ + protected $host; + /** * Port * @@ -28,13 +35,6 @@ class ServerUrl extends AbstractHelper */ protected $scheme; - /** - * Host (including port) - * - * @var string - */ - protected $host; - /** * Whether or not to query proxy servers for address * @@ -66,110 +66,6 @@ public function __invoke($requestUri = null) return $this->getScheme() . '://' . $this->getHost() . $path; } - /** - * Returns host - * - * @return string - */ - public function getHost() - { - if (null === $this->host) { - $this->detectHost(); - } - - return $this->host; - } - - /** - * Sets host - * - * @param string $host - * @return ServerUrl - */ - public function setHost($host) - { - $port = $this->getPort(); - $scheme = $this->getScheme(); - - if (($scheme == 'http' && (null === $port || $port == 80)) - || ($scheme == 'https' && (null === $port || $port == 443)) - ) { - $this->host = $host; - return $this; - } - - $this->host = $host . ':' . $port; - - return $this; - } - - /** - * Returns scheme (typically http or https) - * - * @return string - */ - public function getScheme() - { - if (null === $this->scheme) { - $this->detectScheme(); - } - - return $this->scheme; - } - - /** - * Sets scheme (typically http or https) - * - * @param string $scheme - * @return ServerUrl - */ - public function setScheme($scheme) - { - $this->scheme = $scheme; - - return $this; - } - - /** - * Retrieve the server port - * - * @return int|null - */ - public function getPort() - { - if (null === $this->port) { - $this->detectPort(); - } - - return $this->port; - } - - /** - * Set server port - * - * @param int $port - * @return ServerUrl - */ - public function setPort($port) - { - $this->port = (int) $port; - - return $this; - } - - /** - * Set flag indicating whether or not to query proxy servers - * - * @param bool $useProxy - * @return ServerUrl - */ - public function setUseProxy($useProxy = false) - { - $this->useProxy = (bool) $useProxy; - - return $this; - } - /** * Detect the host based on headers * @@ -205,31 +101,20 @@ protected function detectHost() } /** - * Detect if a proxy is in use, and, if so, set the host based on it + * Detect the port * - * @return bool + * @return null */ - protected function setHostFromProxy() + protected function detectPort() { - if (!$this->useProxy) { - return false; - } - - if (!isset($_SERVER['HTTP_X_FORWARDED_HOST']) || empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { - return false; + if ($this->setPortFromProxy()) { + return; } - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; - if (strpos($host, ',') !== false) { - $hosts = explode(',', $host); - $host = trim(array_pop($hosts)); - } - if (empty($host)) { - return false; + if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']) { + $this->setPort($_SERVER['SERVER_PORT']); + return; } - $this->setHost($host); - - return true; } /** @@ -258,20 +143,52 @@ protected function detectScheme() } /** - * Detect the port + * Detect if a proxy is in use, and, if so, set the host based on it * - * @return null + * @return bool */ - protected function detectPort() + protected function setHostFromProxy() { - if ($this->setPortFromProxy()) { - return; + if (!$this->useProxy) { + return false; } - if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']) { - $this->setPort($_SERVER['SERVER_PORT']); - return; + if (!isset($_SERVER['HTTP_X_FORWARDED_HOST']) || empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { + return false; + } + + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; + if (strpos($host, ',') !== false) { + $hosts = explode(',', $host); + $host = trim(array_pop($hosts)); + } + if (empty($host)) { + return false; + } + $this->setHost($host); + + return true; + } + + /** + * Set port based on detected proxy headers + * + * @return bool + */ + protected function setPortFromProxy() + { + if (!$this->useProxy) { + return false; + } + + if (!isset($_SERVER['HTTP_X_FORWARDED_PORT']) || empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { + return false; } + + $port = $_SERVER['HTTP_X_FORWARDED_PORT']; + $this->setPort($port); + + return true; } /** @@ -308,23 +225,106 @@ protected function setSchemeFromProxy() } /** - * Set port based on detected proxy headers + * Sets host * - * @return bool + * @param string $host + * @return ServerUrl */ - protected function setPortFromProxy() + public function setHost($host) { - if (!$this->useProxy) { - return false; + $port = $this->getPort(); + $scheme = $this->getScheme(); + + if (($scheme == 'http' && (null === $port || $port == 80)) + || ($scheme == 'https' && (null === $port || $port == 443)) + ) { + $this->host = $host; + return $this; } - if (!isset($_SERVER['HTTP_X_FORWARDED_PORT']) || empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { - return false; + $this->host = $host . ':' . $port; + + return $this; + } + + /** + * Returns host + * + * @return string + */ + public function getHost() + { + if (null === $this->host) { + $this->detectHost(); } - $port = $_SERVER['HTTP_X_FORWARDED_PORT']; - $this->setPort($port); + return $this->host; + } - return true; + /** + * Set server port + * + * @param int $port + * @return ServerUrl + */ + public function setPort($port) + { + $this->port = (int) $port; + + return $this; + } + + /** + * Retrieve the server port + * + * @return int|null + */ + public function getPort() + { + if (null === $this->port) { + $this->detectPort(); + } + + return $this->port; + } + + /** + * Sets scheme (typically http or https) + * + * @param string $scheme + * @return ServerUrl + */ + public function setScheme($scheme) + { + $this->scheme = $scheme; + + return $this; + } + + /** + * Returns scheme (typically http or https) + * + * @return string + */ + public function getScheme() + { + if (null === $this->scheme) { + $this->detectScheme(); + } + + return $this->scheme; + } + + /** + * Set flag indicating whether or not to query proxy servers + * + * @param bool $useProxy + * @return ServerUrl + */ + public function setUseProxy($useProxy = false) + { + $this->useProxy = (bool) $useProxy; + + return $this; } } diff --git a/src/Helper/Url.php b/src/Helper/Url.php index a9823fa1..d43c4b4f 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -98,7 +98,6 @@ public function __invoke($name = null, array $params = array(), $options = array public function setRouter(RouteStackInterface $router) { $this->router = $router; - return $this; } @@ -111,7 +110,6 @@ public function setRouter(RouteStackInterface $router) public function setRouteMatch(RouteMatch $routeMatch) { $this->routeMatch = $routeMatch; - return $this; } } diff --git a/src/Helper/ViewModel.php b/src/Helper/ViewModel.php index 2a781c65..f183df39 100644 --- a/src/Helper/ViewModel.php +++ b/src/Helper/ViewModel.php @@ -27,23 +27,15 @@ class ViewModel extends AbstractHelper protected $root; /** - * Get the root view model - * - * @return null|Model - */ - public function getRoot() - { - return $this->root; - } - - /** - * Is a root view model composed? + * Set the current view model * - * @return bool + * @param Model $model + * @return ViewModel */ - public function hasRoot() + public function setCurrent(Model $model) { - return ($this->root instanceof Model); + $this->current = $model; + return $this; } /** @@ -75,20 +67,26 @@ public function hasCurrent() public function setRoot(Model $model) { $this->root = $model; - return $this; } /** - * Set the current view model + * Get the root view model * - * @param Model $model - * @return ViewModel + * @return null|Model */ - public function setCurrent(Model $model) + public function getRoot() { - $this->current = $model; + return $this->root; + } - return $this; + /** + * Is a root view model composed? + * + * @return bool + */ + public function hasRoot() + { + return ($this->root instanceof Model); } } From 3d0fb936dd5b8bc65e7ca8355909f7b4bdd28cd0 Mon Sep 17 00:00:00 2001 From: Matej Szendi Date: Fri, 29 Mar 2013 01:06:27 +0100 Subject: [PATCH 54/68] Revert renaming PluginFlashMessenger to FlashMessengerPlugin --- src/Helper/FlashMessenger.php | 78 +++++++++++++++++------------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/Helper/FlashMessenger.php b/src/Helper/FlashMessenger.php index 4b27314a..7e71fcca 100644 --- a/src/Helper/FlashMessenger.php +++ b/src/Helper/FlashMessenger.php @@ -9,7 +9,7 @@ namespace Zend\View\Helper; -use Zend\Mvc\Controller\Plugin\FlashMessenger as FlashMessengerPlugin; +use Zend\Mvc\Controller\Plugin\FlashMessenger as PluginFlashMessenger; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View\Helper\AbstractHelper; @@ -27,10 +27,10 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA * @var array */ protected $classMessages = array( - FlashMessengerPlugin::NAMESPACE_INFO => 'info', - FlashMessengerPlugin::NAMESPACE_ERROR => 'error', - FlashMessengerPlugin::NAMESPACE_SUCCESS => 'success', - FlashMessengerPlugin::NAMESPACE_DEFAULT => 'default', + PluginFlashMessenger::NAMESPACE_INFO => 'info', + PluginFlashMessenger::NAMESPACE_ERROR => 'error', + PluginFlashMessenger::NAMESPACE_SUCCESS => 'success', + PluginFlashMessenger::NAMESPACE_DEFAULT => 'default', ); /** @@ -52,9 +52,9 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA /** * Flash messenger plugin * - * @var FlashMessengerPlugin + * @var PluginFlashMessenger */ - protected $flashMessengerPlugin; + protected $pluginFlashMessenger; /** * Service locator @@ -67,14 +67,14 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA * Returns the flash messenger plugin controller * * @param string|null $namespace - * @return FlashMessenger|FlashMessengerPlugin + * @return FlashMessenger|PluginFlashMessenger */ public function __invoke($namespace = null) { if (null === $namespace) { return $this; } - $flashMessenger = $this->getFlashMessengerPlugin(); + $flashMessenger = $this->getPluginFlashMessenger(); return $flashMessenger->getMessagesFromNamespace($namespace); } @@ -88,7 +88,7 @@ public function __invoke($namespace = null) */ public function __call($method, $argv) { - $flashMessenger = $this->getFlashMessengerPlugin(); + $flashMessenger = $this->getPluginFlashMessenger(); return call_user_func_array(array($flashMessenger, $method), $argv); } @@ -99,15 +99,15 @@ public function __call($method, $argv) * @param array $classes * @return string */ - public function render($namespace = FlashMessengerPlugin::NAMESPACE_DEFAULT, array $classes = array()) + public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array()) { - $flashMessenger = $this->getFlashMessengerPlugin(); + $flashMessenger = $this->getPluginFlashMessenger(); $messages = $flashMessenger->getMessagesFromNamespace($namespace); // Prepare classes for opening tag if (empty($classes)) { $classes = isset($this->classMessages[$namespace]) ? - $this->classMessages[$namespace] : $this->classMessages[FlashMessengerPlugin::NAMESPACE_DEFAULT]; + $this->classMessages[$namespace] : $this->classMessages[PluginFlashMessenger::NAMESPACE_DEFAULT]; $classes = array($classes); } @@ -139,32 +139,6 @@ public function render($namespace = FlashMessengerPlugin::NAMESPACE_DEFAULT, arr return $markup; } - /** - * Set the flash messenger plugin - * - * @param FlashMessengerPlugin $flashMessengerPlugin - * @return FlashMessenger - */ - public function setFlashMessengerPlugin(FlashMessengerPlugin $flashMessengerPlugin) - { - $this->flashMessengerPlugin = $flashMessengerPlugin; - return $this; - } - - /** - * Get the flash messenger plugin - * - * @return FlashMessengerPlugin - */ - public function getFlashMessengerPlugin() - { - if (null === $this->flashMessengerPlugin) { - $this->setFlashMessengerPlugin(new FlashMessengerPlugin()); - } - - return $this->flashMessengerPlugin; - } - /** * Set the string used to close message representation * @@ -231,6 +205,32 @@ public function getMessageSeparatorString() return $this->messageSeparatorString; } + /** + * Set the flash messenger plugin + * + * @param PluginFlashMessenger $pluginFlashMessenger + * @return FlashMessenger + */ + public function setPluginFlashMessenger(PluginFlashMessenger $pluginFlashMessenger) + { + $this->pluginFlashMessenger = $pluginFlashMessenger; + return $this; + } + + /** + * Get the flash messenger plugin + * + * @return PluginFlashMessenger + */ + public function getPluginFlashMessenger() + { + if (null === $this->pluginFlashMessenger) { + $this->setPluginFlashMessenger(new PluginFlashMessenger()); + } + + return $this->pluginFlashMessenger; + } + /** * Set the service locator. * From bffb81f272867700953ff26c96155f5d6dca8b50 Mon Sep 17 00:00:00 2001 From: Maxnuf Date: Sun, 31 Mar 2013 10:41:57 +0000 Subject: [PATCH 55/68] add docblock and simplify logic --- src/Helper/Service/IdentityFactory.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Helper/Service/IdentityFactory.php b/src/Helper/Service/IdentityFactory.php index 65fc68c2..f7b1750a 100644 --- a/src/Helper/Service/IdentityFactory.php +++ b/src/Helper/Service/IdentityFactory.php @@ -15,14 +15,18 @@ class IdentityFactory implements FactoryInterface { + /** + * {@inheritDoc} + * + * @return \Zend\View\Helper\Identity + */ public function createService(ServiceLocatorInterface $serviceLocator) { $services = $serviceLocator->getServiceLocator(); $helper = new Identity(); - if (!$services->has('Zend\Authentication\AuthenticationService')) { - return $helper; + if ($services->has('Zend\Authentication\AuthenticationService')) { + $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService')); } - $helper->setAuthenticationService($services->get('Zend\Authentication\AuthenticationService')); return $helper; } } From 22e960d760233df084760c2c56abdd3d39432d2c Mon Sep 17 00:00:00 2001 From: Maxnuf Date: Sun, 31 Mar 2013 10:51:29 +0000 Subject: [PATCH 56/68] remove unnecessary whitespace --- src/HelperPluginManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 28d97580..02d9ef85 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -28,8 +28,8 @@ class HelperPluginManager extends AbstractPluginManager * @var array */ protected $factories = array( - 'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory', - 'identity' => 'Zend\View\Helper\Service\IdentityFactory', + 'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory', + 'identity' => 'Zend\View\Helper\Service\IdentityFactory', ); /** From 829dfe780d3a7f61208839a696360376bef9563d Mon Sep 17 00:00:00 2001 From: Jurian Sluiman Date: Tue, 2 Apr 2013 11:07:59 +0200 Subject: [PATCH 57/68] Create test to ensure view model is retrieved from event --- test/ViewTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/ViewTest.php b/test/ViewTest.php index a2c9299a..5ddf398f 100644 --- a/test/ViewTest.php +++ b/test/ViewTest.php @@ -22,6 +22,7 @@ use Zend\View\Resolver; use Zend\View\Variables as ViewVariables; use Zend\View\View; +use Zend\View\ViewEvent; class ViewTest extends TestCase { @@ -306,4 +307,31 @@ public function testCanTriggerPostRendererEvent() $this->view->render($this->model); $this->assertTrue($test->flag); } + + /** + * Test the view model can be swapped out + * + * @see https://github.com/zendframework/zf2/pull/4164 + */ + public function testModelFromEventIsUsedByRenderer() + { + $renderer = $this->getMock('Zend\View\Renderer\PhpRenderer', array('render')); + + $model1 = new ViewModel; + $model2 = new ViewModel; + + $this->view->addRenderingStrategy(function ($e) use ($renderer) { + return $renderer; + }); + + $this->view->getEventManager(ViewEvent::EVENT_RENDERER_POST, function($e) use ($model2) { + $e->setModel($model2); + }); + + $renderer->expects($this->once()) + ->method('render') + ->with($model2); + + $this->view->render($model1); + } } From 070a9fa3a405d670537a4b138d8f3b3b9141a015 Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Thu, 4 Apr 2013 12:11:25 +0200 Subject: [PATCH 58/68] Ducktyped params --- src/Helper/Url.php | 19 ++++++++++++++----- test/Helper/UrlTest.php | 8 ++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index b7a933a1..ad12eda0 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -14,6 +14,7 @@ use Zend\Mvc\Router\RouteStackInterface; use Zend\Stdlib\ArrayUtils; use Zend\View\Exception; +use Zend\Stdlib\Exception as StdlibException; /** * Helper for making easy links and getting urls that depend on the routes and router. @@ -66,10 +67,11 @@ public function setRouteMatch(RouteMatch $routeMatch) * @param array $params Parameters for the link * @param array|\Traversable $options Options for the route * @param bool $reuseMatchedParams Whether to reuse matched parameters - * @return string Url For the link href attribute - * @throws Exception\RuntimeException If no RouteStackInterface was provided - * @throws Exception\RuntimeException If no RouteMatch was provided - * @throws Exception\RuntimeException If RouteMatch didn't contain a matched route name + * @return string Url For the link href attribute + * @throws Exception\RuntimeException If no RouteStackInterface was provided + * @throws Exception\RuntimeException If no RouteMatch was provided + * @throws Exception\RuntimeException If RouteMatch didn't contain a matched route name + * @throws Exception\InvalidArgumentException If the params object was not an array or \Traversable object */ public function __invoke($name = null, $params = array(), $options = array(), $reuseMatchedParams = false) { @@ -94,7 +96,14 @@ public function __invoke($name = null, $params = array(), $options = array(), $r } } - $params = ArrayUtils::iteratorToArray($params, false); + try { + + $params = ArrayUtils::iteratorToArray($params, false); + + } catch(StdlibException\InvalidArgumentException $e) { + + throw new Exception\InvalidArgumentException('Params is expected to be an array of a Traversable object'); + } if ($reuseMatchedParams && $this->routeMatch !== null) { $routeMatchParams = $this->routeMatch->getParams(); diff --git a/test/Helper/UrlTest.php b/test/Helper/UrlTest.php index 3ad8dcd1..d8542e43 100644 --- a/test/Helper/UrlTest.php +++ b/test/Helper/UrlTest.php @@ -81,6 +81,14 @@ public function testModel() $this->assertEquals('/ctrl/act', $url); } + /** + * @expectedException \Zend\View\Exception\InvalidArgumentException + */ + public function testThrowsExceptionOnInvalidParams() + { + $this->url->__invoke('default', 'invalid params'); + } + public function testPluginWithoutRouteMatchesInEventRaisesExceptionWhenNoRouteProvided() { $this->setExpectedException('Zend\View\Exception\RuntimeException', 'RouteMatch'); From 0e2e546ac2d6a65dcd709e15b639afc764b54ac2 Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Sat, 6 Apr 2013 00:03:11 +0200 Subject: [PATCH 59/68] Doing as insttructed --- src/Helper/Url.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index ad12eda0..a138c522 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -96,13 +96,18 @@ public function __invoke($name = null, $params = array(), $options = array(), $r } } - try { + if (! is_array($params)) { - $params = ArrayUtils::iteratorToArray($params, false); + if (! $params instanceof \Traversable) { - } catch(StdlibException\InvalidArgumentException $e) { + throw new Exception\InvalidArgumentException( + 'Params is expected to be an array of a Traversable object' + ); - throw new Exception\InvalidArgumentException('Params is expected to be an array of a Traversable object'); + } else { + + $params = iterator_to_array($params); + } } if ($reuseMatchedParams && $this->routeMatch !== null) { From 40932366b69d03b3f6b9d2dc8975ded10fc258b6 Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Tue, 9 Apr 2013 08:12:54 +0200 Subject: [PATCH 60/68] fixing cs --- src/Helper/Url.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index a138c522..7866bc29 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -9,6 +9,7 @@ namespace Zend\View\Helper; +use Traversable; use Zend\Mvc\ModuleRouteListener; use Zend\Mvc\Router\RouteMatch; use Zend\Mvc\Router\RouteStackInterface; @@ -65,7 +66,7 @@ public function setRouteMatch(RouteMatch $routeMatch) * @see Zend\Mvc\Router\RouteInterface::assemble() * @param string $name Name of the route * @param array $params Parameters for the link - * @param array|\Traversable $options Options for the route + * @param array|Traversable $options Options for the route * @param bool $reuseMatchedParams Whether to reuse matched parameters * @return string Url For the link href attribute * @throws Exception\RuntimeException If no RouteStackInterface was provided @@ -96,16 +97,12 @@ public function __invoke($name = null, $params = array(), $options = array(), $r } } - if (! is_array($params)) { - - if (! $params instanceof \Traversable) { - + if (!is_array($params)) { + if (!$params instanceof Traversable) { throw new Exception\InvalidArgumentException( 'Params is expected to be an array of a Traversable object' ); - } else { - $params = iterator_to_array($params); } } From a22f0623e76670754a2e9446858764009037f043 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 12 Apr 2013 12:05:50 -0500 Subject: [PATCH 61/68] [zendframework/zf2#4161] Mark ServiceManager as optional - It's an optional dependency only, as the helper system is opt-in, via the renderers -- which are optional as well. --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 61921958..edf19399 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,7 @@ "php": ">=5.3.3", "zendframework/zend-eventmanager": "self.version", "zendframework/zend-loader": "self.version", - "zendframework/zend-stdlib": "self.version", - "zendframework/zend-servicemanager": "self.version" + "zendframework/zend-stdlib": "self.version" }, "require-dev": { "zendframework/zend-authentication": "self.version", @@ -49,7 +48,7 @@ "zendframework/zend-navigation": "Zend\\Navigation component", "zendframework/zend-paginator": "Zend\\Paginator component", "zendframework/zend-permissions-acl": "Zend\\Permissions\\Acl component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", + "zendframework/zend-servicemanager": "self.version", "zendframework/zend-uri": "Zend\\Uri component" }, "extra": { From e87e744000cc6484e54937162f1b94f46b6c75f3 Mon Sep 17 00:00:00 2001 From: Matus Zeman Date: Sat, 23 Feb 2013 02:59:58 +0000 Subject: [PATCH 62/68] Comments Conflicts: library/Zend/View/Helper/HeadTitle.php --- src/Helper/HeadTitle.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Helper/HeadTitle.php b/src/Helper/HeadTitle.php index 60c43f99..93600d55 100644 --- a/src/Helper/HeadTitle.php +++ b/src/Helper/HeadTitle.php @@ -84,7 +84,7 @@ public function __invoke($title = null, $setType = null) } /** - * Turn helper into string + * Render title (wrapped by title tag) * * @param string|null $indent * @return string @@ -100,6 +100,11 @@ public function toString($indent = null) return $indent . '' . $output . ''; } + /** + * Render title string + * + * @return string + */ public function renderTitle() { $items = array(); From 7e685c4efe52083153a92b753e0a838320b19f25 Mon Sep 17 00:00:00 2001 From: Matus Zeman Date: Sun, 14 Apr 2013 14:17:32 +0700 Subject: [PATCH 63/68] tests --- test/Helper/HeadTitleTest.php | 38 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/test/Helper/HeadTitleTest.php b/test/Helper/HeadTitleTest.php index acbcd0f5..a373f5a6 100644 --- a/test/Helper/HeadTitleTest.php +++ b/test/Helper/HeadTitleTest.php @@ -67,44 +67,50 @@ public function testHeadTitleReturnsObjectInstance() public function testCanSetTitleViaHeadTitle() { $placeholder = $this->helper->__invoke('Foo Bar', 'SET'); - $this->assertContains('Foo Bar', $placeholder->toString()); + $this->assertEquals('Foo Bar', $placeholder->renderTitle()); + } + + public function testToStringWrapsToTitleTag() + { + $placeholder = $this->helper->__invoke('Foo Bar', 'SET'); + $this->assertEquals('Foo Bar', $placeholder->toString()); } public function testCanAppendTitleViaHeadTitle() { $placeholder = $this->helper->__invoke('Foo'); $placeholder = $this->helper->__invoke('Bar'); - $this->assertContains('FooBar', $placeholder->toString()); + $this->assertEquals('FooBar', $placeholder->renderTitle()); } public function testCanPrependTitleViaHeadTitle() { $placeholder = $this->helper->__invoke('Foo'); $placeholder = $this->helper->__invoke('Bar', 'PREPEND'); - $this->assertContains('BarFoo', $placeholder->toString()); + $this->assertEquals('BarFoo', $placeholder->renderTitle()); } - public function testReturnedPlaceholderToStringContainsFullTitleElement() + public function testReturnedPlaceholderRenderTitleContainsFullTitleElement() { $placeholder = $this->helper->__invoke('Foo'); $placeholder = $this->helper->__invoke('Bar', 'APPEND')->setSeparator(' :: '); - $this->assertEquals('Foo :: Bar', $placeholder->toString()); + $this->assertEquals('Foo :: Bar', $placeholder->renderTitle()); } - public function testToStringEscapesEntries() + public function testRenderTitleEscapesEntries() { $this->helper->__invoke(''); - $string = $this->helper->toString(); + $string = $this->helper->renderTitle(); $this->assertNotContains('assertNotContains('', $string); } - public function testToStringEscapesSeparator() + public function testRenderTitleEscapesSeparator() { $this->helper->__invoke('Foo') ->__invoke('Bar') ->setSeparator('
'); - $string = $this->helper->toString(); + $string = $this->helper->renderTitle(); $this->assertNotContains('
', $string); $this->assertContains('Foo', $string); $this->assertContains('Bar', $string); @@ -123,14 +129,14 @@ public function testIndentationIsHonored() public function testAutoEscapeIsHonored() { $this->helper->__invoke('Some Title ©right;'); - $this->assertEquals('Some Title &copyright;', $this->helper->toString()); + $this->assertEquals('Some Title &copyright;', $this->helper->renderTitle()); $this->assertTrue($this->helper->__invoke()->getAutoEscape()); $this->helper->__invoke()->setAutoEscape(false); $this->assertFalse($this->helper->__invoke()->getAutoEscape()); - $this->assertEquals('Some Title ©right;', $this->helper->toString()); + $this->assertEquals('Some Title ©right;', $this->helper->renderTitle()); } /** @@ -143,7 +149,7 @@ public function testZF2918() $this->helper->setPrefix('Prefix: '); $this->helper->setPostfix(' :Postfix'); - $this->assertEquals('Prefix: Some Title :Postfix', $this->helper->toString()); + $this->assertEquals('Prefix: Some Title :Postfix', $this->helper->renderTitle()); } /** @@ -157,7 +163,7 @@ public function testZF3577() $this->helper->setPrefix('Prefix & '); $this->helper->setPostfix(' & Postfix'); - $this->assertEquals('Prefix & Some Title & Postfix', $this->helper->toString()); + $this->assertEquals('Prefix & Some Title & Postfix', $this->helper->renderTitle()); } public function testCanTranslateTitle() @@ -173,7 +179,7 @@ public function testCanTranslateTitle() $this->helper->setTranslatorEnabled(true); $this->helper->setTranslator($translator); $this->helper->__invoke('Message_1'); - $this->assertEquals('Message 1 (en)', $this->helper->toString()); + $this->assertEquals('Message 1 (en)', $this->helper->renderTitle()); } public function testTranslatorMethods() @@ -196,7 +202,7 @@ public function testTranslatorMethods() public function testHeadTitleZero() { $this->helper->__invoke('0'); - $this->assertEquals('0', $this->helper->toString()); + $this->assertEquals('0', $this->helper->renderTitle()); } public function testCanPrependTitlesUsingDefaultAttachOrder() @@ -204,7 +210,7 @@ public function testCanPrependTitlesUsingDefaultAttachOrder() $this->helper->setDefaultAttachOrder('PREPEND'); $placeholder = $this->helper->__invoke('Foo'); $placeholder = $this->helper->__invoke('Bar'); - $this->assertContains('BarFoo', $placeholder->toString()); + $this->assertEquals('BarFoo', $placeholder->renderTitle()); } From 2ee00a3513c98223a615acfbee5dccd11afbb31d Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 15 Apr 2013 06:15:26 -0500 Subject: [PATCH 64/68] [zendframework/zf2#3877] CS fixes - per php-cs-fixer --- src/Helper/HeadTitle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/HeadTitle.php b/src/Helper/HeadTitle.php index 93600d55..900ae5e1 100644 --- a/src/Helper/HeadTitle.php +++ b/src/Helper/HeadTitle.php @@ -99,7 +99,7 @@ public function toString($indent = null) return $indent . '' . $output . ''; } - + /** * Render title string * From e1ea65dcd5ba69f5554838533f5b2f8eed2aaf67 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Tue, 23 Apr 2013 13:58:49 +0200 Subject: [PATCH 65/68] Rename addPageClassToLi to addClassToListItem --- src/Helper/Navigation/Menu.php | 38 +++++++++---------- test/Helper/Navigation/MenuTest.php | 10 ++--- ....html => addclasstolistitem_as_false.html} | 0 ...e.html => addclasstolistitem_as_true.html} | 0 ... onlyactivebranch_addclasstolistitem.html} | 0 5 files changed, 24 insertions(+), 24 deletions(-) rename test/Helper/Navigation/_files/expected/menu/{addpageclasstoli_as_false.html => addclasstolistitem_as_false.html} (100%) rename test/Helper/Navigation/_files/expected/menu/{addpageclasstoli_as_true.html => addclasstolistitem_as_true.html} (100%) rename test/Helper/Navigation/_files/expected/menu/{onlyactivebranch_addpageclasstoli.html => onlyactivebranch_addclasstolistitem.html} (100%) diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php index 9a1bafe2..53ee11e9 100644 --- a/src/Helper/Navigation/Menu.php +++ b/src/Helper/Navigation/Menu.php @@ -53,7 +53,7 @@ class Menu extends AbstractHelper * * @var bool */ - protected $addPageClassToLi = false; + protected $addClassToListItem = false; /** * Partial view script to use for rendering menu @@ -175,9 +175,9 @@ public function getRenderParents() * Default is true. * @return Menu fluent interface, returns self */ - public function setAddPageClassToLi($flag = true) + public function setAddClassToListItem($flag = true) { - $this->addPageClassToLi = (bool) $flag; + $this->addClassToListItem = (bool) $flag; return $this; } @@ -188,9 +188,9 @@ public function setAddPageClassToLi($flag = true) * * @return bool whether parents should be rendered */ - public function getAddPageClassToLi() + public function getAddClassToListItem() { - return $this->addPageClassToLi; + return $this->addClassToListItem; } /** @@ -234,7 +234,7 @@ public function getPartial() * @param bool $escapeLabel Whether or not to escape the label * @return string HTML string for the given page */ - public function htmlify(AbstractPage $page, $escapeLabel = true, $addPageClassToLi = false) + public function htmlify(AbstractPage $page, $escapeLabel = true, $addClassToListItem = false) { // get label and title for translating $label = $page->getLabel(); @@ -257,7 +257,7 @@ public function htmlify(AbstractPage $page, $escapeLabel = true, $addPageClassTo 'title' => $title, ); - if ($addPageClassToLi === false) { + if ($addClassToListItem === false) { $attribs['class'] = $page->getClass(); } @@ -335,8 +335,8 @@ protected function normalizeOptions(array $options = array()) $options['renderParents'] = $this->getRenderParents(); } - if (!isset($options['addPageClassToLi'])) { - $options['addPageClassToLi'] = $this->getAddPageClassToLi(); + if (!isset($options['addClassToListItem'])) { + $options['addClassToListItem'] = $this->getAddClassToListItem(); } return $options; @@ -362,7 +362,7 @@ protected function renderDeepestMenu(AbstractContainer $container, $minDepth, $maxDepth, $escapeLabels, - $addPageClassToLi + $addClassToListItem ) { if (!$active = $this->findActive($container, $minDepth - 1, $maxDepth)) { return ''; @@ -396,13 +396,13 @@ protected function renderDeepestMenu(AbstractContainer $container, $liClasses[] = 'active'; } // Add CSS class from page to
  • - if ($addPageClassToLi && $subPage->getClass()) { + if ($addClassToListItem && $subPage->getClass()) { $liClasses[] = $subPage->getClass(); } $liClass = empty($liClasses) ? '' : ' class="' . implode(' ', $liClasses) . '"'; $html .= $indent . ' ' . self::EOL; - $html .= $indent . ' ' . $this->htmlify($subPage, $escapeLabels, $addPageClassToLi) . self::EOL; + $html .= $indent . ' ' . $this->htmlify($subPage, $escapeLabels, $addClassToListItem) . self::EOL; $html .= $indent . '
  • ' . self::EOL; } @@ -421,7 +421,7 @@ protected function renderDeepestMenu(AbstractContainer $container, * @param int|null $maxDepth maximum depth * @param bool $onlyActive render only active branch? * @param bool $escapeLabels Whether or not to escape the labels - * @param bool $addPageClassToLi Whether or not page class applied to
  • element + * @param bool $addClassToListItem Whether or not page class applied to
  • element * @return string */ protected function renderNormalMenu(AbstractContainer $container, @@ -431,7 +431,7 @@ protected function renderNormalMenu(AbstractContainer $container, $maxDepth, $onlyActive, $escapeLabels, - $addPageClassToLi + $addClassToListItem ) { $html = ''; @@ -515,13 +515,13 @@ protected function renderNormalMenu(AbstractContainer $container, $liClasses[] = 'active'; } // Add CSS class from page to
  • - if ($addPageClassToLi && $page->getClass()) { + if ($addClassToListItem && $page->getClass()) { $liClasses[] = $page->getClass(); } $liClass = empty($liClasses) ? '' : ' class="' . implode(' ', $liClasses) . '"'; $html .= $myIndent . ' ' . self::EOL - . $myIndent . ' ' . $this->htmlify($page, $escapeLabels, $addPageClassToLi) . self::EOL; + . $myIndent . ' ' . $this->htmlify($page, $escapeLabels, $addClassToListItem) . self::EOL; // store as previous depth for next iteration $prevDepth = $depth; @@ -572,7 +572,7 @@ public function renderMenu($container = null, array $options = array()) $options['minDepth'], $options['maxDepth'], $options['escapeLabels'], - $options['addPageClassToLi']); + $options['addClassToListItem']); } else { $html = $this->renderNormalMenu($container, $options['ulClass'], @@ -581,7 +581,7 @@ public function renderMenu($container = null, array $options = array()) $options['maxDepth'], $options['onlyActiveBranch'], $options['escapeLabels'], - $options['addPageClassToLi']); + $options['addClassToListItem']); } return $html; @@ -629,7 +629,7 @@ public function renderSubMenu(AbstractContainer $container = null, 'onlyActiveBranch' => true, 'renderParents' => false, 'escapeLabels' => true, - 'addPageClassToLi' => false, + 'addClassToListItem' => false, )); } diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php index deef6c22..89441881 100644 --- a/test/Helper/Navigation/MenuTest.php +++ b/test/Helper/Navigation/MenuTest.php @@ -529,7 +529,7 @@ public function testRenderingWithoutPageClassToLi() 'class' => 'foobar', )); - $expected = $this->_getExpected('menu/addpageclasstoli_as_false.html'); + $expected = $this->_getExpected('menu/addclasstolistitem_as_false.html'); $actual = $this->_helper->renderMenu($container); $this->assertEquals($expected, $actual); @@ -538,7 +538,7 @@ public function testRenderingWithoutPageClassToLi() public function testRenderingWithPageClassToLi() { $options = array( - 'addPageClassToLi' => true, + 'addClassToListItem' => true, ); $container = new \Zend\Navigation\Navigation($this->_nav2->toArray()); @@ -548,7 +548,7 @@ public function testRenderingWithPageClassToLi() 'class' => 'foobar', )); - $expected = $this->_getExpected('menu/addpageclasstoli_as_true.html'); + $expected = $this->_getExpected('menu/addclasstolistitem_as_true.html'); $actual = $this->_helper->renderMenu($container, $options); $this->assertEquals($expected, $actual); @@ -557,7 +557,7 @@ public function testRenderingWithPageClassToLi() public function testRenderDeepestMenuWithPageClassToLi() { $options = array( - 'addPageClassToLi' => true, + 'addClassToListItem' => true, 'onlyActiveBranch' => true, 'renderParents' => false, ); @@ -566,7 +566,7 @@ public function testRenderDeepestMenuWithPageClassToLi() $pages[1]['class'] = 'foobar'; $container = new \Zend\Navigation\Navigation($pages); - $expected = $this->_getExpected('menu/onlyactivebranch_addpageclasstoli.html'); + $expected = $this->_getExpected('menu/onlyactivebranch_addclasstolistitem.html'); $actual = $this->_helper->renderMenu($container, $options); $this->assertEquals($expected, $actual); diff --git a/test/Helper/Navigation/_files/expected/menu/addpageclasstoli_as_false.html b/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html similarity index 100% rename from test/Helper/Navigation/_files/expected/menu/addpageclasstoli_as_false.html rename to test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html diff --git a/test/Helper/Navigation/_files/expected/menu/addpageclasstoli_as_true.html b/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html similarity index 100% rename from test/Helper/Navigation/_files/expected/menu/addpageclasstoli_as_true.html rename to test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addpageclasstoli.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html similarity index 100% rename from test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addpageclasstoli.html rename to test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html From 4e7b3d3f5b40fbf7ecfdd1cbdbdb6304230f897d Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 25 Apr 2013 10:00:28 -0500 Subject: [PATCH 66/68] [zendframework/zf2#4298] CS fixes - Per php-cs-fixer --- .../_files/expected/menu/addclasstolistitem_as_false.html | 2 +- .../_files/expected/menu/addclasstolistitem_as_true.html | 2 +- .../expected/menu/onlyactivebranch_addclasstolistitem.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html b/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html index f3b66dee..5016960c 100644 --- a/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html +++ b/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html @@ -11,4 +11,4 @@
  • Class test
  • - \ No newline at end of file + diff --git a/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html b/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html index dc0eaee6..aaf0ca0a 100644 --- a/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html +++ b/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html @@ -11,4 +11,4 @@
  • Class test
  • - \ No newline at end of file + diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html index 8c50053f..754cdc12 100644 --- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html +++ b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html @@ -8,4 +8,4 @@
  • Site 3
  • - \ No newline at end of file + From 14939fdc2c63c9965a303fa12c2b9425711b859b Mon Sep 17 00:00:00 2001 From: Nicolas Eeckeloo Date: Mon, 29 Apr 2013 09:38:13 +0200 Subject: [PATCH 67/68] Fix coding standards PSR-2 --- src/Helper/Identity.php | 2 +- src/Helper/Layout.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Helper/Identity.php b/src/Helper/Identity.php index b4b9c635..b1801513 100644 --- a/src/Helper/Identity.php +++ b/src/Helper/Identity.php @@ -34,7 +34,7 @@ class Identity extends AbstractHelper */ public function __invoke() { - if (!$this->authenticationService instanceof AuthenticationService){ + if (!$this->authenticationService instanceof AuthenticationService) { throw new Exception\RuntimeException('No AuthenticationService instance provided'); } diff --git a/src/Helper/Layout.php b/src/Helper/Layout.php index e98c10ca..5b4dc47e 100644 --- a/src/Helper/Layout.php +++ b/src/Helper/Layout.php @@ -89,7 +89,7 @@ public function setTemplate($template) */ protected function getViewModelHelper() { - if(null === $this->viewModelHelper) { + if (null === $this->viewModelHelper) { $this->viewModelHelper = $this->getView()->plugin('view_model'); } From d8558d1da6c47748018c041970a8c7857512deef Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 1 May 2013 16:42:36 -0500 Subject: [PATCH 68/68] [2.2.0rc1] Release preparation - Updated all component composer.json files to reflect new branch aliases - Updated changelog - Updated readme --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index edf19399..b1a25684 100644 --- a/composer.json +++ b/composer.json @@ -53,8 +53,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.1-dev", - "dev-develop": "2.2-dev" + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" } }, "autoload-dev": {