From ef515edb247bd29e65e18536a8ab60d492df60e9 Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Sun, 18 Mar 2012 17:18:55 +0100 Subject: [PATCH 01/78] Add support for Console MVC applications. - Revert Mvc/Bootstrap.php - Add Mvc\ConsoleBootstrap, extending standard (http) Bootstrap, for bootstrapping application when inside a Console enviroment. - Add Mvc\Router\Console\Catchall, a route that always matches with a Console request. - Add Mvc\View\CreateViewModelListener::createViewModelFromString() that allows controllers to return a "string" that will be output to console. - Add Mvc\View\InjectRoutematchParamsStrategy.php that copies matched parameters and their values from Routematch to Request. - Add View\Model\ConsoleModel describing data returned from a console MVC action. - Add View\Renderer\ConsoleRenderer that prepares Console output to be echoed. - Add View\Renderer\ConsoleStrategy which responsible for selecting ConsoleRenderer and outputing the result to the console. --- src/Model/ConsoleModel.php | 74 +++++++++++++ src/Renderer/ConsoleRenderer.php | 174 +++++++++++++++++++++++++++++++ src/Strategy/ConsoleStrategy.php | 141 +++++++++++++++++++++++++ 3 files changed, 389 insertions(+) create mode 100644 src/Model/ConsoleModel.php create mode 100644 src/Renderer/ConsoleRenderer.php create mode 100644 src/Strategy/ConsoleStrategy.php diff --git a/src/Model/ConsoleModel.php b/src/Model/ConsoleModel.php new file mode 100644 index 00000000..481513c6 --- /dev/null +++ b/src/Model/ConsoleModel.php @@ -0,0 +1,74 @@ +errorLevel = $errorLevel; + } + + /** + * @return int + */ + public function getErrorLevel() + { + return $this->errorLevel; + } +} diff --git a/src/Renderer/ConsoleRenderer.php b/src/Renderer/ConsoleRenderer.php new file mode 100644 index 00000000..cb0c3e40 --- /dev/null +++ b/src/Renderer/ConsoleRenderer.php @@ -0,0 +1,174 @@ +init(); + } + + public function setResolver(Resolver $resolver){} + + /** + * Return the template engine object + * + * Returns the object instance, as it is its own template engine + * + * @return PhpRenderer + */ + public function getEngine() + { + return $this; + } + + /** + * Allow custom object initialization when extending Zend_View_Abstract or + * Zend_View + * + * Triggered by {@link __construct() the constructor} as its final action. + * + * @return void + */ + public function init() + { + } + + /** + * Set filter chain + * + * @param FilterChain $filters + * @return Zend\View\PhpRenderer + */ + public function setFilterChain(FilterChain $filters) + { + $this->__filterChain = $filters; + return $this; + } + + /** + * Retrieve filter chain for post-filtering script content + * + * @return FilterChain + */ + public function getFilterChain() + { + if (null === $this->__filterChain) { + $this->setFilterChain(new FilterChain()); + } + return $this->__filterChain; + } + + /** + * Recursively processes all ViewModels and returns output. + * + * @param string|Model $model A ViewModel instance. + * @param null|array|Traversable $values Values to use when rendering. If none + * provided, uses those in the composed + * variables container. + * @return string Console output. + */ + public function render($model, $values = null) + { + if(!$model instanceof Model){ + return ''; + } + + $result = ''; + $options = $model->getOptions(); + foreach ($options as $setting => $value) { + $method = 'set' . $setting; + if (method_exists($this, $method)) { + $this->$method($value); + } + unset($method, $setting, $value); + } + unset($options); + + $values = $model->getVariables(); + + if(isset($values['result'])){ + // filter and append the result + $result .= $this->getFilterChain()->filter($values['result']); + } + + if($model->hasChildren()){ + // recursively render all children + foreach($model->getChildren() as $child){ + $result .= $this->render($child, $values); + } + } + + return $result; + } + + /** + * @see Zend\View\Renderer\TreeRendererInterface + * @return bool + */ + public function canRenderTrees() + { + return true; + } + +} diff --git a/src/Strategy/ConsoleStrategy.php b/src/Strategy/ConsoleStrategy.php new file mode 100644 index 00000000..e5ad1bf3 --- /dev/null +++ b/src/Strategy/ConsoleStrategy.php @@ -0,0 +1,141 @@ +renderer = $renderer; + $this->console = $console; + } + + /** + * Retrieve the composed renderer + * + * @return ConsoleRenderer + */ + public function getRenderer() + { + return $this->renderer; + } + + /** + * Attach the aggregate to the specified event manager + * + * @param EventCollection $events + * @param int $priority + * @return void + */ + public function attach(EventCollection $events, $priority = 1) + { + $this->listeners[] = $events->attach('renderer', array($this, 'selectRenderer'), $priority); + $this->listeners[] = $events->attach('response', array($this, 'outputToConsole'), $priority); + } + + /** + * Detach aggregate listeners from the specified event manager + * + * @param EventCollection $events + * @return void + */ + public function detach(EventCollection $events) + { + foreach ($this->listeners as $index => $listener) { + if ($events->detach($listener)) { + unset($this->listeners[$index]); + } + } + } + + /** + * Select the ConsoleRenderer; typically, this will be registered last or at + * low priority. + * + * @param ViewEvent $e + * @return ConsoleRenderer + */ + public function selectRenderer(ViewEvent $e) + { + return $this->renderer; + } + + /** + * Populate the response object from the View + * + * Populates the content of the response object from the view rendering + * results. + * + * @param ViewEvent $e + * @return void + */ + public function outputToConsole(ViewEvent $e) + { + $renderer = $e->getRenderer(); + if ($renderer !== $this->renderer) { + return; + } + + $result = $e->getResult(); + $response = $e->getResponse(); + $response->setContent($result); + + $this->console->write($result); + } +} From 151d3c895d72f977e7606d72117036e64e9b3161 Mon Sep 17 00:00:00 2001 From: "Dolf Schimmel (Freeaqingme)" Date: Sun, 17 Jun 2012 03:39:17 +0200 Subject: [PATCH 02/78] Cleaning up --- src/Strategy/JsonStrategy.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 08095bb0..aedce678 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -96,7 +96,6 @@ public function detach(EventManagerInterface $events) */ public function selectRenderer(ViewEvent $e) { -// return $this->renderer; $model = $e->getModel(); if ($model instanceof Model\JsonModel) { From b91e07d1797e24f71c36a30dc12f2defed25d9a2 Mon Sep 17 00:00:00 2001 From: Evan Coury Date: Sun, 1 Jul 2012 09:50:52 -0700 Subject: [PATCH 03/78] Unify the remaining service managers - View Helper Manager - Controller Plugin Manager - Controller Loader --- src/HelperPluginManager.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index f7e29306..6d5ebad4 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -27,7 +27,7 @@ * Plugin manager implementation for view helpers * * Enforces that heleprs retrieved are instances of - * Helper\HelperInterface. Additionally, it registers a number of default + * Helper\HelperInterface. Additionally, it registers a number of default * helpers. * * @category Zend @@ -39,15 +39,14 @@ class HelperPluginManager extends AbstractPluginManager { /** * Default set of helpers - * + * * @var array */ protected $invokableClasses = array( - 'basepath' => 'Zend\View\Helper\BasePath', + // basepath, doctype, and url are set up as factories in the ViewHelperManagerFactory 'currency' => 'Zend\View\Helper\Currency', 'cycle' => 'Zend\View\Helper\Cycle', 'declarevars' => 'Zend\View\Helper\DeclareVars', - 'doctype' => 'Zend\View\Helper\Doctype', 'escape' => 'Zend\View\Helper\Escape', 'gravatar' => 'Zend\View\Helper\Gravatar', 'headlink' => 'Zend\View\Helper\HeadLink', @@ -71,7 +70,6 @@ class HelperPluginManager extends AbstractPluginManager 'rendertoplaceholder' => 'Zend\View\Helper\RenderToPlaceholder', 'serverurl' => 'Zend\View\Helper\ServerUrl', 'translator' => 'Zend\View\Helper\Translator', - 'url' => 'Zend\View\Helper\Url', 'viewmodel' => 'Zend\View\Helper\ViewModel', ); @@ -85,8 +83,8 @@ class HelperPluginManager extends AbstractPluginManager * * After invoking parent constructor, add an initializer to inject the * attached renderer, if any, to the currently requested helper. - * - * @param null|ConfigurationInterface $configuration + * + * @param null|ConfigurationInterface $configuration * @return void */ public function __construct(ConfigurationInterface $configuration = null) @@ -97,8 +95,8 @@ public function __construct(ConfigurationInterface $configuration = null) /** * Set renderer - * - * @param Renderer\RendererInterface $renderer + * + * @param Renderer\RendererInterface $renderer * @return HelperPluginManager */ public function setRenderer(Renderer\RendererInterface $renderer) @@ -109,7 +107,7 @@ public function setRenderer(Renderer\RendererInterface $renderer) /** * Retrieve renderer instance - * + * * @return null|Renderer\RendererInterface */ public function getRenderer() @@ -120,13 +118,13 @@ public function getRenderer() /** * Inject a helper instance with the registered renderer * - * @param Helper\HelperInterface $helper + * @param Helper\HelperInterface $helper * @return void */ public function injectRenderer($helper) { $renderer = $this->getRenderer(); - if (null === $renderer) { + if (null === $renderer) { return; } $helper->setView($renderer); @@ -136,8 +134,8 @@ public function injectRenderer($helper) * Validate the plugin * * Checks that the helper loaded is an instance of Helper\HelperInterface. - * - * @param mixed $plugin + * + * @param mixed $plugin * @return void * @throws Exception\InvalidHelperException if invalid */ From 04aaa501ddd397d543cded04b000fe66fa0046e3 Mon Sep 17 00:00:00 2001 From: Evan Coury Date: Sun, 1 Jul 2012 23:16:57 -0700 Subject: [PATCH 04/78] ServiceManager should check for a factory first (before invokables) Currently a lot of tests expect that 'basepath', 'url', and 'doctype' are available invokable helpers. In a working MVC app, we want to use factories for these to inject things like the request, router, route match, doctype setting from config, etc. However, in the tests, these things will not be availble and they're expected to be available as invokables by default. This allows both assumptions to be made at the cost of an isset() per invokable instantiated. There's a chance that 'doctype' is the only one affected by this, which is something I'll look into more later. --- src/HelperPluginManager.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 6d5ebad4..defea415 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -44,6 +44,9 @@ class HelperPluginManager extends AbstractPluginManager */ protected $invokableClasses = array( // basepath, doctype, and url are set up as factories in the ViewHelperManagerFactory + 'doctype' => 'Zend\View\Helper\Doctype', + 'basepath' => 'Zend\View\Helper\BasePath', + 'url' => 'Zend\View\Helper\Url', 'currency' => 'Zend\View\Helper\Currency', 'cycle' => 'Zend\View\Helper\Cycle', 'declarevars' => 'Zend\View\Helper\DeclareVars', From 5f30f0aa53c8d4c58be3aa8c8458cfdd0cd816de Mon Sep 17 00:00:00 2001 From: Evan Coury Date: Sun, 1 Jul 2012 23:26:08 -0700 Subject: [PATCH 05/78] Allow the doctype helper to still be an invokable by default --- src/HelperPluginManager.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index defea415..fed6c3eb 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -43,10 +43,11 @@ class HelperPluginManager extends AbstractPluginManager * @var array */ protected $invokableClasses = array( - // basepath, doctype, and url are set up as factories in the ViewHelperManagerFactory - 'doctype' => 'Zend\View\Helper\Doctype', - 'basepath' => 'Zend\View\Helper\BasePath', - 'url' => 'Zend\View\Helper\Url', + // basepath, doctype, and url are set up as factories in the ViewHelperManagerFactory. + // basepath and url are not very useful without their factories, however the doctype + // helper works fine as an invokable. The factory for doctype simply checks for the + // config value from the merged config. + 'doctype' => 'Zend\View\Helper\Doctype', // overridden by a factory in ViewHelperManagerFactory 'currency' => 'Zend\View\Helper\Currency', 'cycle' => 'Zend\View\Helper\Cycle', 'declarevars' => 'Zend\View\Helper\DeclareVars', From f5e9bae32b59c279e98213a5d463df760d0f5c89 Mon Sep 17 00:00:00 2001 From: Evan Coury Date: Sun, 1 Jul 2012 23:38:20 -0700 Subject: [PATCH 06/78] View tests require basepath helper as invokable --- src/HelperPluginManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index fed6c3eb..a51bdf95 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -48,6 +48,8 @@ class HelperPluginManager extends AbstractPluginManager // helper works fine as an invokable. The factory for doctype simply checks for the // config value from the merged config. 'doctype' => 'Zend\View\Helper\Doctype', // overridden by a factory in ViewHelperManagerFactory + 'basepath' => 'Zend\View\Helper\BasePath', + 'url' => 'Zend\View\Helper\Url', 'currency' => 'Zend\View\Helper\Currency', 'cycle' => 'Zend\View\Helper\Cycle', 'declarevars' => 'Zend\View\Helper\DeclareVars', From be7e1d76144ec83d7d9d759553b30251c08e2245 Mon Sep 17 00:00:00 2001 From: Christopher Martin Date: Mon, 2 Jul 2012 23:04:39 -0400 Subject: [PATCH 07/78] [i18n] Currency, NumberFormat View Helpers --- src/Helper/Currency.php | 110 --------------------------- src/HelperPluginManager.php | 1 - test/Helper/CurrencyTest.php | 139 ----------------------------------- 3 files changed, 250 deletions(-) delete mode 100644 src/Helper/Currency.php delete mode 100644 test/Helper/CurrencyTest.php diff --git a/src/Helper/Currency.php b/src/Helper/Currency.php deleted file mode 100644 index d4ff73f2..00000000 --- a/src/Helper/Currency.php +++ /dev/null @@ -1,110 +0,0 @@ -setCurrency($currency); - } - - /** - * Output a formatted currency - * - * @param integer|float $value Currency value to output - * @param string|\Zend\Locale\Locale|array $currency OPTIONAL Currency to use for this call - * @return string Formatted currency - */ - public function __invoke($value = null, $currency = null) - { - if ($value === null) { - return $this; - } - - if (is_string($currency) || ($currency instanceof Locale\Locale)) { - if (Locale\Locale::isLocale($currency)) { - $currency = array('locale' => $currency); - } - } - - if (is_string($currency)) { - $currency = array('currency' => $currency); - } - - if (is_array($currency)) { - return $this->_currency->toCurrency($value, $currency); - } - - return $this->_currency->toCurrency($value); - } - - /** - * Sets a currency to use - * - * @param Zend_Currency|String|\Zend\Locale\Locale $currency Currency to use - * @throws \Zend\View\Exception When no or a false currency was set - * @return \Zend\View\Helper\Currency - */ - public function setCurrency($currency = null) - { - if (!$currency instanceof \Zend\Currency\Currency) { - $currency = new \Zend\Currency\Currency($currency); - } - $this->_currency = $currency; - - return $this; - } - - /** - * Retrieve currency object - * - * @return \Zend\Currency\Currency|null - */ - public function getCurrency() - { - return $this->_currency; - } -} diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index a51bdf95..28eb3015 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -50,7 +50,6 @@ class HelperPluginManager extends AbstractPluginManager 'doctype' => 'Zend\View\Helper\Doctype', // overridden by a factory in ViewHelperManagerFactory 'basepath' => 'Zend\View\Helper\BasePath', 'url' => 'Zend\View\Helper\Url', - 'currency' => 'Zend\View\Helper\Currency', 'cycle' => 'Zend\View\Helper\Cycle', 'declarevars' => 'Zend\View\Helper\DeclareVars', 'escape' => 'Zend\View\Helper\Escape', diff --git a/test/Helper/CurrencyTest.php b/test/Helper/CurrencyTest.php deleted file mode 100644 index 4063b713..00000000 --- a/test/Helper/CurrencyTest.php +++ /dev/null @@ -1,139 +0,0 @@ - 0)); - Currency\Currency::setCache($cache); - - $this->helper = new Helper\Currency('de_AT'); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @return void - */ - public function tearDown() - { - unset($this->helper); - } - - public function testCurrencyObjectPassedToConstructor() - { - $curr = new Currency\Currency('de_AT'); - - $helper = new Helper\Currency($curr); - $this->assertEquals('€ 1.234,56', $helper->__invoke(1234.56)); - $this->assertEquals('€ 0,12', $helper->__invoke(0.123)); - } - - public function testLocalCurrencyObjectUsedWhenPresent() - { - $curr = new Currency\Currency('de_AT'); - - $this->helper->setCurrency($curr); - $this->assertEquals('€ 1.234,56', $this->helper->__invoke(1234.56)); - $this->assertEquals('€ 0,12', $this->helper->__invoke(0.123)); - } - - public function testPassingNonNullNonCurrencyObjectToConstructorThrowsException() - { - try { - $helper = new Helper\Currency('something'); - } catch (\Exception $e) { - if (substr($e->getMessage(), 0, 15) == 'No region found') { - $this->assertContains('within the locale', $e->getMessage()); - } else { - $this->assertContains('not found', $e->getMessage()); - } - } - } - - public function testPassingNonCurrencyObjectToSetCurrencyThrowsException() - { - try { - $this->helper->setCurrency('something'); - } catch (\Exception $e) { - if (substr($e->getMessage(), 0, 15) == 'No region found') { - $this->assertContains('within the locale', $e->getMessage()); - } else { - $this->assertContains('not found', $e->getMessage()); - } - } - } - - public function testCanOutputCurrencyWithOptions() - { - $curr = new Currency\Currency('de_AT'); - - $this->helper->setCurrency($curr); - $this->assertEquals("€ 1.234,56", $this->helper->__invoke(1234.56, "de_AT")); - } - - public function testCurrencyObjectNullByDefault() - { - $this->assertNotNull($this->helper->getCurrency()); - } - - public function testHelperObjectReturnedWhenNoArgumentsPassed() - { - $helper = $this->helper->__invoke(); - $this->assertSame($this->helper, $helper); - - $currLoc = new Currency\Currency('de_AT'); - $this->helper->setCurrency($currLoc); - $helper = $this->helper->__invoke(); - $this->assertSame($this->helper, $helper); - } -} From 0a522f8e3b83515d5d8ace66f9565fc7009c42f8 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 22:52:22 +0200 Subject: [PATCH 08/78] Fixed unit test testAttemptingToRenderWithNoCurrentModelRaisesException so that it succeeds on Windows --- test/Helper/RenderChildModelTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Helper/RenderChildModelTest.php b/test/Helper/RenderChildModelTest.php index 2f9f2ff3..e7dd6a1d 100644 --- a/test/Helper/RenderChildModelTest.php +++ b/test/Helper/RenderChildModelTest.php @@ -140,7 +140,7 @@ public function testAttemptingToRenderWithNoCurrentModelRaisesException() $renderer = new PhpRenderer(); $renderer->setResolver($this->resolver); $this->setExpectedException('Zend\View\Exception\RuntimeException', 'no view model'); - $this->expectOutputString("Layout start\n\n"); + $this->expectOutputString("Layout start" . PHP_EOL . PHP_EOL); $renderer->render('layout'); } } From 6be761c0725b9c3f7fbd63b2e60375638a953b18 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 22:53:26 +0200 Subject: [PATCH 09/78] Fixed unit test RenderToPlaceholderTest::testDefaultEmpty so that it works on Windows. --- test/Helper/RenderToPlaceholderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Helper/RenderToPlaceholderTest.php b/test/Helper/RenderToPlaceholderTest.php index a470be24..7b925b64 100644 --- a/test/Helper/RenderToPlaceholderTest.php +++ b/test/Helper/RenderToPlaceholderTest.php @@ -48,7 +48,7 @@ public function testDefaultEmpty() { $this->_view->plugin('renderToPlaceholder')->__invoke('rendertoplaceholderscript.phtml', 'fooPlaceholder'); $placeholder = new PlaceholderHelper(); - $this->assertEquals("Foo Bar\n", $placeholder->__invoke('fooPlaceholder')->getValue()); + $this->assertEquals("Foo Bar" . PHP_EOL, $placeholder->__invoke('fooPlaceholder')->getValue()); } } From 4f29d61a09a02631d154d40aa4e0dd8f17560653 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 22:55:38 +0200 Subject: [PATCH 10/78] Fixed unit test PhpRendererTest::testNestedRenderingRestoresVariablesCorrectly so that it works on Windows. --- test/PhpRendererTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/PhpRendererTest.php b/test/PhpRendererTest.php index b5567cc8..77b4c52e 100644 --- a/test/PhpRendererTest.php +++ b/test/PhpRendererTest.php @@ -208,7 +208,7 @@ public function testPassingVariablesObjectToSetVarsShouldUseItDirectoy() */ public function testNestedRenderingRestoresVariablesCorrectly() { - $expected = "inner\n

content

"; + $expected = "inner" . PHP_EOL . "

content

"; $this->renderer->resolver()->addPath(__DIR__ . '/_templates'); $test = $this->renderer->render('testNestedOuter.phtml', array('content' => '

content

')); $this->assertEquals($expected, $test); From f5749deb8e47baddfc3c16ff6ec5e0c3dfe05b39 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:00:28 +0200 Subject: [PATCH 11/78] Fixed unit test TemplatePathStackTest::testAllowsRelativePharPath so that it works on Windows --- test/TemplatePathStackTest.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/TemplatePathStackTest.php b/test/TemplatePathStackTest.php index 2c14efd4..737802e6 100644 --- a/test/TemplatePathStackTest.php +++ b/test/TemplatePathStackTest.php @@ -238,10 +238,16 @@ public function testAllowsPassingOptionsToConstructor($arg) public function testAllowsRelativePharPath() { - $path = 'phar://' . __DIR__ . '/_templates/view.phar/start/../views'; + $path = 'phar://' . __DIR__ + . DIRECTORY_SEPARATOR . '_templates' + . DIRECTORY_SEPARATOR . 'view.phar' + . DIRECTORY_SEPARATOR . 'start' + . DIRECTORY_SEPARATOR . '..' + . DIRECTORY_SEPARATOR . 'views'; + $this->stack->addPath($path); - $test = $this->stack->resolve('foo/hello.phtml'); - $this->assertEquals($path . '/foo/hello.phtml', $test); + $test = $this->stack->resolve('foo' . DIRECTORY_SEPARATOR . 'hello.phtml'); + $this->assertEquals($path . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'hello.phtml', $test); } public function testDefaultFileSuffixIsPhtml() From 97b46820210fe2a3b9acd675d2d506180c80ca24 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:27:37 +0200 Subject: [PATCH 12/78] Fixed unit test SitemapTest::testSetServerUrlWithSchemeAndPortAndHostAndPath so that it works on Windows. --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 613d32e7..8d0d6d87 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -239,7 +239,9 @@ public function testSetServerUrlWithSchemeAndPortAndHostAndPath() $this->_helper->setServerUrl('http://sub.example.org:8080/foo/'); $expected = $this->_getExpected('sitemap/serverurl2.xml'); - $this->assertEquals($expected, $this->_helper->render()); + $got = str_replace("\n", PHP_EOL, $this->_helper->render()); + + $this->assertEquals($expected, $got); } public function testGetUserSchemaValidation() From 3900d0c35d8dccf3affa77a2ac41f587f817341d Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:28:34 +0200 Subject: [PATCH 13/78] Fixed unit test SitemapTest::testSetServerUrlWithSchemeAndHost so that it works on Windows. --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 8d0d6d87..66a195b0 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -231,7 +231,9 @@ public function testSetServerUrlWithSchemeAndHost() $this->_helper->setServerUrl('http://sub.example.org'); $expected = $this->_getExpected('sitemap/serverurl1.xml'); - $this->assertEquals($expected, $this->_helper->render()); + $got = str_replace("\n", PHP_EOL, $this->_helper->render()); + + $this->assertEquals($expected, $got); } public function testSetServerUrlWithSchemeAndPortAndHostAndPath() From 29b4161bd197f353fbc7846490d6efec2de610de Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:30:21 +0200 Subject: [PATCH 14/78] Fixed unit test SitemapTest::testDisablingValidators so that it works on Windows. --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 66a195b0..1a2361e4 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -211,7 +211,9 @@ public function testDisablingValidators() $this->_helper->setUseSitemapValidators(false); $expected = $this->_getExpected('sitemap/invalid.xml'); - $this->assertEquals($expected, $this->_helper->render($nav)); + $got = str_replace("\n", PHP_EOL, $this->_helper->render($nav)); + + $this->assertEquals($expected, $got); } public function testSetServerUrlRequiresValidUri() From 401537bcb987941e37a09749d3bbdae37b74efee Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:31:53 +0200 Subject: [PATCH 15/78] Fixed unit test SitemapTest::testDropXmlDeclaration so that it works on Windows. --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 1a2361e4..2201d184 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -181,7 +181,9 @@ public function testDropXmlDeclaration() $this->_helper->setUseXmlDeclaration(false); $expected = $this->_getExpected('sitemap/nodecl.xml'); - $this->assertEquals($expected, $this->_helper->render($this->_nav2)); + $got = str_replace("\n", PHP_EOL, $this->_helper->render($this->_nav2)); + + $this->assertEquals($expected, $got); } public function testThrowExceptionOnInvalidLoc() From 0da79b45d8b49e06e29d22eee7d38752b872965f Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:33:08 +0200 Subject: [PATCH 16/78] Fixed unit test SitemapTest::testSettingBothDepths so that it works on Windows. --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 2201d184..cfdd2b4a 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -173,7 +173,9 @@ public function testSettingBothDepths() $this->_helper->setMinDepth(1)->setMaxDepth(2); $expected = $this->_getExpected('sitemap/depth3.xml'); - $this->assertEquals($expected, $this->_helper->render()); + $got = str_replace("\n", PHP_EOL, $this->_helper->render()); + + $this->assertEquals($expected, $got); } public function testDropXmlDeclaration() From 03531b568939f57bdcb219e066a2011a446ef91b Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:34:23 +0200 Subject: [PATCH 17/78] Fixed unit test SitemapTest::testSettingMinDepth so that it works on Windows. --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index cfdd2b4a..f558238d 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -165,7 +165,9 @@ public function testSettingMinDepth() $this->_helper->setMinDepth(1); $expected = $this->_getExpected('sitemap/depth2.xml'); - $this->assertEquals($expected, $this->_helper->render()); + $got = str_replace("\n", PHP_EOL, $this->_helper->render()); + + $this->assertEquals($expected, $got); } public function testSettingBothDepths() From 6784e9fcf714e7ed553865f4d36c531ed5ea8337 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:36:44 +0200 Subject: [PATCH 18/78] Fixed unit test SitemapTest::testSettingMaxDepth so that it works on Windows --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index f558238d..9fea0200 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -157,7 +157,9 @@ public function testSettingMaxDepth() $this->_helper->setMaxDepth(0); $expected = $this->_getExpected('sitemap/depth1.xml'); - $this->assertEquals($expected, $this->_helper->render()); + $got = str_replace("\n", PHP_EOL, $this->_helper->render()); + + $this->assertEquals($expected, $got); } public function testSettingMinDepth() From 45b1aceb38b152dbf2d4743e837d8dd03e910b79 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:38:00 +0200 Subject: [PATCH 19/78] Fixed unit test SitemapTest::testUseAclButNoRole so that it works on Windows. --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 9fea0200..0701fb16 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -149,7 +149,9 @@ public function testUseAclButNoRole() $this->_helper->setRole(null); $expected = $this->_getExpected('sitemap/acl2.xml'); - $this->assertEquals($expected, $this->_helper->render()); + $got = str_replace("\n", PHP_EOL, $this->_helper->render()); + + $this->assertEquals($expected, $got); } public function testSettingMaxDepth() From 04414f77a2802f71d6e62e1361e2e8aa8a78b8e9 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:38:54 +0200 Subject: [PATCH 20/78] Fixed unit test SitemapTest::testUseAclRoles so that it works on Windows. --- test/Helper/Navigation/SitemapTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 0701fb16..033fcfa7 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -139,7 +139,9 @@ public function testUseAclRoles() $this->_helper->setRole($acl['role']); $expected = $this->_getExpected('sitemap/acl.xml'); - $this->assertEquals($expected, $this->_helper->render()); + $got = str_replace("\n", PHP_EOL, $this->_helper->render()); + + $this->assertEquals($expected, $got); } public function testUseAclButNoRole() From 238ff96260de42b07329122ce2160c7d0e6da5f7 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:41:48 +0200 Subject: [PATCH 21/78] Made sure the Sitemap view helper replaces new lines with the correct EOL character. This fixes a lot of unit tests. --- src/Helper/Navigation/Sitemap.php | 4 ++- test/Helper/Navigation/SitemapTest.php | 36 +++++++------------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index 11410911..d0671251 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -448,6 +448,8 @@ public function render($container = null) $dom->saveXML() : $dom->saveXML($dom->documentElement); - return rtrim($xml, PHP_EOL); + // Replace all new line characters with the correct system EOL character. This is needed + // in order to keep unit tests working. + return str_replace("\n", PHP_EOL, rtrim($xml, PHP_EOL) ); } } diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 033fcfa7..613d32e7 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -139,9 +139,7 @@ public function testUseAclRoles() $this->_helper->setRole($acl['role']); $expected = $this->_getExpected('sitemap/acl.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render()); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render()); } public function testUseAclButNoRole() @@ -151,9 +149,7 @@ public function testUseAclButNoRole() $this->_helper->setRole(null); $expected = $this->_getExpected('sitemap/acl2.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render()); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render()); } public function testSettingMaxDepth() @@ -161,9 +157,7 @@ public function testSettingMaxDepth() $this->_helper->setMaxDepth(0); $expected = $this->_getExpected('sitemap/depth1.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render()); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render()); } public function testSettingMinDepth() @@ -171,9 +165,7 @@ public function testSettingMinDepth() $this->_helper->setMinDepth(1); $expected = $this->_getExpected('sitemap/depth2.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render()); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render()); } public function testSettingBothDepths() @@ -181,9 +173,7 @@ public function testSettingBothDepths() $this->_helper->setMinDepth(1)->setMaxDepth(2); $expected = $this->_getExpected('sitemap/depth3.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render()); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render()); } public function testDropXmlDeclaration() @@ -191,9 +181,7 @@ public function testDropXmlDeclaration() $this->_helper->setUseXmlDeclaration(false); $expected = $this->_getExpected('sitemap/nodecl.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render($this->_nav2)); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render($this->_nav2)); } public function testThrowExceptionOnInvalidLoc() @@ -223,9 +211,7 @@ public function testDisablingValidators() $this->_helper->setUseSitemapValidators(false); $expected = $this->_getExpected('sitemap/invalid.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render($nav)); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render($nav)); } public function testSetServerUrlRequiresValidUri() @@ -245,9 +231,7 @@ public function testSetServerUrlWithSchemeAndHost() $this->_helper->setServerUrl('http://sub.example.org'); $expected = $this->_getExpected('sitemap/serverurl1.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render()); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render()); } public function testSetServerUrlWithSchemeAndPortAndHostAndPath() @@ -255,9 +239,7 @@ public function testSetServerUrlWithSchemeAndPortAndHostAndPath() $this->_helper->setServerUrl('http://sub.example.org:8080/foo/'); $expected = $this->_getExpected('sitemap/serverurl2.xml'); - $got = str_replace("\n", PHP_EOL, $this->_helper->render()); - - $this->assertEquals($expected, $got); + $this->assertEquals($expected, $this->_helper->render()); } public function testGetUserSchemaValidation() From f756afe695147f605b24461ef96201ca5c5a1cb6 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:48:56 +0200 Subject: [PATCH 22/78] Changed the comment to make it more describing --- src/Helper/Navigation/Sitemap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index d0671251..4f1682da 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -448,7 +448,7 @@ public function render($container = null) $dom->saveXML() : $dom->saveXML($dom->documentElement); - // Replace all new line characters with the correct system EOL character. This is needed + // DOMDocument ends lines with a "\n" character. We want this to be the PHP_EOL character // in order to keep unit tests working. return str_replace("\n", PHP_EOL, rtrim($xml, PHP_EOL) ); } From 74437cee13befc0758ea57f4a3eb98b2d51a78a8 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Tue, 3 Jul 2012 23:57:39 +0200 Subject: [PATCH 23/78] Fixed even more unit tests for Windows. --- test/Helper/Navigation/_files/mvc/views/menu.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Helper/Navigation/_files/mvc/views/menu.phtml b/test/Helper/Navigation/_files/mvc/views/menu.phtml index 102fadea..004ee04f 100644 --- a/test/Helper/Navigation/_files/mvc/views/menu.phtml +++ b/test/Helper/Navigation/_files/mvc/views/menu.phtml @@ -9,5 +9,5 @@ foreach ($this->vars('container') as $page) { } $pages = implode(', ', $pages); ?> -Is a container: +Is a container: Pages: From f700d48b6054af957f509fda8352a59ca27afe60 Mon Sep 17 00:00:00 2001 From: Walter Tamboer Date: Wed, 4 Jul 2012 00:23:09 +0200 Subject: [PATCH 24/78] Made sure the EOL character is kept into account when rendering lists --- src/Helper/HtmlList.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Helper/HtmlList.php b/src/Helper/HtmlList.php index b9075bf8..8a42ffc0 100644 --- a/src/Helper/HtmlList.php +++ b/src/Helper/HtmlList.php @@ -52,8 +52,9 @@ public function __invoke(array $items, $ordered = false, $attribs = false, $esca } $list .= '
  • ' . $item . '
  • ' . self::EOL; } else { - if (6 < strlen($list)) { - $list = substr($list, 0, strlen($list) - 6) + $itemLength = 5 + strlen(self::EOL); + if ($itemLength < strlen($list)) { + $list = substr($list, 0, strlen($list) - $itemLength) . $this($item, $ordered, $attribs, $escape) . '' . self::EOL; } else { $list .= '
  • ' . $this($item, $ordered, $attribs, $escape) . '
  • ' . self::EOL; From b43106631ef6ba95926f18bd8cce01013da05590 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 4 Jul 2012 08:10:00 +0200 Subject: [PATCH 25/78] Remove old stuff * Remove PHPTools (PHPNamespacer) * Remove zf1 mvc --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 21d57da5..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "tools/phptools"] - path = tools/phptools - url = git://github.com/ralphschindler/PHPTools.git From 10bbc9608bf4942900cc554079c9cabad917fbe3 Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Wed, 4 Jul 2012 13:07:52 +0200 Subject: [PATCH 26/78] FeedStrategy now sets the charset from the given feeds encoding --- src/Model/FeedModel.php | 16 +++++++++++++--- src/Strategy/FeedStrategy.php | 12 +++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Model/FeedModel.php b/src/Model/FeedModel.php index f146e03c..f6d5dc93 100644 --- a/src/Model/FeedModel.php +++ b/src/Model/FeedModel.php @@ -45,6 +45,16 @@ class FeedModel extends ViewModel */ protected $type = false; + /** + * A feed is always terminal + * + * @var bool + */ + protected $terminate = true; + + /** + * @return \Zend\Feed\Writer\Feed + */ public function getFeed() { if ($this->feed instanceof Feed) { @@ -67,8 +77,8 @@ public function getFeed() /** * Set the feed object - * - * @param Feed $feed + * + * @param Feed $feed * @return FeedModel */ public function setFeed(Feed $feed) @@ -79,7 +89,7 @@ public function setFeed(Feed $feed) /** * Get the feed type - * + * * @return false|string */ public function getFeedType() diff --git a/src/Strategy/FeedStrategy.php b/src/Strategy/FeedStrategy.php index 54da6353..a032296b 100644 --- a/src/Strategy/FeedStrategy.php +++ b/src/Strategy/FeedStrategy.php @@ -162,10 +162,20 @@ public function injectResponse(ViewEvent $e) ? 'application/rss+xml' : 'application/atom+xml'; + $feed = $e->getModel() + ->getFeed(); + + $charset = ''; + + if ($feed instanceof Feed) { + + $charset = '; charset=' . $feed->getEncoding() . ';'; + } + // Populate response $response = $e->getResponse(); $response->setContent($result); $headers = $response->getHeaders(); - $headers->addHeaderLine('content-type', $feedType); + $headers->addHeaderLine('content-type', $feedType . $charset); } } From fd2a195959229f92509518737357f42af9449a66 Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Wed, 4 Jul 2012 14:08:17 +0200 Subject: [PATCH 27/78] updated the strategy so it wouldn't break tests --- src/Strategy/FeedStrategy.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Strategy/FeedStrategy.php b/src/Strategy/FeedStrategy.php index a032296b..7dd47f0e 100644 --- a/src/Strategy/FeedStrategy.php +++ b/src/Strategy/FeedStrategy.php @@ -162,12 +162,12 @@ public function injectResponse(ViewEvent $e) ? 'application/rss+xml' : 'application/atom+xml'; - $feed = $e->getModel() - ->getFeed(); - + $model = $e->getModel(); $charset = ''; - if ($feed instanceof Feed) { + if ($model instanceof Model\FeedModel) { + + $feed = $model->getFeed(); $charset = '; charset=' . $feed->getEncoding() . ';'; } From 7706afd7808c16d2e7e901f1c39f16b4ed98bc1c Mon Sep 17 00:00:00 2001 From: Denis Portnov Date: Wed, 4 Jul 2012 22:15:47 +0400 Subject: [PATCH 28/78] removal of view helpers - Zend\View\Helper\Translator - Zend\View\Helper\FormElement --- src/Helper/FormElement.php | 194 ------------------------------------ src/Helper/HtmlList.php | 7 +- src/Helper/Translator.php | 187 ---------------------------------- src/HelperPluginManager.php | 1 - 4 files changed, 2 insertions(+), 387 deletions(-) delete mode 100644 src/Helper/FormElement.php delete mode 100644 src/Helper/Translator.php diff --git a/src/Helper/FormElement.php b/src/Helper/FormElement.php deleted file mode 100644 index 09b54548..00000000 --- a/src/Helper/FormElement.php +++ /dev/null @@ -1,194 +0,0 @@ -_translator; - } - - /** - * Set translator - * - * @param $translator|null \Zend\Translator\Translator - * @return \Zend\View\Helper\FormElement - * @throws Exception\InvalidArgumentException - */ - public function setTranslator($translator = null) - { - if (null === $translator) { - $this->_translator = null; - } elseif ($translator instanceof \Zend\Translator\Adapter\AbstractAdapter) { - $this->_translator = $translator; - } elseif ($translator instanceof \Zend\Translator\Translator) { - $this->_translator = $translator->getAdapter(); - } else { - throw new Exception\InvalidArgumentException('Invalid translator specified'); - } - - return $this; - } - - /** - * Converts parameter arguments to an element info array. - * - * E.g, formExample($name, $value, $attribs, $options, $listsep) is - * the same thing as formExample(array('name' => ...)). - * - * Note that you cannot pass a 'disable' param; you need to pass - * it as an 'attribs' key. - * - * @access protected - * - * @return array An element info array with keys for name, value, - * attribs, options, listsep, disable, and escape. - */ - protected function _getInfo($name, $value = null, $attribs = null, - $options = null, $listsep = null - ) { - // the baseline info. note that $name serves a dual purpose; - // if an array, it's an element info array that will override - // these baseline values. as such, ignore it for the 'name' - // if it's an array. - $info = array( - 'name' => is_array($name) ? '' : $name, - 'id' => is_array($name) ? '' : $name, - 'value' => $value, - 'attribs' => $attribs, - 'options' => $options, - 'listsep' => $listsep, - 'disable' => false, - 'escape' => true, - ); - - // override with named args - if (is_array($name)) { - // only set keys that are already in info - foreach ($info as $key => $val) { - if (isset($name[$key])) { - $info[$key] = $name[$key]; - } - } - - // If all helper options are passed as an array, attribs may have - // been as well - if (null === $attribs) { - $attribs = $info['attribs']; - } - } - - $attribs = (array)$attribs; - - // Normalize readonly tag - if (array_key_exists('readonly', $attribs)) { - $attribs['readonly'] = 'readonly'; - } - - // Disable attribute - if (array_key_exists('disable', $attribs)) { - if (is_scalar($attribs['disable'])) { - // disable the element - $info['disable'] = (bool)$attribs['disable']; - } else if (is_array($attribs['disable'])) { - $info['disable'] = $attribs['disable']; - } - } - - // Set ID for element - if (array_key_exists('id', $attribs)) { - $info['id'] = (string)$attribs['id']; - } else if ('' !== $info['name']) { - $info['id'] = trim(strtr($info['name'], - array('[' => '-', ']' => '')), '-'); - } - - // Determine escaping from attributes - if (array_key_exists('escape', $attribs)) { - $info['escape'] = (bool)$attribs['escape']; - } - - // Determine listsetp from attributes - if (array_key_exists('listsep', $attribs)) { - $info['listsep'] = (string)$attribs['listsep']; - } - - // Remove attribs that might overwrite the other keys. We do this LAST - // because we needed the other attribs values earlier. - foreach ($info as $key => $val) { - if (array_key_exists($key, $attribs)) { - unset($attribs[$key]); - } - } - $info['attribs'] = $attribs; - - // done! - return $info; - } - - /** - * Creates a hidden element. - * - * We have this as a common method because other elements often - * need hidden elements for their operation. - * - * @access protected - * - * @param $name The element name. - * - * @param $value The element value. - * - * @param $attribs Attributes for the element. - * - * @return string A hidden element. - */ - protected function _hidden($name, $value = null, $attribs = null) - { - $escaper = $this->view->plugin('escape'); - return '_htmlAttribs($attribs) . $this->getClosingBracket(); - } -} diff --git a/src/Helper/HtmlList.php b/src/Helper/HtmlList.php index 8a42ffc0..7c0556a8 100644 --- a/src/Helper/HtmlList.php +++ b/src/Helper/HtmlList.php @@ -30,7 +30,7 @@ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class HtmlList extends FormElement +class HtmlList extends AbstractHtmlElement { /** * Generates a 'List' element. @@ -68,10 +68,7 @@ public function __invoke(array $items, $ordered = false, $attribs = false, $esca $attribs = ''; } - $tag = 'ul'; - if ($ordered) { - $tag = 'ol'; - } + $tag = ($ordered) ? 'ol' : 'ul'; return '<' . $tag . $attribs . '>' . self::EOL . $list . '' . self::EOL; } diff --git a/src/Helper/Translator.php b/src/Helper/Translator.php deleted file mode 100644 index e8242024..00000000 --- a/src/Helper/Translator.php +++ /dev/null @@ -1,187 +0,0 @@ -setTranslator($translate); - } - } - - /** - * Mock __invoke for manual call - * - * @see __invoke - * @param string $messageid Id of the message to be translated - * @return string|\Zend\View\Helper\Translator Translated message - */ - public function translate($messageid = null) - { - $options = func_get_args(); - return call_user_func_array(array($this, '__invoke'), $options); - } - - /** - * Translate a message - * You can give multiple params or an array of params. - * If you want to output another locale just set it as last single parameter - * Example 1: translate('%1\$s + %2\$s', $value1, $value2, $locale); - * Example 2: translate('%1\$s + %2\$s', array($value1, $value2), $locale); - * - * @param string $messageid Id of the message to be translated - * @return string|\Zend\View\Helper\Translator Translated message - */ - public function __invoke($messageid = null) - { - if ($messageid === null) { - return $this; - } - - $translator = $this->getTranslator(); - $options = func_get_args(); - - array_shift($options); - $count = count($options); - $locale = null; - if ($count > 0) { - if (Locale::isLocale($options[($count - 1)]) !== false) { - // Don't treat last option as the locale if doing so will result in an error - if (is_array($options[0]) || @vsprintf($messageid, array_slice($options, 0, -1)) !== false) { - $locale = array_pop($options); - } - } - } - - if ((count($options) === 1) and (is_array($options[0]) === true)) { - $options = $options[0]; - } - - if ($translator !== null) { - $messageid = $translator->translate($messageid, $locale); - } - - if (count($options) === 0) { - return $messageid; - } - - return vsprintf($messageid, $options); - } - - /** - * Sets a translation Adapter for translation - * - * @param Translation|TranslationAdapter $translator - * @return Translator - * @throws Exception\InvalidArgumentException When no or a false instance was set - */ - public function setTranslator($translator) - { - if ($translator instanceof TranslationAdapter) { - $this->translator = $translator; - } else if ($translator instanceof Translation) { - $this->translator = $translator->getAdapter(); - } else { - throw new Exception\InvalidArgumentException( - 'You must set an instance of Zend\Translator\Translator or Zend\Translator\Adapter' - ); - } - - return $this; - } - - /** - * Retrieve translation object - * - * @return TranslationAdapter|null - */ - public function getTranslator() - { - return $this->translator; - } - - /** - * Set's a new locale for all further translations - * - * @param string|Locale $locale New locale to set - * @return Translator - * @throws Exception\RuntimeException When no Translation instance was set - */ - public function setLocale($locale = null) - { - $translator = $this->getTranslator(); - if ($translator === null) { - throw new Exception\RuntimeException( - 'You must set an instance of Zend\Translator\Translator or Zend\Translator\Adapter' - ); - } - - $translator->setLocale($locale); - return $this; - } - - /** - * Returns the set locale for translations - * - * @return string|Locale - * @throws Exception\RuntimeException When no Translation instance was set - */ - public function getLocale() - { - $translator = $this->getTranslator(); - if ($translator === null) { - throw new Exception\RuntimeException( - 'You must set an instance of Zend\Translator\Translator or Zend\Translator\Adapter' - ); - } - - return $translator->getLocale(); - } -} diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 28eb3015..5d649900 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -74,7 +74,6 @@ class HelperPluginManager extends AbstractPluginManager 'renderchildmodel' => 'Zend\View\Helper\RenderChildModel', 'rendertoplaceholder' => 'Zend\View\Helper\RenderToPlaceholder', 'serverurl' => 'Zend\View\Helper\ServerUrl', - 'translator' => 'Zend\View\Helper\Translator', 'viewmodel' => 'Zend\View\Helper\ViewModel', ); From 82d586a92f6f08d5c866dc84cf40952534ba4fb1 Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Wed, 4 Jul 2012 20:06:04 +0100 Subject: [PATCH 29/78] Replaces Zend\View\Helper\Escape with new Zend\View\Helper\EscapeHtml --- src/Helper/Escape.php | 185 ------------------ src/Helper/EscapeHtml.php | 87 ++++++++ src/Helper/Escaper/AbstractHelper.php | 92 +++++++++ .../{EscapeTest.php => EscapeHtmlTest.php} | 56 +++--- 4 files changed, 210 insertions(+), 210 deletions(-) delete mode 100644 src/Helper/Escape.php create mode 100644 src/Helper/EscapeHtml.php create mode 100644 src/Helper/Escaper/AbstractHelper.php rename test/Helper/{EscapeTest.php => EscapeHtmlTest.php} (75%) diff --git a/src/Helper/Escape.php b/src/Helper/Escape.php deleted file mode 100644 index 069e411e..00000000 --- a/src/Helper/Escape.php +++ /dev/null @@ -1,185 +0,0 @@ -supportedEncodings)) { - throw new Exception\InvalidArgumentException( - 'Value of \'' . $encoding . '\' passed to ' . get_called_class() - . '::setEncoding() is invalid. Provide an encoding supported by htmlspecialchars()' - ); - } - $this->encoding = $encoding; - return $this; - } - - /** - * Get the encoding to use for escape operations - * - * @return string - */ - public function getEncoding() - { - return $this->encoding; - } - - /** - * Set a callback to use for escaping - * - * @param callback $callback - * @return Escape - * @throws Exception\InvalidArgumentException if provided callback is not callable - */ - public function setCallback($callback) - { - if (!is_callable($callback)) { - throw new Exception\InvalidArgumentException('Invalid callback provided to ' . get_called_class()); - } - $this->callback = $callback; - return $this; - } - - /** - * Get the attached callback - * - * If none defined, creates a closure wrapping htmlspecialchars, providing - * the currently set encoding. - * - * @return callback - */ - public function getCallback() - { - if (!is_callable($this->callback)) { - $encoding = $this->getEncoding(); - $callback = function($value) use ($encoding) { - return htmlspecialchars($value, ENT_QUOTES, $encoding, false); - }; - $this->setCallback($callback); - } - return $this->callback; - } - - /** - * Invoke this helper: escape a value - * - * @param mixed $value - * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping - * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. - * @throws Exception\InvalidArgumentException - */ - public function __invoke($value, $recurse = self::RECURSE_NONE) - { - if (is_string($value)) { - $callback = $this->getCallback(); - return call_user_func($callback, $value); - } - if (is_array($value)) { - if (!(self::RECURSE_ARRAY & $recurse)) { - throw new Exception\InvalidArgumentException( - 'Array provided to Escape helper, but flags do not allow recursion' - ); - } - foreach ($value as $k => $v) { - $value[$k] = $this->__invoke($v, $recurse); - } - return $value; - } - if (is_object($value)) { - if (!(self::RECURSE_OBJECT & $recurse)) { - // Attempt to cast it to a string - if (method_exists($value, '__toString')) { - $callback = $this->getCallback(); - return call_user_func($callback, (string) $value); - } - - throw new Exception\InvalidArgumentException( - 'Object provided to Escape helper, but flags do not allow recursion' - ); - } - if (method_exists($value, 'toArray')) { - return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); - } - return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); - } - - // At this point, we have a scalar; simply return it - return $value; - } -} diff --git a/src/Helper/EscapeHtml.php b/src/Helper/EscapeHtml.php new file mode 100644 index 00000000..ad6c4c8f --- /dev/null +++ b/src/Helper/EscapeHtml.php @@ -0,0 +1,87 @@ +getEscaper()->escapeHtml($value); + } + if (is_array($value)) { + if (!(self::RECURSE_ARRAY & $recurse)) { + throw new Exception\InvalidArgumentException( + 'Array provided to Escape helper, but flags do not allow recursion' + ); + } + foreach ($value as $k => $v) { + $value[$k] = $this->__invoke($v, $recurse); + } + return $value; + } + if (is_object($value)) { + if (!(self::RECURSE_OBJECT & $recurse)) { + // Attempt to cast it to a string + if (method_exists($value, '__toString')) { + return $this->getEscaper()->escapeHtml((string) $value); + } + throw new Exception\InvalidArgumentException( + 'Object provided to Escape helper, but flags do not allow recursion' + ); + } + if (method_exists($value, 'toArray')) { + return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); + } + return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); + } + // At this point, we have a scalar; simply return it + return $value; + } +} diff --git a/src/Helper/Escaper/AbstractHelper.php b/src/Helper/Escaper/AbstractHelper.php new file mode 100644 index 00000000..10479217 --- /dev/null +++ b/src/Helper/Escaper/AbstractHelper.php @@ -0,0 +1,92 @@ +escaper = $escaper; + $this->encoding = $escaper->getEncoding(); + return $this; + } + + public function getEscaper() + { + if (null === $this->escaper) { + $this->setEscaper(new Escaper\Escaper($this->getEncoding())); + } + return $this->escaper; + } + + /** + * Set the encoding to use for escape operations + * + * @param string $encoding + * @return AbstractEscaper + */ + public function setEncoding($encoding) + { + if (!is_null($this->escaper)) { + throw new Exception\InvalidArgumentException( + 'Encoding cannot be changed once a Zend\Escaper\Escaper object has been' + . ' instantiated by or injected into this Helper.' + ); + } + $this->encoding = $encoding; + return $this; + } + + /** + * Get the encoding to use for escape operations + * + * @return string + */ + public function getEncoding() + { + return $this->encoding; + } + +} \ No newline at end of file diff --git a/test/Helper/EscapeTest.php b/test/Helper/EscapeHtmlTest.php similarity index 75% rename from test/Helper/EscapeTest.php rename to test/Helper/EscapeHtmlTest.php index a7a091e2..20b04e8c 100644 --- a/test/Helper/EscapeTest.php +++ b/test/Helper/EscapeHtmlTest.php @@ -4,9 +4,9 @@ use PHPUnit_Framework_TestCase as TestCase, stdClass, - Zend\View\Helper\Escape as EscapeHelper; + Zend\View\Helper\EscapeHtml as EscapeHelper; -class EscapeTest extends TestCase +class EscapeHtmlTest extends TestCase { protected $supportedEncodings = array( @@ -20,7 +20,6 @@ class EscapeTest extends TestCase 'cp932', '932', 'euc-jp', 'eucjp', 'eucjp-win', 'macroman' ); - public function setUp() { @@ -32,36 +31,39 @@ public function testUsesUtf8EncodingByDefault() $this->assertEquals('UTF-8', $this->helper->getEncoding()); } - public function testEncodingIsMutable() + /** + * @expectedException \Zend\View\Exception\InvalidArgumentException + */ + public function testEncodingIsImmutable() { $this->helper->setEncoding('BIG5-HKSCS'); - $this->assertEquals('BIG5-HKSCS', $this->helper->getEncoding()); - } - - public function testDefaultCallbackIsDefined() - { - $callback = $this->helper->getCallback(); - $this->assertTrue(is_callable($callback)); + $this->helper->getEscaper(); + $this->helper->setEncoding('UTF-8'); } - public function testCallbackIsMutable() + public function testGetEscaperCreatesDefaultInstanceWithCorrectEncoding() { - $this->helper->setCallback('strip_tags'); // Don't do this at home ;) - $this->assertEquals('strip_tags', $this->helper->getCallback()); + $this->helper->setEncoding('BIG5-HKSCS'); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); } - public function testSettingInvalidCallbackRaisesException() + public function testSettingEscaperObjectAlsoSetsEncoding() { - $this->setExpectedException('Zend\View\Exception\ExceptionInterface'); - $this->helper->setCallback(3.1415); + $escaper = new \Zend\Escaper\Escaper('big5-hkscs'); + $this->helper->setEscaper($escaper); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); } - public function testInvokingCallbackEscapesText() + public function testEscapehtmlCalledOnEscaperObject() { - $text = 'Hey! This is some Text! Yo!'; - $expected = htmlspecialchars($text, ENT_COMPAT, 'UTF-8', false); - $test = $this->helper->__invoke($text); - $this->assertEquals($expected, $test); + $escaper = $this->getMock('\\Zend\\Escaper\\Escaper'); + $escaper->expects($this->any())->method('escapeHtml'); + $this->helper->setEscaper($escaper); + $this->helper->__invoke('foo'); } public function testAllowsRecursiveEscapingOfArrays() @@ -152,7 +154,7 @@ public function testCanRecurseObjectProperties() } /** - * @expectedException \Zend\View\Exception\InvalidArgumentException + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException * * PHP 5.3 instates default encoding on empty string instead of the expected * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts @@ -162,17 +164,20 @@ public function testCanRecurseObjectProperties() public function testSettingEncodingToEmptyStringShouldThrowException() { $this->helper->setEncoding(''); + $this->helper->getEscaper(); } public function testSettingValidEncodingShouldNotThrowExceptions() { foreach ($this->supportedEncodings as $value) { - $this->helper->setEncoding($value); + $helper = new EscapeHelper; + $helper->setEncoding($value); + $helper->getEscaper(); } } /** - * @expectedException \Zend\View\Exception\InvalidArgumentException + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException * * All versions of PHP - when an invalid encoding is set on htmlspecialchars() * a warning level error is issued and escaping continues with the default encoding @@ -182,5 +187,6 @@ public function testSettingValidEncodingShouldNotThrowExceptions() public function testSettingEncodingToInvalidValueShouldThrowException() { $this->helper->setEncoding('completely-invalid'); + $this->helper->getEscaper(); } } From 5aee60e36c94ef311111a4b06041231fd46dd112 Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Wed, 4 Jul 2012 20:12:06 +0100 Subject: [PATCH 30/78] Added helpers for other escaper functions --- src/Helper/EscapeCss.php | 87 +++++++++++++++++++++++++++++++++++ src/Helper/EscapeHtmlAttr.php | 87 +++++++++++++++++++++++++++++++++++ src/Helper/EscapeJs.php | 87 +++++++++++++++++++++++++++++++++++ src/Helper/EscapeUrl.php | 87 +++++++++++++++++++++++++++++++++++ 4 files changed, 348 insertions(+) create mode 100644 src/Helper/EscapeCss.php create mode 100644 src/Helper/EscapeHtmlAttr.php create mode 100644 src/Helper/EscapeJs.php create mode 100644 src/Helper/EscapeUrl.php diff --git a/src/Helper/EscapeCss.php b/src/Helper/EscapeCss.php new file mode 100644 index 00000000..d23f09e4 --- /dev/null +++ b/src/Helper/EscapeCss.php @@ -0,0 +1,87 @@ +getEscaper()->escapeCss($value); + } + if (is_array($value)) { + if (!(self::RECURSE_ARRAY & $recurse)) { + throw new Exception\InvalidArgumentException( + 'Array provided to Escape helper, but flags do not allow recursion' + ); + } + foreach ($value as $k => $v) { + $value[$k] = $this->__invoke($v, $recurse); + } + return $value; + } + if (is_object($value)) { + if (!(self::RECURSE_OBJECT & $recurse)) { + // Attempt to cast it to a string + if (method_exists($value, '__toString')) { + return $this->getEscaper()->escapeCss((string) $value); + } + throw new Exception\InvalidArgumentException( + 'Object provided to Escape helper, but flags do not allow recursion' + ); + } + if (method_exists($value, 'toArray')) { + return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); + } + return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); + } + // At this point, we have a scalar; simply return it + return $value; + } +} diff --git a/src/Helper/EscapeHtmlAttr.php b/src/Helper/EscapeHtmlAttr.php new file mode 100644 index 00000000..da504273 --- /dev/null +++ b/src/Helper/EscapeHtmlAttr.php @@ -0,0 +1,87 @@ +getEscaper()->escapeHtmlAttr($value); + } + if (is_array($value)) { + if (!(self::RECURSE_ARRAY & $recurse)) { + throw new Exception\InvalidArgumentException( + 'Array provided to Escape helper, but flags do not allow recursion' + ); + } + foreach ($value as $k => $v) { + $value[$k] = $this->__invoke($v, $recurse); + } + return $value; + } + if (is_object($value)) { + if (!(self::RECURSE_OBJECT & $recurse)) { + // Attempt to cast it to a string + if (method_exists($value, '__toString')) { + return $this->getEscaper()->escapeHtmlAttr((string) $value); + } + throw new Exception\InvalidArgumentException( + 'Object provided to Escape helper, but flags do not allow recursion' + ); + } + if (method_exists($value, 'toArray')) { + return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); + } + return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); + } + // At this point, we have a scalar; simply return it + return $value; + } +} diff --git a/src/Helper/EscapeJs.php b/src/Helper/EscapeJs.php new file mode 100644 index 00000000..71819acc --- /dev/null +++ b/src/Helper/EscapeJs.php @@ -0,0 +1,87 @@ +getEscaper()->escapeJs($value); + } + if (is_array($value)) { + if (!(self::RECURSE_ARRAY & $recurse)) { + throw new Exception\InvalidArgumentException( + 'Array provided to Escape helper, but flags do not allow recursion' + ); + } + foreach ($value as $k => $v) { + $value[$k] = $this->__invoke($v, $recurse); + } + return $value; + } + if (is_object($value)) { + if (!(self::RECURSE_OBJECT & $recurse)) { + // Attempt to cast it to a string + if (method_exists($value, '__toString')) { + return $this->getEscaper()->escapeJs((string) $value); + } + throw new Exception\InvalidArgumentException( + 'Object provided to Escape helper, but flags do not allow recursion' + ); + } + if (method_exists($value, 'toArray')) { + return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); + } + return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); + } + // At this point, we have a scalar; simply return it + return $value; + } +} diff --git a/src/Helper/EscapeUrl.php b/src/Helper/EscapeUrl.php new file mode 100644 index 00000000..5d71fbd4 --- /dev/null +++ b/src/Helper/EscapeUrl.php @@ -0,0 +1,87 @@ +getEscaper()->escapeUrl($value); + } + if (is_array($value)) { + if (!(self::RECURSE_ARRAY & $recurse)) { + throw new Exception\InvalidArgumentException( + 'Array provided to Escape helper, but flags do not allow recursion' + ); + } + foreach ($value as $k => $v) { + $value[$k] = $this->__invoke($v, $recurse); + } + return $value; + } + if (is_object($value)) { + if (!(self::RECURSE_OBJECT & $recurse)) { + // Attempt to cast it to a string + if (method_exists($value, '__toString')) { + return $this->getEscaper()->escapeUrl((string) $value); + } + throw new Exception\InvalidArgumentException( + 'Object provided to Escape helper, but flags do not allow recursion' + ); + } + if (method_exists($value, 'toArray')) { + return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); + } + return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); + } + // At this point, we have a scalar; simply return it + return $value; + } +} From b03c84c5d8f33a66f41df7ef390f1ea74c31ca43 Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Wed, 4 Jul 2012 20:38:00 +0100 Subject: [PATCH 31/78] Updated View Helpers to use new Escaper class & supporting helpers --- src/Helper/AbstractHtmlElement.php | 2 +- src/Helper/FormElement.php | 2 +- src/Helper/HtmlList.php | 2 +- src/Helper/Navigation/AbstractHelper.php | 2 +- src/Helper/Navigation/Breadcrumbs.php | 2 +- src/Helper/Navigation/Menu.php | 2 +- .../Placeholder/Container/AbstractStandalone.php | 13 +++++++++++-- src/HelperPluginManager.php | 6 +++++- 8 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Helper/AbstractHtmlElement.php b/src/Helper/AbstractHtmlElement.php index a2bea0da..35757a78 100644 --- a/src/Helper/AbstractHtmlElement.php +++ b/src/Helper/AbstractHtmlElement.php @@ -84,7 +84,7 @@ protected function _isXhtml() protected function _htmlAttribs($attribs) { $xhtml = ''; - $escaper = $this->view->plugin('escape'); + $escaper = $this->view->plugin('escapehtml'); foreach ((array) $attribs as $key => $val) { $key = $escaper($key); diff --git a/src/Helper/FormElement.php b/src/Helper/FormElement.php index 09b54548..a172f334 100644 --- a/src/Helper/FormElement.php +++ b/src/Helper/FormElement.php @@ -185,7 +185,7 @@ protected function _getInfo($name, $value = null, $attribs = null, */ protected function _hidden($name, $value = null, $attribs = null) { - $escaper = $this->view->plugin('escape'); + $escaper = $this->view->plugin('escapeHtml'); return 'view->plugin('escape'); + $escaper = $this->view->plugin('escapeHtml'); $item = $escaper($item); } $list .= '
  • ' . $item . '
  • ' . self::EOL; diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index d6a2361d..252c0b9f 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -673,7 +673,7 @@ public function htmlify(AbstractPage $page) 'target' => $page->getTarget() ); - $escaper = $this->view->plugin('escape'); + $escaper = $this->view->plugin('escapeHtml'); return '_htmlAttribs($attribs) . '>' . $escaper($label) diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php index aec20ac9..6fbda7d4 100644 --- a/src/Helper/Navigation/Breadcrumbs.php +++ b/src/Helper/Navigation/Breadcrumbs.php @@ -191,7 +191,7 @@ public function renderStraight($container = null) if ($this->getUseTranslator() && $t = $this->getTranslator()) { $html = $t->translate($html); } - $escaper = $this->view->plugin('escape'); + $escaper = $this->view->plugin('escapeHtml'); $html = $escaper($html); } diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php index 96cfffeb..6c3e66d3 100644 --- a/src/Helper/Navigation/Menu.php +++ b/src/Helper/Navigation/Menu.php @@ -233,7 +233,7 @@ public function htmlify(AbstractPage $page) $element = 'span'; } - $escaper = $this->view->plugin('escape'); + $escaper = $this->view->plugin('escapeHtml'); return '<' . $element . $this->_htmlAttribs($attribs) . '>' . $escaper($label) . ''; diff --git a/src/Helper/Placeholder/Container/AbstractStandalone.php b/src/Helper/Placeholder/Container/AbstractStandalone.php index 34424f96..e522ee0c 100644 --- a/src/Helper/Placeholder/Container/AbstractStandalone.php +++ b/src/Helper/Placeholder/Container/AbstractStandalone.php @@ -127,9 +127,18 @@ protected function _escape($string) && method_exists($this->view, 'getEncoding') ) { $enc = $this->view->getEncoding(); + $escaper = $this->view->plugin('escapeHtml'); + return $escaper((string) $string); } - - return htmlspecialchars((string) $string, ENT_COMPAT, $enc); + /** + * bump this out to a protected method to kill the instance penalty! + */ + $escaper = new \Zend\Escaper\Escaper($enc); + return $escaper->escapeHtml((string) $string); + /** + * Replaced to ensure consistent escaping + */ + //return htmlspecialchars((string) $string, ENT_COMPAT, $enc); } /** diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 28eb3015..c5584a27 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -52,7 +52,11 @@ class HelperPluginManager extends AbstractPluginManager 'url' => 'Zend\View\Helper\Url', 'cycle' => 'Zend\View\Helper\Cycle', 'declarevars' => 'Zend\View\Helper\DeclareVars', - 'escape' => 'Zend\View\Helper\Escape', + 'escapehtml' => 'Zend\View\Helper\EscapeHtml', + 'escapehtmlattr' => 'Zend\View\Helper\EscapeHtmlAttr', + 'escapejs' => 'Zend\View\Helper\EscapeJs', + 'escapecss' => 'Zend\View\Helper\EscapeCss', + 'escapeurl' => 'Zend\View\Helper\EscapeUrl', 'gravatar' => 'Zend\View\Helper\Gravatar', 'headlink' => 'Zend\View\Helper\HeadLink', 'headmeta' => 'Zend\View\Helper\HeadMeta', From 000f56a3aa0be145ae12724bdaa73e108b01c57d Mon Sep 17 00:00:00 2001 From: Adam Lundrigan Date: Thu, 5 Jul 2012 00:33:37 -0230 Subject: [PATCH 32/78] Initial work towards updating Zend\Form view helpers to use Zend\Escaper --- src/Helper/EscapeHtmlAttr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/EscapeHtmlAttr.php b/src/Helper/EscapeHtmlAttr.php index da504273..993f9204 100644 --- a/src/Helper/EscapeHtmlAttr.php +++ b/src/Helper/EscapeHtmlAttr.php @@ -32,7 +32,7 @@ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class EscapeCss extends Escaper\AbstractHelper +class EscapeHtmlAttr extends Escaper\AbstractHelper { /**@+ * @const Recursion constants From 085eab63f9ac9cd977e039eee9135ddc5e05934e Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Thu, 5 Jul 2012 09:53:40 +0200 Subject: [PATCH 33/78] RenderToPlaceholderTest - The expected file line-ending is just \n so comparing it to PHP_EOL fails on Windows --- test/Helper/RenderToPlaceholderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Helper/RenderToPlaceholderTest.php b/test/Helper/RenderToPlaceholderTest.php index 7b925b64..edc67e3f 100644 --- a/test/Helper/RenderToPlaceholderTest.php +++ b/test/Helper/RenderToPlaceholderTest.php @@ -48,7 +48,7 @@ public function testDefaultEmpty() { $this->_view->plugin('renderToPlaceholder')->__invoke('rendertoplaceholderscript.phtml', 'fooPlaceholder'); $placeholder = new PlaceholderHelper(); - $this->assertEquals("Foo Bar" . PHP_EOL, $placeholder->__invoke('fooPlaceholder')->getValue()); + $this->assertEquals("Foo Bar" . "\n", $placeholder->__invoke('fooPlaceholder')->getValue()); } } From 78c71a5b75ec24401f39a15cef6f2e5e4dc62c02 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Thu, 5 Jul 2012 09:55:00 +0200 Subject: [PATCH 34/78] PhpRendererTest.php - The expected file line-ending is just \n so comparing it to PHP_EOL fails on Window --- test/PhpRendererTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/PhpRendererTest.php b/test/PhpRendererTest.php index 77b4c52e..b5567cc8 100644 --- a/test/PhpRendererTest.php +++ b/test/PhpRendererTest.php @@ -208,7 +208,7 @@ public function testPassingVariablesObjectToSetVarsShouldUseItDirectoy() */ public function testNestedRenderingRestoresVariablesCorrectly() { - $expected = "inner" . PHP_EOL . "

    content

    "; + $expected = "inner\n

    content

    "; $this->renderer->resolver()->addPath(__DIR__ . '/_templates'); $test = $this->renderer->render('testNestedOuter.phtml', array('content' => '

    content

    ')); $this->assertEquals($expected, $test); From af20ceb402c9999eb2f3b74b9cffe7404402659c Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Thu, 5 Jul 2012 10:00:18 +0200 Subject: [PATCH 35/78] Zend\View\Helper\Navigation\Sitemap - The expected file line-ending is just \n so comparing it to PHP_EOL fails on Window --- src/Helper/Navigation/Sitemap.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index 4f1682da..11410911 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -448,8 +448,6 @@ public function render($container = null) $dom->saveXML() : $dom->saveXML($dom->documentElement); - // DOMDocument ends lines with a "\n" character. We want this to be the PHP_EOL character - // in order to keep unit tests working. - return str_replace("\n", PHP_EOL, rtrim($xml, PHP_EOL) ); + return rtrim($xml, PHP_EOL); } } From 8e5bf534cd0e3d5442d9800396e56d0b8fcbeaf1 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Thu, 5 Jul 2012 10:12:59 +0200 Subject: [PATCH 36/78] Zend\View\Helper\Navigation - fix Windows newline issues --- test/Helper/Navigation/AbstractTest.php | 2 +- test/Helper/Navigation/LinksTest.php | 10 ++++++++++ test/Helper/Navigation/MenuTest.php | 10 ++++++++++ test/Helper/Navigation/NavigationTest.php | 10 ++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/test/Helper/Navigation/AbstractTest.php b/test/Helper/Navigation/AbstractTest.php index c76b5e9c..100c27c4 100644 --- a/test/Helper/Navigation/AbstractTest.php +++ b/test/Helper/Navigation/AbstractTest.php @@ -153,7 +153,7 @@ protected function setUp() } /** - * Returns the contens of the exepcted $file + * Returns the contens of the expected $file * @param string $file * @return string */ diff --git a/test/Helper/Navigation/LinksTest.php b/test/Helper/Navigation/LinksTest.php index 1326ccf4..bcdcc69d 100644 --- a/test/Helper/Navigation/LinksTest.php +++ b/test/Helper/Navigation/LinksTest.php @@ -729,4 +729,14 @@ public function testSetMinDepth() $this->assertEquals($expected, $actual); } + + /** + * Returns the contens of the expected $file, normalizes newlines + * @param string $file + * @return string + */ + protected function _getExpected($file) + { + return str_replace("\n", PHP_EOL, parent::_getExpected($file)); + } } diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php index b7d52ec6..40a621de 100644 --- a/test/Helper/Navigation/MenuTest.php +++ b/test/Helper/Navigation/MenuTest.php @@ -496,4 +496,14 @@ public function testOptionOnlyActiveBranchNoParentsAndBothDepthsSpecified() $this->assertEquals($expected, $actual); } + + /** + * Returns the contens of the expected $file, normalizes newlines + * @param string $file + * @return string + */ + protected function _getExpected($file) + { + return str_replace("\n", PHP_EOL, parent::_getExpected($file)); + } } diff --git a/test/Helper/Navigation/NavigationTest.php b/test/Helper/Navigation/NavigationTest.php index 9ca978c6..ad95e395 100644 --- a/test/Helper/Navigation/NavigationTest.php +++ b/test/Helper/Navigation/NavigationTest.php @@ -420,4 +420,14 @@ public function testRenderInvisibleItem() $this->assertTrue(strpos($render, 'p2') !== false); } + + /** + * Returns the contens of the expected $file, normalizes newlines + * @param string $file + * @return string + */ + protected function _getExpected($file) + { + return str_replace("\n", PHP_EOL, parent::_getExpected($file)); + } } From a5040530d48abec35a0fa7ff99d68fb08d7725c8 Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Wed, 4 Jul 2012 17:14:47 +0200 Subject: [PATCH 37/78] due to the nature of navigation not having duplicate by pure configuration is almost impossible --- src/Helper/Navigation/Sitemap.php | 42 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index 4f1682da..d7cb70a2 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -91,6 +91,13 @@ class Sitemap extends AbstractHelper */ protected $serverUrl; + /** + * List of urls in the sitemap + * + * @var array + */ + protected $urls = array(); + /** * Helper entry point * @@ -284,11 +291,17 @@ public function url(AbstractPage $page) $curDoc = $basePathHelper(); $curDoc = ('/' == $curDoc) ? '' : trim($curDoc, '/'); $url = rtrim($this->getServerUrl(), '/') . '/' - . $curDoc - . (empty($curDoc) ? '' : '/') . $href; + . $curDoc + . (empty($curDoc) ? '' : '/') . $href; + } + + if (! in_array($url, $this->urls)) { + + $this->urls[] = $url; + return $this->xmlEscape($url); } - return $this->xmlEscape($url); + return null; } /** @@ -353,6 +366,7 @@ public function getDomSitemap(AbstractContainer $container = null) // get absolute url from page if (!$url = $this->url($page)) { // skip page if it has no url (rare case) + // or already is in the sitemap continue; } @@ -364,14 +378,14 @@ public function getDomSitemap(AbstractContainer $container = null) && !$locValidator->isValid($url) ) { throw new Exception\RuntimeException(sprintf( - 'Encountered an invalid URL for Sitemap XML: "%s"', - $url + 'Encountered an invalid URL for Sitemap XML: "%s"', + $url )); } // 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)) { @@ -386,7 +400,7 @@ public function getDomSitemap(AbstractContainer $container = null) $lastmodValidator->isValid($lastmod)) { $urlNode->appendChild( $dom->createElementNS(self::SITEMAP_NS, 'lastmod', - $lastmod) + $lastmod) ); } } @@ -398,7 +412,7 @@ public function getDomSitemap(AbstractContainer $container = null) $changefreqValidator->isValid($changefreq)) { $urlNode->appendChild( $dom->createElementNS(self::SITEMAP_NS, 'changefreq', - $changefreq) + $changefreq) ); } } @@ -410,7 +424,7 @@ public function getDomSitemap(AbstractContainer $container = null) $priorityValidator->isValid($priority)) { $urlNode->appendChild( $dom->createElementNS(self::SITEMAP_NS, 'priority', - $priority) + $priority) ); } } @@ -420,8 +434,8 @@ public function getDomSitemap(AbstractContainer $container = null) if ($this->getUseSchemaValidation()) { if (!@$dom->schemaValidate(self::SITEMAP_XSD)) { throw new Exception\RuntimeException(sprintf( - 'Sitemap is invalid according to XML Schema at "%s"', - self::SITEMAP_XSD + 'Sitemap is invalid according to XML Schema at "%s"', + self::SITEMAP_XSD )); } } @@ -437,7 +451,7 @@ public function getDomSitemap(AbstractContainer $container = null) * Implements {@link HelperInterface::render()}. * * @param link|AbstractContainer $container [optional] container to render. Default is - * to render the container registered in the + * to render the container registered in the * helper. * @return string helper output */ @@ -445,8 +459,8 @@ public function render($container = null) { $dom = $this->getDomSitemap($container); $xml = $this->getUseXmlDeclaration() ? - $dom->saveXML() : - $dom->saveXML($dom->documentElement); + $dom->saveXML() : + $dom->saveXML($dom->documentElement); // DOMDocument ends lines with a "\n" character. We want this to be the PHP_EOL character // in order to keep unit tests working. From 251500634fd59d4bc468019f5bed7d7d31f1964e Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Wed, 4 Jul 2012 20:47:48 +0200 Subject: [PATCH 38/78] Cosmetic update, didn't notice i moved those two lines --- src/Helper/Navigation/Sitemap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index d7cb70a2..1e4783b3 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -291,8 +291,8 @@ public function url(AbstractPage $page) $curDoc = $basePathHelper(); $curDoc = ('/' == $curDoc) ? '' : trim($curDoc, '/'); $url = rtrim($this->getServerUrl(), '/') . '/' - . $curDoc - . (empty($curDoc) ? '' : '/') . $href; + . $curDoc + . (empty($curDoc) ? '' : '/') . $href; } if (! in_array($url, $this->urls)) { From 27111ea89e4efdca69bc303ab048cdc6b75e9eb3 Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Thu, 5 Jul 2012 13:18:36 +0200 Subject: [PATCH 39/78] Reset the urls before each render --- src/Helper/Navigation/Sitemap.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index 1e4783b3..41899c33 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -457,6 +457,9 @@ public function getDomSitemap(AbstractContainer $container = null) */ public function render($container = null) { + // Reset the urls + $this->urls = array(); + $dom = $this->getDomSitemap($container); $xml = $this->getUseXmlDeclaration() ? $dom->saveXML() : From 52ec94e4926299ff2a92a96df2712c9b4a809600 Mon Sep 17 00:00:00 2001 From: Antoine Hedgecock Date: Thu, 5 Jul 2012 13:22:01 +0200 Subject: [PATCH 40/78] moved the url reset --- src/Helper/Navigation/Sitemap.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index 41899c33..b0d0a1d2 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -322,6 +322,9 @@ public function url(AbstractPage $page) */ public function getDomSitemap(AbstractContainer $container = null) { + // Reset the urls + $this->urls = array(); + if (null === $container) { $container = $this->getContainer(); } @@ -457,9 +460,6 @@ public function getDomSitemap(AbstractContainer $container = null) */ public function render($container = null) { - // Reset the urls - $this->urls = array(); - $dom = $this->getDomSitemap($container); $xml = $this->getUseXmlDeclaration() ? $dom->saveXML() : From 05b32b4ab7821c5a7069cca1664fc27e636a11e2 Mon Sep 17 00:00:00 2001 From: vahid sohrabloo Date: Thu, 5 Jul 2012 19:23:54 +0430 Subject: [PATCH 41/78] append child to capture ZF2-233 --- src/Model/ModelInterface.php | 19 +++++++++++++++++- src/Model/ViewModel.php | 37 ++++++++++++++++++++++++++++++++++- src/Renderer/JsonRenderer.php | 1 + src/View.php | 8 +++++++- 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/src/Model/ModelInterface.php b/src/Model/ModelInterface.php index ea2c778e..25b06e73 100644 --- a/src/Model/ModelInterface.php +++ b/src/Model/ModelInterface.php @@ -108,9 +108,10 @@ public function getTemplate(); * * @param ModelInterface $child * @param null|string $captureTo Optional; if specified, the "capture to" value to set on the child + * @param null|bool $append Optional; if specified, append to child with the same capture * @return ModelInterface */ - public function addChild(ModelInterface $child, $captureTo = null); + public function addChild(ModelInterface $child, $captureTo = null, $append = false); /** * Return all children. @@ -157,4 +158,20 @@ public function setTerminal($terminate); * @return bool */ public function terminate(); + + + /** + * Set flag indicating whether or not append to child with the same capture + * + * @param bool $append + * @return ModelInterface + */ + public function setAppend($append); + + /** + * Is this append to child with the same capture? + * + * @return bool + */ + public function isAppend(); } diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index cd3aa760..e467e78e 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -76,6 +76,14 @@ class ViewModel implements ModelInterface * @var array|ArrayAccess&Traversable */ protected $variables = array(); + + + /** + * Is this append to child with the same capture? + * + * @var bool + */ + protected $append = false; /** * Constructor @@ -284,14 +292,19 @@ public function getTemplate() * * @param ModelInterface $child * @param null|string $captureTo Optional; if specified, the "capture to" value to set on the child + * @param null|bool $append Optional; if specified, append to child with the same capture * @return ViewModel */ - public function addChild(ModelInterface $child, $captureTo = null) + public function addChild(ModelInterface $child, $captureTo = null, $append = null) { $this->children[] = $child; if (null !== $captureTo) { $child->setCaptureTo($captureTo); } + if (null !== $captureTo) { + $child->setAppend($append); + } + return $this; } @@ -360,6 +373,28 @@ public function terminate() { return $this->terminate; } + + /** + * Set flag indicating whether or not append to child with the same capture + * + * @param bool $append + * @return ViewModel + */ + public function setAppend($append) + { + $this->append = (bool) $append; + return $this; + } + + /** + * Is this append to child with the same capture? + * + * @return bool + */ + public function isAppend() + { + return $this->append; + } /** * Return count of children diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php index 9db05876..478bac3f 100644 --- a/src/Renderer/JsonRenderer.php +++ b/src/Renderer/JsonRenderer.php @@ -224,6 +224,7 @@ 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? $values[$captureTo] = $childValues; } elseif ($mergeChildren) { // Merging values with parent diff --git a/src/View.php b/src/View.php index 1733f7ff..457fd151 100644 --- a/src/View.php +++ b/src/View.php @@ -243,7 +243,13 @@ protected function renderChildren(Model $model) $child->setOption('has_parent', null); $capture = $child->captureTo(); if (!empty($capture)) { - $model->setVariable($capture, $result); + if($child->isAppend()) { + $oldResult=$model->{$capture}; + $model->setVariable($capture, $oldResult.$result); + } + else { + $model->setVariable($capture, $result); + } } } } From 243687e2df0fa2afdf45b7c15b1fa772cd2813ba Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Thu, 5 Jul 2012 18:35:30 +0100 Subject: [PATCH 42/78] Incorrect class name for EscapeUrl helper. Everyone has a Homer day... --- src/Helper/EscapeUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/EscapeUrl.php b/src/Helper/EscapeUrl.php index 5d71fbd4..b77c6f42 100644 --- a/src/Helper/EscapeUrl.php +++ b/src/Helper/EscapeUrl.php @@ -32,7 +32,7 @@ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class EscapeCss extends Escaper\AbstractHelper +class EscapeUrl extends Escaper\AbstractHelper { /**@+ * @const Recursion constants From fe7fd3e7a8ff1a3ce173f615c0895e62a335898f Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Thu, 5 Jul 2012 18:55:22 +0100 Subject: [PATCH 43/78] Added test case for EscapeHtmlAttr and revised class name correctly --- src/Helper/EscapeHtmlAttr.php | 2 +- test/Helper/EscapeHtmlAttrTest.php | 195 +++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 test/Helper/EscapeHtmlAttrTest.php diff --git a/src/Helper/EscapeHtmlAttr.php b/src/Helper/EscapeHtmlAttr.php index da504273..993f9204 100644 --- a/src/Helper/EscapeHtmlAttr.php +++ b/src/Helper/EscapeHtmlAttr.php @@ -32,7 +32,7 @@ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class EscapeCss extends Escaper\AbstractHelper +class EscapeHtmlAttr extends Escaper\AbstractHelper { /**@+ * @const Recursion constants diff --git a/test/Helper/EscapeHtmlAttrTest.php b/test/Helper/EscapeHtmlAttrTest.php new file mode 100644 index 00000000..42f35968 --- /dev/null +++ b/test/Helper/EscapeHtmlAttrTest.php @@ -0,0 +1,195 @@ +helper = new EscapeHelper; + } + + public function testUsesUtf8EncodingByDefault() + { + $this->assertEquals('UTF-8', $this->helper->getEncoding()); + } + + /** + * @expectedException \Zend\View\Exception\InvalidArgumentException + */ + public function testEncodingIsImmutable() + { + $this->helper->setEncoding('BIG5-HKSCS'); + $this->helper->getEscaper(); + $this->helper->setEncoding('UTF-8'); + } + + public function testGetEscaperCreatesDefaultInstanceWithCorrectEncoding() + { + $this->helper->setEncoding('BIG5-HKSCS'); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); + } + + public function testSettingEscaperObjectAlsoSetsEncoding() + { + $escaper = new \Zend\Escaper\Escaper('big5-hkscs'); + $this->helper->setEscaper($escaper); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); + } + + public function testEscapehtmlCalledOnEscaperObject() + { + $escaper = $this->getMock('\\Zend\\Escaper\\Escaper'); + $escaper->expects($this->any())->method('escapeHtmlAttr'); + $this->helper->setEscaper($escaper); + $this->helper->__invoke('foo'); + } + + public function testAllowsRecursiveEscapingOfArrays() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $expected = array( + 'foo' => '<b>bar</b>', + 'baz' => array( + '<em>bat</em>', + 'second' => array( + '<i>third</i>', + ), + ), + ); + $test = $this->helper->__invoke($original, EscapeHelper::RECURSE_ARRAY); + $this->assertEquals($expected, $test); + } + + public function testWillCastObjectsToStringsBeforeEscaping() + { + $object = new TestAsset\Stringified; + $test = $this->helper->__invoke($object); + $this->assertEquals( + 'ZendTest\View\Helper\TestAsset\Stringified', + $test + ); + } + + public function testCanRecurseObjectImplementingToArray() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $object = new TestAsset\ToArray(); + $object->array = $original; + + $expected = array( + 'foo' => '<b>bar</b>', + 'baz' => array( + '<em>bat</em>', + 'second' => array( + '<i>third</i>', + ), + ), + ); + $test = $this->helper->__invoke($object, EscapeHelper::RECURSE_OBJECT); + $this->assertEquals($expected, $test); + } + + public function testCanRecurseObjectProperties() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $object = new stdClass(); + foreach ($original as $key => $value) { + $object->$key = $value; + } + + $expected = array( + 'foo' => '<b>bar</b>', + 'baz' => array( + '<em>bat</em>', + 'second' => array( + '<i>third</i>', + ), + ), + ); + $test = $this->helper->__invoke($object, EscapeHelper::RECURSE_OBJECT); + $this->assertEquals($expected, $test); + } + + /** + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException + * + * PHP 5.3 instates default encoding on empty string instead of the expected + * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts + * to guess the encoding or take it from php.ini default_charset when an empty + * string is set. Both are insecure behaviours. + */ + public function testSettingEncodingToEmptyStringShouldThrowException() + { + $this->helper->setEncoding(''); + $this->helper->getEscaper(); + } + + public function testSettingValidEncodingShouldNotThrowExceptions() + { + foreach ($this->supportedEncodings as $value) { + $helper = new EscapeHelper; + $helper->setEncoding($value); + $helper->getEscaper(); + } + } + + /** + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException + * + * All versions of PHP - when an invalid encoding is set on htmlspecialchars() + * a warning level error is issued and escaping continues with the default encoding + * for that PHP version. Preventing the continuation behaviour offsets display_errors + * off in production env. + */ + public function testSettingEncodingToInvalidValueShouldThrowException() + { + $this->helper->setEncoding('completely-invalid'); + $this->helper->getEscaper(); + } +} From d141f349c0087631b423b9b6088b94e91269df12 Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Thu, 5 Jul 2012 19:10:10 +0100 Subject: [PATCH 44/78] Added tests for CSS, JS and URL escape helpers - basic clones of original just to check workflow --- test/Helper/EscapeCssTest.php | 195 ++++++++++++++++++++++++++++++++++ test/Helper/EscapeJsTest.php | 195 ++++++++++++++++++++++++++++++++++ test/Helper/EscapeUrlTest.php | 195 ++++++++++++++++++++++++++++++++++ 3 files changed, 585 insertions(+) create mode 100644 test/Helper/EscapeCssTest.php create mode 100644 test/Helper/EscapeJsTest.php create mode 100644 test/Helper/EscapeUrlTest.php diff --git a/test/Helper/EscapeCssTest.php b/test/Helper/EscapeCssTest.php new file mode 100644 index 00000000..160519a9 --- /dev/null +++ b/test/Helper/EscapeCssTest.php @@ -0,0 +1,195 @@ +helper = new EscapeHelper; + } + + public function testUsesUtf8EncodingByDefault() + { + $this->assertEquals('UTF-8', $this->helper->getEncoding()); + } + + /** + * @expectedException \Zend\View\Exception\InvalidArgumentException + */ + public function testEncodingIsImmutable() + { + $this->helper->setEncoding('BIG5-HKSCS'); + $this->helper->getEscaper(); + $this->helper->setEncoding('UTF-8'); + } + + public function testGetEscaperCreatesDefaultInstanceWithCorrectEncoding() + { + $this->helper->setEncoding('BIG5-HKSCS'); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); + } + + public function testSettingEscaperObjectAlsoSetsEncoding() + { + $escaper = new \Zend\Escaper\Escaper('big5-hkscs'); + $this->helper->setEscaper($escaper); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); + } + + public function testEscapehtmlCalledOnEscaperObject() + { + $escaper = $this->getMock('\\Zend\\Escaper\\Escaper'); + $escaper->expects($this->any())->method('escapeCss'); + $this->helper->setEscaper($escaper); + $this->helper->__invoke('foo'); + } + + public function testAllowsRecursiveEscapingOfArrays() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $expected = array( + 'foo' => '\3C b\3E bar\3C \2F b\3E ', + 'baz' => array( + '\3C em\3E bat\3C \2F em\3E ', + 'second' => array( + '\3C i\3E third\3C \2F i\3E ', + ), + ), + ); + $test = $this->helper->__invoke($original, EscapeHelper::RECURSE_ARRAY); + $this->assertEquals($expected, $test); + } + + public function testWillCastObjectsToStringsBeforeEscaping() + { + $object = new TestAsset\Stringified; + $test = $this->helper->__invoke($object); + $this->assertEquals( + 'ZendTest\5C View\5C Helper\5C TestAsset\5C Stringified', + $test + ); + } + + public function testCanRecurseObjectImplementingToArray() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $object = new TestAsset\ToArray(); + $object->array = $original; + + $expected = array( + 'foo' => '\3C b\3E bar\3C \2F b\3E ', + 'baz' => array( + '\3C em\3E bat\3C \2F em\3E ', + 'second' => array( + '\3C i\3E third\3C \2F i\3E ', + ), + ), + ); + $test = $this->helper->__invoke($object, EscapeHelper::RECURSE_OBJECT); + $this->assertEquals($expected, $test); + } + + public function testCanRecurseObjectProperties() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $object = new stdClass(); + foreach ($original as $key => $value) { + $object->$key = $value; + } + + $expected = array( + 'foo' => '\3C b\3E bar\3C \2F b\3E ', + 'baz' => array( + '\3C em\3E bat\3C \2F em\3E ', + 'second' => array( + '\3C i\3E third\3C \2F i\3E ', + ), + ), + ); + $test = $this->helper->__invoke($object, EscapeHelper::RECURSE_OBJECT); + $this->assertEquals($expected, $test); + } + + /** + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException + * + * PHP 5.3 instates default encoding on empty string instead of the expected + * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts + * to guess the encoding or take it from php.ini default_charset when an empty + * string is set. Both are insecure behaviours. + */ + public function testSettingEncodingToEmptyStringShouldThrowException() + { + $this->helper->setEncoding(''); + $this->helper->getEscaper(); + } + + public function testSettingValidEncodingShouldNotThrowExceptions() + { + foreach ($this->supportedEncodings as $value) { + $helper = new EscapeHelper; + $helper->setEncoding($value); + $helper->getEscaper(); + } + } + + /** + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException + * + * All versions of PHP - when an invalid encoding is set on htmlspecialchars() + * a warning level error is issued and escaping continues with the default encoding + * for that PHP version. Preventing the continuation behaviour offsets display_errors + * off in production env. + */ + public function testSettingEncodingToInvalidValueShouldThrowException() + { + $this->helper->setEncoding('completely-invalid'); + $this->helper->getEscaper(); + } +} diff --git a/test/Helper/EscapeJsTest.php b/test/Helper/EscapeJsTest.php new file mode 100644 index 00000000..9bc9d933 --- /dev/null +++ b/test/Helper/EscapeJsTest.php @@ -0,0 +1,195 @@ +helper = new EscapeHelper; + } + + public function testUsesUtf8EncodingByDefault() + { + $this->assertEquals('UTF-8', $this->helper->getEncoding()); + } + + /** + * @expectedException \Zend\View\Exception\InvalidArgumentException + */ + public function testEncodingIsImmutable() + { + $this->helper->setEncoding('BIG5-HKSCS'); + $this->helper->getEscaper(); + $this->helper->setEncoding('UTF-8'); + } + + public function testGetEscaperCreatesDefaultInstanceWithCorrectEncoding() + { + $this->helper->setEncoding('BIG5-HKSCS'); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); + } + + public function testSettingEscaperObjectAlsoSetsEncoding() + { + $escaper = new \Zend\Escaper\Escaper('big5-hkscs'); + $this->helper->setEscaper($escaper); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); + } + + public function testEscapehtmlCalledOnEscaperObject() + { + $escaper = $this->getMock('\\Zend\\Escaper\\Escaper'); + $escaper->expects($this->any())->method('escapeJs'); + $this->helper->setEscaper($escaper); + $this->helper->__invoke('foo'); + } + + public function testAllowsRecursiveEscapingOfArrays() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $expected = array( + 'foo' => '\x3Cb\x3Ebar\x3C\x2Fb\x3E', + 'baz' => array( + '\x3Cem\x3Ebat\x3C\x2Fem\x3E', + 'second' => array( + '\x3Ci\x3Ethird\x3C\x2Fi\x3E', + ), + ), + ); + $test = $this->helper->__invoke($original, EscapeHelper::RECURSE_ARRAY); + $this->assertEquals($expected, $test); + } + + public function testWillCastObjectsToStringsBeforeEscaping() + { + $object = new TestAsset\Stringified; + $test = $this->helper->__invoke($object); + $this->assertEquals( + 'ZendTest\x5CView\x5CHelper\x5CTestAsset\x5CStringified', + $test + ); + } + + public function testCanRecurseObjectImplementingToArray() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $object = new TestAsset\ToArray(); + $object->array = $original; + + $expected = array( + 'foo' => '\x3Cb\x3Ebar\x3C\x2Fb\x3E', + 'baz' => array( + '\x3Cem\x3Ebat\x3C\x2Fem\x3E', + 'second' => array( + '\x3Ci\x3Ethird\x3C\x2Fi\x3E', + ), + ), + ); + $test = $this->helper->__invoke($object, EscapeHelper::RECURSE_OBJECT); + $this->assertEquals($expected, $test); + } + + public function testCanRecurseObjectProperties() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $object = new stdClass(); + foreach ($original as $key => $value) { + $object->$key = $value; + } + + $expected = array( + 'foo' => '\x3Cb\x3Ebar\x3C\x2Fb\x3E', + 'baz' => array( + '\x3Cem\x3Ebat\x3C\x2Fem\x3E', + 'second' => array( + '\x3Ci\x3Ethird\x3C\x2Fi\x3E', + ), + ), + ); + $test = $this->helper->__invoke($object, EscapeHelper::RECURSE_OBJECT); + $this->assertEquals($expected, $test); + } + + /** + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException + * + * PHP 5.3 instates default encoding on empty string instead of the expected + * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts + * to guess the encoding or take it from php.ini default_charset when an empty + * string is set. Both are insecure behaviours. + */ + public function testSettingEncodingToEmptyStringShouldThrowException() + { + $this->helper->setEncoding(''); + $this->helper->getEscaper(); + } + + public function testSettingValidEncodingShouldNotThrowExceptions() + { + foreach ($this->supportedEncodings as $value) { + $helper = new EscapeHelper; + $helper->setEncoding($value); + $helper->getEscaper(); + } + } + + /** + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException + * + * All versions of PHP - when an invalid encoding is set on htmlspecialchars() + * a warning level error is issued and escaping continues with the default encoding + * for that PHP version. Preventing the continuation behaviour offsets display_errors + * off in production env. + */ + public function testSettingEncodingToInvalidValueShouldThrowException() + { + $this->helper->setEncoding('completely-invalid'); + $this->helper->getEscaper(); + } +} diff --git a/test/Helper/EscapeUrlTest.php b/test/Helper/EscapeUrlTest.php new file mode 100644 index 00000000..00d7ac5a --- /dev/null +++ b/test/Helper/EscapeUrlTest.php @@ -0,0 +1,195 @@ +helper = new EscapeHelper; + } + + public function testUsesUtf8EncodingByDefault() + { + $this->assertEquals('UTF-8', $this->helper->getEncoding()); + } + + /** + * @expectedException \Zend\View\Exception\InvalidArgumentException + */ + public function testEncodingIsImmutable() + { + $this->helper->setEncoding('BIG5-HKSCS'); + $this->helper->getEscaper(); + $this->helper->setEncoding('UTF-8'); + } + + public function testGetEscaperCreatesDefaultInstanceWithCorrectEncoding() + { + $this->helper->setEncoding('BIG5-HKSCS'); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); + } + + public function testSettingEscaperObjectAlsoSetsEncoding() + { + $escaper = new \Zend\Escaper\Escaper('big5-hkscs'); + $this->helper->setEscaper($escaper); + $escaper = $this->helper->getEscaper(); + $this->assertTrue($escaper instanceof \Zend\Escaper\Escaper); + $this->assertEquals('big5-hkscs', $escaper->getEncoding()); + } + + public function testEscapehtmlCalledOnEscaperObject() + { + $escaper = $this->getMock('\\Zend\\Escaper\\Escaper'); + $escaper->expects($this->any())->method('escapeUrl'); + $this->helper->setEscaper($escaper); + $this->helper->__invoke('foo'); + } + + public function testAllowsRecursiveEscapingOfArrays() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $expected = array( + 'foo' => '%3Cb%3Ebar%3C%2Fb%3E', + 'baz' => array( + '%3Cem%3Ebat%3C%2Fem%3E', + 'second' => array( + '%3Ci%3Ethird%3C%2Fi%3E', + ), + ), + ); + $test = $this->helper->__invoke($original, EscapeHelper::RECURSE_ARRAY); + $this->assertEquals($expected, $test); + } + + public function testWillCastObjectsToStringsBeforeEscaping() + { + $object = new TestAsset\Stringified; + $test = $this->helper->__invoke($object); + $this->assertEquals( + 'ZendTest%5CView%5CHelper%5CTestAsset%5CStringified', + $test + ); + } + + public function testCanRecurseObjectImplementingToArray() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $object = new TestAsset\ToArray(); + $object->array = $original; + + $expected = array( + 'foo' => '%3Cb%3Ebar%3C%2Fb%3E', + 'baz' => array( + '%3Cem%3Ebat%3C%2Fem%3E', + 'second' => array( + '%3Ci%3Ethird%3C%2Fi%3E', + ), + ), + ); + $test = $this->helper->__invoke($object, EscapeHelper::RECURSE_OBJECT); + $this->assertEquals($expected, $test); + } + + public function testCanRecurseObjectProperties() + { + $original = array( + 'foo' => 'bar', + 'baz' => array( + 'bat', + 'second' => array( + 'third', + ), + ), + ); + $object = new stdClass(); + foreach ($original as $key => $value) { + $object->$key = $value; + } + + $expected = array( + 'foo' => '%3Cb%3Ebar%3C%2Fb%3E', + 'baz' => array( + '%3Cem%3Ebat%3C%2Fem%3E', + 'second' => array( + '%3Ci%3Ethird%3C%2Fi%3E', + ), + ), + ); + $test = $this->helper->__invoke($object, EscapeHelper::RECURSE_OBJECT); + $this->assertEquals($expected, $test); + } + + /** + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException + * + * PHP 5.3 instates default encoding on empty string instead of the expected + * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts + * to guess the encoding or take it from php.ini default_charset when an empty + * string is set. Both are insecure behaviours. + */ + public function testSettingEncodingToEmptyStringShouldThrowException() + { + $this->helper->setEncoding(''); + $this->helper->getEscaper(); + } + + public function testSettingValidEncodingShouldNotThrowExceptions() + { + foreach ($this->supportedEncodings as $value) { + $helper = new EscapeHelper; + $helper->setEncoding($value); + $helper->getEscaper(); + } + } + + /** + * @expectedException \Zend\Escaper\Exception\InvalidArgumentException + * + * All versions of PHP - when an invalid encoding is set on htmlspecialchars() + * a warning level error is issued and escaping continues with the default encoding + * for that PHP version. Preventing the continuation behaviour offsets display_errors + * off in production env. + */ + public function testSettingEncodingToInvalidValueShouldThrowException() + { + $this->helper->setEncoding('completely-invalid'); + $this->helper->getEscaper(); + } +} From a8c120a511a0b66e5a8d49e15a3ae900135fddb6 Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Thu, 5 Jul 2012 19:46:00 +0100 Subject: [PATCH 45/78] Updated Exception message for clarity --- src/Helper/Escaper/AbstractHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Helper/Escaper/AbstractHelper.php b/src/Helper/Escaper/AbstractHelper.php index 24050b05..5629da38 100644 --- a/src/Helper/Escaper/AbstractHelper.php +++ b/src/Helper/Escaper/AbstractHelper.php @@ -71,8 +71,8 @@ public function setEncoding($encoding) { if (!is_null($this->escaper)) { throw new Exception\InvalidArgumentException( - 'Encoding cannot be changed once a Zend\Escaper\Escaper object has been' - . ' instantiated by or injected into this Helper.' + '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.' ); } $this->encoding = $encoding; From d607c77f915d7763df297df0051e7cddf997c209 Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Thu, 5 Jul 2012 20:06:38 +0100 Subject: [PATCH 46/78] Minor refactor of Escape helper recursion into parent AbstractHelper --- src/Helper/EscapeCss.php | 54 ++++-------------------- src/Helper/EscapeHtml.php | 54 ++++-------------------- src/Helper/EscapeHtmlAttr.php | 54 ++++-------------------- src/Helper/EscapeJs.php | 54 ++++-------------------- src/Helper/EscapeUrl.php | 54 ++++-------------------- src/Helper/Escaper/AbstractHelper.php | 59 +++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 230 deletions(-) diff --git a/src/Helper/EscapeCss.php b/src/Helper/EscapeCss.php index d23f09e4..e2e11618 100644 --- a/src/Helper/EscapeCss.php +++ b/src/Helper/EscapeCss.php @@ -34,54 +34,16 @@ */ class EscapeCss extends Escaper\AbstractHelper { - /**@+ - * @const Recursion constants - */ - const RECURSE_NONE = 0x00; - const RECURSE_ARRAY = 0x01; - const RECURSE_OBJECT = 0x02; - /**@-*/ - + /** - * Invoke this helper: escape a value - * - * @param mixed $value - * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping - * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. - * @throws Exception\InvalidArgumentException + * Escape a value for current escaping strategy + * + * @param string $value + * @return string */ - public function __invoke($value, $recurse = self::RECURSE_NONE) + protected function escape($value) { - if (is_string($value)) { - return $this->getEscaper()->escapeCss($value); - } - if (is_array($value)) { - if (!(self::RECURSE_ARRAY & $recurse)) { - throw new Exception\InvalidArgumentException( - 'Array provided to Escape helper, but flags do not allow recursion' - ); - } - foreach ($value as $k => $v) { - $value[$k] = $this->__invoke($v, $recurse); - } - return $value; - } - if (is_object($value)) { - if (!(self::RECURSE_OBJECT & $recurse)) { - // Attempt to cast it to a string - if (method_exists($value, '__toString')) { - return $this->getEscaper()->escapeCss((string) $value); - } - throw new Exception\InvalidArgumentException( - 'Object provided to Escape helper, but flags do not allow recursion' - ); - } - if (method_exists($value, 'toArray')) { - return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); - } - return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); - } - // At this point, we have a scalar; simply return it - return $value; + return $this->getEscaper()->escapeCss($value); } + } diff --git a/src/Helper/EscapeHtml.php b/src/Helper/EscapeHtml.php index ad6c4c8f..bec5da1e 100644 --- a/src/Helper/EscapeHtml.php +++ b/src/Helper/EscapeHtml.php @@ -34,54 +34,16 @@ */ class EscapeHtml extends Escaper\AbstractHelper { - /**@+ - * @const Recursion constants - */ - const RECURSE_NONE = 0x00; - const RECURSE_ARRAY = 0x01; - const RECURSE_OBJECT = 0x02; - /**@-*/ - + /** - * Invoke this helper: escape a value - * - * @param mixed $value - * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping - * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. - * @throws Exception\InvalidArgumentException + * Escape a value for current escaping strategy + * + * @param string $value + * @return string */ - public function __invoke($value, $recurse = self::RECURSE_NONE) + protected function escape($value) { - if (is_string($value)) { - return $this->getEscaper()->escapeHtml($value); - } - if (is_array($value)) { - if (!(self::RECURSE_ARRAY & $recurse)) { - throw new Exception\InvalidArgumentException( - 'Array provided to Escape helper, but flags do not allow recursion' - ); - } - foreach ($value as $k => $v) { - $value[$k] = $this->__invoke($v, $recurse); - } - return $value; - } - if (is_object($value)) { - if (!(self::RECURSE_OBJECT & $recurse)) { - // Attempt to cast it to a string - if (method_exists($value, '__toString')) { - return $this->getEscaper()->escapeHtml((string) $value); - } - throw new Exception\InvalidArgumentException( - 'Object provided to Escape helper, but flags do not allow recursion' - ); - } - if (method_exists($value, 'toArray')) { - return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); - } - return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); - } - // At this point, we have a scalar; simply return it - return $value; + return $this->getEscaper()->escapeHtml($value); } + } diff --git a/src/Helper/EscapeHtmlAttr.php b/src/Helper/EscapeHtmlAttr.php index 993f9204..a1cc9121 100644 --- a/src/Helper/EscapeHtmlAttr.php +++ b/src/Helper/EscapeHtmlAttr.php @@ -34,54 +34,16 @@ */ class EscapeHtmlAttr extends Escaper\AbstractHelper { - /**@+ - * @const Recursion constants - */ - const RECURSE_NONE = 0x00; - const RECURSE_ARRAY = 0x01; - const RECURSE_OBJECT = 0x02; - /**@-*/ - + /** - * Invoke this helper: escape a value - * - * @param mixed $value - * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping - * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. - * @throws Exception\InvalidArgumentException + * Escape a value for current escaping strategy + * + * @param string $value + * @return string */ - public function __invoke($value, $recurse = self::RECURSE_NONE) + protected function escape($value) { - if (is_string($value)) { - return $this->getEscaper()->escapeHtmlAttr($value); - } - if (is_array($value)) { - if (!(self::RECURSE_ARRAY & $recurse)) { - throw new Exception\InvalidArgumentException( - 'Array provided to Escape helper, but flags do not allow recursion' - ); - } - foreach ($value as $k => $v) { - $value[$k] = $this->__invoke($v, $recurse); - } - return $value; - } - if (is_object($value)) { - if (!(self::RECURSE_OBJECT & $recurse)) { - // Attempt to cast it to a string - if (method_exists($value, '__toString')) { - return $this->getEscaper()->escapeHtmlAttr((string) $value); - } - throw new Exception\InvalidArgumentException( - 'Object provided to Escape helper, but flags do not allow recursion' - ); - } - if (method_exists($value, 'toArray')) { - return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); - } - return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); - } - // At this point, we have a scalar; simply return it - return $value; + return $this->getEscaper()->escapeHtmlAttr($value); } + } diff --git a/src/Helper/EscapeJs.php b/src/Helper/EscapeJs.php index 71819acc..9fe52ba0 100644 --- a/src/Helper/EscapeJs.php +++ b/src/Helper/EscapeJs.php @@ -34,54 +34,16 @@ */ class EscapeJs extends Escaper\AbstractHelper { - /**@+ - * @const Recursion constants - */ - const RECURSE_NONE = 0x00; - const RECURSE_ARRAY = 0x01; - const RECURSE_OBJECT = 0x02; - /**@-*/ - + /** - * Invoke this helper: escape a value - * - * @param mixed $value - * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping - * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. - * @throws Exception\InvalidArgumentException + * Escape a value for current escaping strategy + * + * @param string $value + * @return string */ - public function __invoke($value, $recurse = self::RECURSE_NONE) + protected function escape($value) { - if (is_string($value)) { - return $this->getEscaper()->escapeJs($value); - } - if (is_array($value)) { - if (!(self::RECURSE_ARRAY & $recurse)) { - throw new Exception\InvalidArgumentException( - 'Array provided to Escape helper, but flags do not allow recursion' - ); - } - foreach ($value as $k => $v) { - $value[$k] = $this->__invoke($v, $recurse); - } - return $value; - } - if (is_object($value)) { - if (!(self::RECURSE_OBJECT & $recurse)) { - // Attempt to cast it to a string - if (method_exists($value, '__toString')) { - return $this->getEscaper()->escapeJs((string) $value); - } - throw new Exception\InvalidArgumentException( - 'Object provided to Escape helper, but flags do not allow recursion' - ); - } - if (method_exists($value, 'toArray')) { - return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); - } - return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); - } - // At this point, we have a scalar; simply return it - return $value; + return $this->getEscaper()->escapeJs($value); } + } diff --git a/src/Helper/EscapeUrl.php b/src/Helper/EscapeUrl.php index b77c6f42..ca787102 100644 --- a/src/Helper/EscapeUrl.php +++ b/src/Helper/EscapeUrl.php @@ -34,54 +34,16 @@ */ class EscapeUrl extends Escaper\AbstractHelper { - /**@+ - * @const Recursion constants - */ - const RECURSE_NONE = 0x00; - const RECURSE_ARRAY = 0x01; - const RECURSE_OBJECT = 0x02; - /**@-*/ - + /** - * Invoke this helper: escape a value - * - * @param mixed $value - * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping - * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. - * @throws Exception\InvalidArgumentException + * Escape a value for current escaping strategy + * + * @param string $value + * @return string */ - public function __invoke($value, $recurse = self::RECURSE_NONE) + protected function escape($value) { - if (is_string($value)) { - return $this->getEscaper()->escapeUrl($value); - } - if (is_array($value)) { - if (!(self::RECURSE_ARRAY & $recurse)) { - throw new Exception\InvalidArgumentException( - 'Array provided to Escape helper, but flags do not allow recursion' - ); - } - foreach ($value as $k => $v) { - $value[$k] = $this->__invoke($v, $recurse); - } - return $value; - } - if (is_object($value)) { - if (!(self::RECURSE_OBJECT & $recurse)) { - // Attempt to cast it to a string - if (method_exists($value, '__toString')) { - return $this->getEscaper()->escapeUrl((string) $value); - } - throw new Exception\InvalidArgumentException( - 'Object provided to Escape helper, but flags do not allow recursion' - ); - } - if (method_exists($value, 'toArray')) { - return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); - } - return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); - } - // At this point, we have a scalar; simply return it - return $value; + return $this->getEscaper()->escapeUrl($value); } + } diff --git a/src/Helper/Escaper/AbstractHelper.php b/src/Helper/Escaper/AbstractHelper.php index 5629da38..c01e0f37 100644 --- a/src/Helper/Escaper/AbstractHelper.php +++ b/src/Helper/Escaper/AbstractHelper.php @@ -36,6 +36,14 @@ abstract class AbstractHelper extends Helper\AbstractHelper { + /**@+ + * @const Recursion constants + */ + const RECURSE_NONE = 0x00; + const RECURSE_ARRAY = 0x01; + const RECURSE_OBJECT = 0x02; + /**@-*/ + /** * @var Escaper\Escaper */ @@ -89,4 +97,55 @@ public function getEncoding() return $this->encoding; } + /** + * Invoke this helper: escape a value + * + * @param mixed $value + * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping + * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. + * @throws Exception\InvalidArgumentException + */ + public function __invoke($value, $recurse = self::RECURSE_NONE) + { + if (is_string($value)) { + return $this->escape($value); + } + if (is_array($value)) { + if (!(self::RECURSE_ARRAY & $recurse)) { + throw new Exception\InvalidArgumentException( + 'Array provided to Escape helper, but flags do not allow recursion' + ); + } + foreach ($value as $k => $v) { + $value[$k] = $this->__invoke($v, $recurse); + } + return $value; + } + if (is_object($value)) { + if (!(self::RECURSE_OBJECT & $recurse)) { + // Attempt to cast it to a string + if (method_exists($value, '__toString')) { + return $this->escape((string) $value); + } + throw new Exception\InvalidArgumentException( + 'Object provided to Escape helper, but flags do not allow recursion' + ); + } + if (method_exists($value, 'toArray')) { + return $this->__invoke($value->toArray(), $recurse | self::RECURSE_ARRAY); + } + return $this->__invoke((array) $value, $recurse | self::RECURSE_ARRAY); + } + // At this point, we have a scalar; simply return it + return $value; + } + + /** + * Escape a value for current escaping strategy + * + * @param string $value + * @return string + */ + protected abstract function escape($value); + } \ No newline at end of file From b4e57dc14d775d81fca6c2b27bdc80585a3a2318 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Mon, 9 Jul 2012 16:19:42 +0200 Subject: [PATCH 47/78] [CS][Library] Set File Header http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards#CodingStandards-Files The following script replaces the content between PHP open tag and namespace declaration. for COMPONENT in $(ls -d *) do for FILE in $(find $COMPONENT -name "*.php") do BLOCK="\/\*\*\n \* Zend Framework \(http:\/\/framework\.zend\.com\/\)\n \*\n \* \@link http:\/\/github\.com\/zendframework\/zf2 for the canonical source repository\n \* \@copyright Copyright \(c\) 2005-2012 Zend Technologies USA Inc\. \(http:\/\/www\.zend\.com\)\n \* \@license http:\/\/framework\.zend\.com\/license\/new-bsd New BSD License\n \* \@package Zend_$COMPONENT\n \*\/" perl -0777 -i -pe "s/(<\?php(\s*.*)*\nn)/ Date: Mon, 9 Jul 2012 16:34:21 +0200 Subject: [PATCH 48/78] [CS][test] Remove @copyright & @license for fl in $(find . -name "*.php"); do mv $fl $fl.old; sed '/@copyright/d' $fl.old > $fl; rm -f $fl.old; done; for fl in $(find . -name "*.php"); do mv $fl $fl.old; sed '/@license/d' $fl.old > $fl; rm -f $fl.old; done; --- test/Helper/BasePathTest.php | 4 ---- test/Helper/CycleTest.php | 4 ---- test/Helper/DeclareVarsTest.php | 4 ---- test/Helper/DoctypeTest.php | 4 ---- test/Helper/GravatarTest.php | 4 ---- test/Helper/HeadLinkTest.php | 4 ---- test/Helper/HeadMetaTest.php | 4 ---- test/Helper/HeadScriptTest.php | 4 ---- test/Helper/HeadStyleTest.php | 4 ---- test/Helper/HeadTitleTest.php | 4 ---- test/Helper/HtmlFlashTest.php | 4 ---- test/Helper/HtmlListTest.php | 4 ---- test/Helper/HtmlObjectTest.php | 4 ---- test/Helper/HtmlPageTest.php | 4 ---- test/Helper/HtmlQuicktimeTest.php | 4 ---- test/Helper/InlineScriptTest.php | 4 ---- test/Helper/JsonTest.php | 4 ---- test/Helper/LayoutTest.php | 4 ---- test/Helper/Navigation/AbstractTest.php | 4 ---- test/Helper/Navigation/BreadcrumbsTest.php | 4 ---- test/Helper/Navigation/LinksTest.php | 4 ---- test/Helper/Navigation/MenuTest.php | 4 ---- test/Helper/Navigation/NavigationTest.php | 4 ---- test/Helper/Navigation/SitemapTest.php | 4 ---- test/Helper/PaginationControlTest.php | 4 ---- test/Helper/PartialLoopTest.php | 4 ---- test/Helper/PartialTest.php | 4 ---- test/Helper/Placeholder/ContainerTest.php | 4 ---- test/Helper/Placeholder/RegistryTest.php | 4 ---- test/Helper/Placeholder/StandaloneContainerTest.php | 4 ---- test/Helper/PlaceholderTest.php | 4 ---- test/Helper/RenderChildModelTest.php | 4 ---- test/Helper/RenderToPlaceholderTest.php | 4 ---- test/Helper/ServerUrlTest.php | 4 ---- test/Helper/UrlTest.php | 4 ---- test/HelperPluginManagerTest.php | 4 ---- test/Model/JsonModelTest.php | 4 ---- test/Model/ViewModelTest.php | 4 ---- test/PhpRendererTest.php | 4 ---- test/Renderer/FeedRendererTest.php | 4 ---- test/Renderer/JsonRendererTest.php | 4 ---- test/Renderer/TestAsset/JsonModel.php | 4 ---- test/Resolver/AggregateResolverTest.php | 4 ---- test/Resolver/TemplateMapResolverTest.php | 4 ---- test/Strategy/FeedStrategyTest.php | 4 ---- test/Strategy/JsonStrategyTest.php | 4 ---- test/Strategy/PhpRendererStrategyTest.php | 4 ---- test/TemplatePathStackTest.php | 4 ---- test/TestAsset/Renderer/VarExportRenderer.php | 4 ---- test/TestAsset/VariableFunctor.php | 4 ---- test/VariablesTest.php | 4 ---- test/ViewTest.php | 2 -- test/_stubs/FilterDir1/Foo.php | 4 ---- test/_stubs/HelperDir1/Stub1.php | 4 ---- test/_stubs/HelperDir1/StubEmpty.php | 2 -- test/_stubs/HelperDir2/Datetime.php | 4 ---- test/_stubs/HelperDir2/Stub1.php | 4 ---- test/_stubs/HelperDir2/Stub2.php | 4 ---- 58 files changed, 228 deletions(-) diff --git a/test/Helper/BasePathTest.php b/test/Helper/BasePathTest.php index bf92a6bc..4bfae932 100644 --- a/test/Helper/BasePathTest.php +++ b/test/Helper/BasePathTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/CycleTest.php b/test/Helper/CycleTest.php index 96215f02..ebd3b732 100644 --- a/test/Helper/CycleTest.php +++ b/test/Helper/CycleTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/DeclareVarsTest.php b/test/Helper/DeclareVarsTest.php index 6a2d7ad4..932acf20 100644 --- a/test/Helper/DeclareVarsTest.php +++ b/test/Helper/DeclareVarsTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/DoctypeTest.php b/test/Helper/DoctypeTest.php index b5baaeb9..3a14d53d 100644 --- a/test/Helper/DoctypeTest.php +++ b/test/Helper/DoctypeTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/GravatarTest.php b/test/Helper/GravatarTest.php index 2c3161b3..0afbd428 100644 --- a/test/Helper/GravatarTest.php +++ b/test/Helper/GravatarTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zendview * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -29,8 +27,6 @@ * @category Zend * @package Zendview * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zendview * @group Zendview_Helper */ diff --git a/test/Helper/HeadLinkTest.php b/test/Helper/HeadLinkTest.php index 938e1608..46ebb24b 100644 --- a/test/Helper/HeadLinkTest.php +++ b/test/Helper/HeadLinkTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HeadMetaTest.php b/test/Helper/HeadMetaTest.php index d3c87953..b4dabae3 100644 --- a/test/Helper/HeadMetaTest.php +++ b/test/Helper/HeadMetaTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HeadScriptTest.php b/test/Helper/HeadScriptTest.php index 66c93f12..49b7a68a 100644 --- a/test/Helper/HeadScriptTest.php +++ b/test/Helper/HeadScriptTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -30,8 +28,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HeadStyleTest.php b/test/Helper/HeadStyleTest.php index 6b3d8d5d..3e26c40a 100644 --- a/test/Helper/HeadStyleTest.php +++ b/test/Helper/HeadStyleTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -30,8 +28,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HeadTitleTest.php b/test/Helper/HeadTitleTest.php index 7dfce4c2..1a59aa03 100644 --- a/test/Helper/HeadTitleTest.php +++ b/test/Helper/HeadTitleTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -31,8 +29,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HtmlFlashTest.php b/test/Helper/HtmlFlashTest.php index a730ee8f..37c2d81d 100644 --- a/test/Helper/HtmlFlashTest.php +++ b/test/Helper/HtmlFlashTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HtmlListTest.php b/test/Helper/HtmlListTest.php index cf69b3e1..08744253 100644 --- a/test/Helper/HtmlListTest.php +++ b/test/Helper/HtmlListTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HtmlObjectTest.php b/test/Helper/HtmlObjectTest.php index 65212047..0d26eaa9 100644 --- a/test/Helper/HtmlObjectTest.php +++ b/test/Helper/HtmlObjectTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -29,8 +27,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HtmlPageTest.php b/test/Helper/HtmlPageTest.php index a0681d44..703404b9 100644 --- a/test/Helper/HtmlPageTest.php +++ b/test/Helper/HtmlPageTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/HtmlQuicktimeTest.php b/test/Helper/HtmlQuicktimeTest.php index 4c427a7f..4bea0c53 100644 --- a/test/Helper/HtmlQuicktimeTest.php +++ b/test/Helper/HtmlQuicktimeTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/InlineScriptTest.php b/test/Helper/InlineScriptTest.php index def220e3..badfd99f 100644 --- a/test/Helper/InlineScriptTest.php +++ b/test/Helper/InlineScriptTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -30,8 +28,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/JsonTest.php b/test/Helper/JsonTest.php index de471f00..405ce005 100644 --- a/test/Helper/JsonTest.php +++ b/test/Helper/JsonTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/LayoutTest.php b/test/Helper/LayoutTest.php index 625aa68c..571349f2 100644 --- a/test/Helper/LayoutTest.php +++ b/test/Helper/LayoutTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -31,8 +29,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Navigation/AbstractTest.php b/test/Helper/Navigation/AbstractTest.php index 304819cd..213e67a7 100644 --- a/test/Helper/Navigation/AbstractTest.php +++ b/test/Helper/Navigation/AbstractTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Navigation; @@ -39,8 +37,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Navigation/BreadcrumbsTest.php b/test/Helper/Navigation/BreadcrumbsTest.php index 25f3e512..3b3d7594 100644 --- a/test/Helper/Navigation/BreadcrumbsTest.php +++ b/test/Helper/Navigation/BreadcrumbsTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Navigation; @@ -30,8 +28,6 @@ * @category Zend_Tests * @package Zend_View * @subpackage Helper - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Navigation/LinksTest.php b/test/Helper/Navigation/LinksTest.php index bcdcc69d..5c5b5edb 100644 --- a/test/Helper/Navigation/LinksTest.php +++ b/test/Helper/Navigation/LinksTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Navigation; @@ -36,8 +34,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php index 40a621de..c1870e51 100644 --- a/test/Helper/Navigation/MenuTest.php +++ b/test/Helper/Navigation/MenuTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Navigation; @@ -27,8 +25,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Navigation/NavigationTest.php b/test/Helper/Navigation/NavigationTest.php index ad95e395..9549f253 100644 --- a/test/Helper/Navigation/NavigationTest.php +++ b/test/Helper/Navigation/NavigationTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Navigation; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php index 613d32e7..0c26a952 100644 --- a/test/Helper/Navigation/SitemapTest.php +++ b/test/Helper/Navigation/SitemapTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Navigation; @@ -29,8 +27,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/PaginationControlTest.php b/test/Helper/PaginationControlTest.php index ab5c8700..ca49920e 100644 --- a/test/Helper/PaginationControlTest.php +++ b/test/Helper/PaginationControlTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -30,8 +28,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/PartialLoopTest.php b/test/Helper/PartialLoopTest.php index 60839e47..8a99bf7d 100644 --- a/test/Helper/PartialLoopTest.php +++ b/test/Helper/PartialLoopTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -33,8 +31,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/PartialTest.php b/test/Helper/PartialTest.php index 363f3683..fbbb630a 100644 --- a/test/Helper/PartialTest.php +++ b/test/Helper/PartialTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -31,8 +29,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Placeholder/ContainerTest.php b/test/Helper/Placeholder/ContainerTest.php index 1ef41225..c86085b7 100644 --- a/test/Helper/Placeholder/ContainerTest.php +++ b/test/Helper/Placeholder/ContainerTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Placeholder; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Placeholder/RegistryTest.php b/test/Helper/Placeholder/RegistryTest.php index ae53096c..c5c03196 100644 --- a/test/Helper/Placeholder/RegistryTest.php +++ b/test/Helper/Placeholder/RegistryTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Placeholder; @@ -30,8 +28,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/Placeholder/StandaloneContainerTest.php b/test/Helper/Placeholder/StandaloneContainerTest.php index 657b1cc0..e7611e3d 100644 --- a/test/Helper/Placeholder/StandaloneContainerTest.php +++ b/test/Helper/Placeholder/StandaloneContainerTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper\Placeholder; @@ -29,8 +27,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/PlaceholderTest.php b/test/Helper/PlaceholderTest.php index c470f219..6eaa44eb 100644 --- a/test/Helper/PlaceholderTest.php +++ b/test/Helper/PlaceholderTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -31,8 +29,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/RenderChildModelTest.php b/test/Helper/RenderChildModelTest.php index e7dd6a1d..4d68868f 100644 --- a/test/Helper/RenderChildModelTest.php +++ b/test/Helper/RenderChildModelTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -31,8 +29,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/RenderToPlaceholderTest.php b/test/Helper/RenderToPlaceholderTest.php index edc67e3f..73ca71cc 100644 --- a/test/Helper/RenderToPlaceholderTest.php +++ b/test/Helper/RenderToPlaceholderTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/ServerUrlTest.php b/test/Helper/ServerUrlTest.php index 9783ad7f..73877575 100644 --- a/test/Helper/ServerUrlTest.php +++ b/test/Helper/ServerUrlTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/Helper/UrlTest.php b/test/Helper/UrlTest.php index c6d0b1fe..1abad584 100644 --- a/test/Helper/UrlTest.php +++ b/test/Helper/UrlTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Helper; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View * @group Zend_View_Helper */ diff --git a/test/HelperPluginManagerTest.php b/test/HelperPluginManagerTest.php index 1a37b94d..dc4aec8a 100644 --- a/test/HelperPluginManagerTest.php +++ b/test/HelperPluginManagerTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View */ class HelperPluginManagerTest extends \PHPUnit_Framework_TestCase diff --git a/test/Model/JsonModelTest.php b/test/Model/JsonModelTest.php index 5d8d147d..c4063477 100644 --- a/test/Model/JsonModelTest.php +++ b/test/Model/JsonModelTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Model; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class JsonModelTest extends TestCase { diff --git a/test/Model/ViewModelTest.php b/test/Model/ViewModelTest.php index f01111c2..fa46f978 100644 --- a/test/Model/ViewModelTest.php +++ b/test/Model/ViewModelTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Model; @@ -31,8 +29,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class ViewModelTest extends TestCase { diff --git a/test/PhpRendererTest.php b/test/PhpRendererTest.php index b5567cc8..b132771b 100644 --- a/test/PhpRendererTest.php +++ b/test/PhpRendererTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View */ class PhpRendererTest extends \PHPUnit_Framework_TestCase diff --git a/test/Renderer/FeedRendererTest.php b/test/Renderer/FeedRendererTest.php index e1525c1a..f6494c43 100644 --- a/test/Renderer/FeedRendererTest.php +++ b/test/Renderer/FeedRendererTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Renderer; @@ -32,8 +30,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class FeedRendererTest extends TestCase { diff --git a/test/Renderer/JsonRendererTest.php b/test/Renderer/JsonRendererTest.php index 10edc021..78b1c932 100644 --- a/test/Renderer/JsonRendererTest.php +++ b/test/Renderer/JsonRendererTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Renderer; @@ -31,8 +29,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View */ class JsonRendererTest extends TestCase diff --git a/test/Renderer/TestAsset/JsonModel.php b/test/Renderer/TestAsset/JsonModel.php index 89883276..84b912a2 100644 --- a/test/Renderer/TestAsset/JsonModel.php +++ b/test/Renderer/TestAsset/JsonModel.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Renderer\TestAsset; @@ -27,8 +25,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class JsonModel implements JsonSerializable { diff --git a/test/Resolver/AggregateResolverTest.php b/test/Resolver/AggregateResolverTest.php index 4f3d661a..f49192dd 100644 --- a/test/Resolver/AggregateResolverTest.php +++ b/test/Resolver/AggregateResolverTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Resolver; @@ -29,8 +27,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class AggregateResolverTest extends TestCase { diff --git a/test/Resolver/TemplateMapResolverTest.php b/test/Resolver/TemplateMapResolverTest.php index 02dc9c97..363e32f5 100644 --- a/test/Resolver/TemplateMapResolverTest.php +++ b/test/Resolver/TemplateMapResolverTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Resolver; @@ -29,8 +27,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class TemplateMapResolverTest extends TestCase { diff --git a/test/Strategy/FeedStrategyTest.php b/test/Strategy/FeedStrategyTest.php index ec1f5004..b8582fab 100644 --- a/test/Strategy/FeedStrategyTest.php +++ b/test/Strategy/FeedStrategyTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Strategy; @@ -37,8 +35,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class FeedStrategyTest extends TestCase { diff --git a/test/Strategy/JsonStrategyTest.php b/test/Strategy/JsonStrategyTest.php index d3dd24c3..ff9afe7e 100644 --- a/test/Strategy/JsonStrategyTest.php +++ b/test/Strategy/JsonStrategyTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Strategy; @@ -37,8 +35,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class JsonStrategyTest extends TestCase { diff --git a/test/Strategy/PhpRendererStrategyTest.php b/test/Strategy/PhpRendererStrategyTest.php index 49b948e0..0e6b8a00 100644 --- a/test/Strategy/PhpRendererStrategyTest.php +++ b/test/Strategy/PhpRendererStrategyTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Strategy; @@ -35,8 +33,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class PhpRendererStrategyTest extends TestCase { diff --git a/test/TemplatePathStackTest.php b/test/TemplatePathStackTest.php index 737802e6..c6241ba3 100644 --- a/test/TemplatePathStackTest.php +++ b/test/TemplatePathStackTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View; @@ -27,8 +25,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View */ class TemplatePathStackTest extends \PHPUnit_Framework_TestCase diff --git a/test/TestAsset/Renderer/VarExportRenderer.php b/test/TestAsset/Renderer/VarExportRenderer.php index b426a931..c864e949 100644 --- a/test/TestAsset/Renderer/VarExportRenderer.php +++ b/test/TestAsset/Renderer/VarExportRenderer.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\TestAsset\Renderer; @@ -29,8 +27,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class VarExportRenderer implements Renderer { diff --git a/test/TestAsset/VariableFunctor.php b/test/TestAsset/VariableFunctor.php index c4b72ee8..f8818e1a 100644 --- a/test/TestAsset/VariableFunctor.php +++ b/test/TestAsset/VariableFunctor.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\TestAsset; @@ -25,8 +23,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class VariableFunctor { diff --git a/test/VariablesTest.php b/test/VariablesTest.php index 7a199455..80b36aba 100644 --- a/test/VariablesTest.php +++ b/test/VariablesTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View; @@ -28,8 +26,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_View */ class VariablesTest extends \PHPUnit_Framework_TestCase diff --git a/test/ViewTest.php b/test/ViewTest.php index c60ef392..a9a4565d 100644 --- a/test/ViewTest.php +++ b/test/ViewTest.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTest - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View; diff --git a/test/_stubs/FilterDir1/Foo.php b/test/_stubs/FilterDir1/Foo.php index 338be41f..52ff5e04 100644 --- a/test/_stubs/FilterDir1/Foo.php +++ b/test/_stubs/FilterDir1/Foo.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\Filter; @@ -25,8 +23,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Foo { diff --git a/test/_stubs/HelperDir1/Stub1.php b/test/_stubs/HelperDir1/Stub1.php index 800dc5a5..5cfcf8cd 100644 --- a/test/_stubs/HelperDir1/Stub1.php +++ b/test/_stubs/HelperDir1/Stub1.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Foo\View\Helper; @@ -25,8 +23,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Stub1 { diff --git a/test/_stubs/HelperDir1/StubEmpty.php b/test/_stubs/HelperDir1/StubEmpty.php index 44d151bb..2e48b95a 100644 --- a/test/_stubs/HelperDir1/StubEmpty.php +++ b/test/_stubs/HelperDir1/StubEmpty.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\_stubs\HelperDir1; diff --git a/test/_stubs/HelperDir2/Datetime.php b/test/_stubs/HelperDir2/Datetime.php index f8c5f3ff..97805522 100644 --- a/test/_stubs/HelperDir2/Datetime.php +++ b/test/_stubs/HelperDir2/Datetime.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\_stubs\HelperDir2; @@ -25,8 +23,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Datetime { diff --git a/test/_stubs/HelperDir2/Stub1.php b/test/_stubs/HelperDir2/Stub1.php index e182fdf6..336f13df 100644 --- a/test/_stubs/HelperDir2/Stub1.php +++ b/test/_stubs/HelperDir2/Stub1.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace ZendTest\View\_stubs\HelperDir2; @@ -25,8 +23,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Stub1 { diff --git a/test/_stubs/HelperDir2/Stub2.php b/test/_stubs/HelperDir2/Stub2.php index 62247a16..00514e51 100644 --- a/test/_stubs/HelperDir2/Stub2.php +++ b/test/_stubs/HelperDir2/Stub2.php @@ -15,8 +15,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\View\Helper; @@ -25,8 +23,6 @@ * @category Zend * @package Zend_View * @subpackage UnitTests - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License */ class Stub2 { From 7716dad37be13f965efc1a34ab09499e07c3d3b9 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Mon, 9 Jul 2012 16:41:27 +0200 Subject: [PATCH 49/78] [CS][Tests] Set File Header http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards#CodingStandards-Files The following script replaces the content between PHP open tag and namespace declaration. for COMPONENT in $(ls -d *) do for FILE in $(find $COMPONENT -name "*.php") do BLOCK="\/\*\*\n \* Zend Framework \(http:\/\/framework\.zend\.com\/\)\n \*\n \* \@link http:\/\/github\.com\/zendframework\/zf2 for the canonical source repository\n \* \@copyright Copyright \(c\) 2005-2012 Zend Technologies USA Inc\. \(http:\/\/www\.zend\.com\)\n \* \@license http:\/\/framework\.zend\.com\/license\/new-bsd New BSD License\n \* \@package Zend_$COMPONENT\n \*\/" perl -0777 -i -pe "s/(<\?php(\s*.*)*\nn)/ Date: Mon, 9 Jul 2012 16:46:59 -0500 Subject: [PATCH 50/78] [zen-49] Correct import statements across framework - Ran a script that would create multiple import statements out of multi-line import statements, and which would sort all import statements in alphabetic order. Script is at https://gist.github.com/3079222 and was run by dropping into the library/Zend folder and typing (in zsh) "for file in **/*.php;do php /path/to/replace-uses.php $file; done" --- src/Helper/Doctype.php | 2 +- src/Helper/EscapeCss.php | 2 +- src/Helper/EscapeHtml.php | 2 +- src/Helper/EscapeHtmlAttr.php | 2 +- src/Helper/EscapeJs.php | 2 +- src/Helper/EscapeUrl.php | 2 +- src/Helper/Escaper/AbstractHelper.php | 4 ++-- src/Helper/Navigation.php | 2 +- src/Helper/Navigation/AbstractHelper.php | 2 +- src/Helper/Navigation/Links.php | 4 ++-- src/Helper/Navigation/Sitemap.php | 2 +- src/Helper/Placeholder/Container/AbstractStandalone.php | 2 +- src/Helper/Url.php | 2 +- src/Renderer/FeedRenderer.php | 4 ++-- src/Renderer/JsonRenderer.php | 2 +- src/Renderer/PhpRenderer.php | 2 +- src/Renderer/RendererInterface.php | 2 +- src/View.php | 4 ++-- 18 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Helper/Doctype.php b/src/Helper/Doctype.php index edec6f56..22b1c632 100644 --- a/src/Helper/Doctype.php +++ b/src/Helper/Doctype.php @@ -10,8 +10,8 @@ namespace Zend\View\Helper; -use Zend\View\Exception; use ArrayObject; +use Zend\View\Exception; /** * Helper for setting and retrieving the doctype diff --git a/src/Helper/EscapeCss.php b/src/Helper/EscapeCss.php index 0d83cc3f..4143ad23 100644 --- a/src/Helper/EscapeCss.php +++ b/src/Helper/EscapeCss.php @@ -10,8 +10,8 @@ namespace Zend\View\Helper; -use Zend\View\Helper\Escaper; use Zend\View\Exception; +use Zend\View\Helper\Escaper; /** * Helper for escaping values diff --git a/src/Helper/EscapeHtml.php b/src/Helper/EscapeHtml.php index 005d2b30..43bb4286 100644 --- a/src/Helper/EscapeHtml.php +++ b/src/Helper/EscapeHtml.php @@ -10,8 +10,8 @@ namespace Zend\View\Helper; -use Zend\View\Helper\Escaper; use Zend\View\Exception; +use Zend\View\Helper\Escaper; /** * Helper for escaping values diff --git a/src/Helper/EscapeHtmlAttr.php b/src/Helper/EscapeHtmlAttr.php index 8b4f6cce..606a0344 100644 --- a/src/Helper/EscapeHtmlAttr.php +++ b/src/Helper/EscapeHtmlAttr.php @@ -10,8 +10,8 @@ namespace Zend\View\Helper; -use Zend\View\Helper\Escaper; use Zend\View\Exception; +use Zend\View\Helper\Escaper; /** * Helper for escaping values diff --git a/src/Helper/EscapeJs.php b/src/Helper/EscapeJs.php index cc4e2bd3..e5ac73f2 100644 --- a/src/Helper/EscapeJs.php +++ b/src/Helper/EscapeJs.php @@ -10,8 +10,8 @@ namespace Zend\View\Helper; -use Zend\View\Helper\Escaper; use Zend\View\Exception; +use Zend\View\Helper\Escaper; /** * Helper for escaping values diff --git a/src/Helper/EscapeUrl.php b/src/Helper/EscapeUrl.php index 137b3219..bef570f8 100644 --- a/src/Helper/EscapeUrl.php +++ b/src/Helper/EscapeUrl.php @@ -10,8 +10,8 @@ namespace Zend\View\Helper; -use Zend\View\Helper\Escaper; use Zend\View\Exception; +use Zend\View\Helper\Escaper; /** * Helper for escaping values diff --git a/src/Helper/Escaper/AbstractHelper.php b/src/Helper/Escaper/AbstractHelper.php index 7b8ee3a0..dc391af2 100644 --- a/src/Helper/Escaper/AbstractHelper.php +++ b/src/Helper/Escaper/AbstractHelper.php @@ -10,9 +10,9 @@ namespace Zend\View\Helper\Escaper; -use Zend\View\Helper; -use Zend\View\Exception; use Zend\Escaper; +use Zend\View\Exception; +use Zend\View\Helper; /** * Helper for escaping values diff --git a/src/Helper/Navigation.php b/src/Helper/Navigation.php index 3cbd0ad7..8e92d477 100644 --- a/src/Helper/Navigation.php +++ b/src/Helper/Navigation.php @@ -12,9 +12,9 @@ use Zend\Navigation\AbstractContainer; use Zend\ServiceManager\ServiceLocatorAwareInterface; +use Zend\View\Exception; use Zend\View\Helper\Navigation\AbstractHelper as AbstractNavigationHelper; use Zend\View\Helper\Navigation\HelperInterface as NavigationHelper; -use Zend\View\Exception; /** * Proxy helper for retrieving navigational helpers and forwarding calls diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 318736da..251eb6c2 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -12,11 +12,11 @@ use RecursiveIteratorIterator; use Zend\Acl; +use Zend\I18n\Translator\Translator; use Zend\Navigation; use Zend\Navigation\Page\AbstractPage; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorInterface; -use Zend\I18n\Translator\Translator; use Zend\View; use Zend\View\Exception; diff --git a/src/Helper/Navigation/Links.php b/src/Helper/Navigation/Links.php index ae72440c..6c494460 100644 --- a/src/Helper/Navigation/Links.php +++ b/src/Helper/Navigation/Links.php @@ -10,11 +10,11 @@ namespace Zend\View\Helper\Navigation; -use Traversable; -use Zend\Stdlib\ArrayUtils; use RecursiveIteratorIterator; +use Traversable; use Zend\Navigation\AbstractContainer; use Zend\Navigation\Page\AbstractPage; +use Zend\Stdlib\ArrayUtils; use Zend\View; use Zend\View\Exception; diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php index 3e7edd00..62d17bfe 100644 --- a/src/Helper/Navigation/Sitemap.php +++ b/src/Helper/Navigation/Sitemap.php @@ -12,8 +12,8 @@ use DOMDocument; use RecursiveIteratorIterator; -use Zend\Navigation\Page\AbstractPage; use Zend\Navigation\AbstractContainer; +use Zend\Navigation\Page\AbstractPage; use Zend\Uri; use Zend\View; use Zend\View\Exception; diff --git a/src/Helper/Placeholder/Container/AbstractStandalone.php b/src/Helper/Placeholder/Container/AbstractStandalone.php index 1791f342..306f94d9 100644 --- a/src/Helper/Placeholder/Container/AbstractStandalone.php +++ b/src/Helper/Placeholder/Container/AbstractStandalone.php @@ -10,8 +10,8 @@ namespace Zend\View\Helper\Placeholder\Container; -use Zend\View\Helper\Placeholder\Registry; use Zend\View\Exception; +use Zend\View\Helper\Placeholder\Registry; /** * Base class for targetted placeholder helpers diff --git a/src/Helper/Url.php b/src/Helper/Url.php index e47d9657..76cb3301 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -10,8 +10,8 @@ namespace Zend\View\Helper; -use Zend\Mvc\Router\RouteStackInterface; use Zend\Mvc\Router\RouteMatch; +use Zend\Mvc\Router\RouteStackInterface; use Zend\View\Exception; /** diff --git a/src/Renderer/FeedRenderer.php b/src/Renderer/FeedRenderer.php index 672c8062..b4128c91 100644 --- a/src/Renderer/FeedRenderer.php +++ b/src/Renderer/FeedRenderer.php @@ -11,9 +11,9 @@ namespace Zend\View\Renderer; use Zend\View\Exception; -use Zend\View\Resolver\ResolverInterface as Resolver; -use Zend\View\Model\ModelInterface as Model; use Zend\View\Model\FeedModel; +use Zend\View\Model\ModelInterface as Model; +use Zend\View\Resolver\ResolverInterface as Resolver; /** * Interface class for Zend_View compatible template engine implementations diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php index 7b89d6e5..564d6f9e 100644 --- a/src/Renderer/JsonRenderer.php +++ b/src/Renderer/JsonRenderer.php @@ -15,8 +15,8 @@ use Zend\Json\Json; use Zend\Stdlib\ArrayUtils; use Zend\View\Exception; -use Zend\View\Model\ModelInterface as Model; use Zend\View\Model\JsonModel; +use Zend\View\Model\ModelInterface as Model; use Zend\View\Renderer\RendererInterface as Renderer; use Zend\View\Resolver\ResolverInterface as Resolver; diff --git a/src/Renderer/PhpRenderer.php b/src/Renderer/PhpRenderer.php index e094d1e6..140fd81a 100644 --- a/src/Renderer/PhpRenderer.php +++ b/src/Renderer/PhpRenderer.php @@ -15,9 +15,9 @@ use Zend\View\Exception; use Zend\View\HelperPluginManager; use Zend\View\Model\ModelInterface as Model; -use Zend\View\Resolver\TemplatePathStack; use Zend\View\Renderer\RendererInterface as Renderer; use Zend\View\Resolver\ResolverInterface as Resolver; +use Zend\View\Resolver\TemplatePathStack; use Zend\View\Variables; /** diff --git a/src/Renderer/RendererInterface.php b/src/Renderer/RendererInterface.php index 84fbbfb5..d2df9670 100644 --- a/src/Renderer/RendererInterface.php +++ b/src/Renderer/RendererInterface.php @@ -10,8 +10,8 @@ namespace Zend\View\Renderer; -use Zend\View\Resolver\ResolverInterface as Resolver; use Zend\View\Model\ModelInterface as Model; +use Zend\View\Resolver\ResolverInterface as Resolver; /** * Interface class for Zend_View compatible template engine implementations diff --git a/src/View.php b/src/View.php index ab306d9b..bd849445 100644 --- a/src/View.php +++ b/src/View.php @@ -10,14 +10,14 @@ namespace Zend\View; -use Zend\EventManager\EventManagerInterface; use Zend\EventManager\EventManager; use Zend\EventManager\EventManagerAwareInterface; +use Zend\EventManager\EventManagerInterface; use Zend\Mvc\MvcEvent; use Zend\Stdlib\RequestInterface as Request; use Zend\Stdlib\ResponseInterface as Response; -use Zend\View\Renderer\RendererInterface as Renderer; use Zend\View\Model\ModelInterface as Model; +use Zend\View\Renderer\RendererInterface as Renderer; use Zend\View\Renderer\TreeRendererInterface; /** From dbb4995cd6622b1ecf1feeec8a94b66962d9ff06 Mon Sep 17 00:00:00 2001 From: Matej Szendi Date: Tue, 10 Jul 2012 12:19:08 +0200 Subject: [PATCH 51/78] Replace controller param with original controller when reuseMatchedParams is enable. --- src/Helper/Url.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index 76cb3301..f18960b7 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -24,21 +24,21 @@ class Url extends AbstractHelper { /** * RouteStackInterface instance. - * + * * @var RouteStackInterface */ protected $router; - + /** * RouteInterface match returned by the router. - * + * * @var RouteMatch. */ protected $routeMatch; /** * Set the router to use for assembling. - * + * * @param RouteStackInterface $router * @return Url */ @@ -47,10 +47,10 @@ public function setRouter(RouteStackInterface $router) $this->router = $router; return $this; } - + /** * Set route match returned by the router. - * + * * @param RouteMatch $routeMatch * @return self */ @@ -83,18 +83,22 @@ public function __invoke($name = null, array $params = array(), array $options = if ($this->routeMatch === null) { throw new Exception\RuntimeException('No RouteMatch instance provided'); } - + $name = $this->routeMatch->getMatchedRouteName(); - + if ($name === null) { throw new Exception\RuntimeException('RouteMatch does not contain a matched route name'); } } - + if ($reuseMatchedParams && $this->routeMatch !== null) { $params = array_merge($this->routeMatch->getParams(), $params); + + if(isset($params[\Zend\Mvc\ModuleRouteListener::ORIGINAL_CONTROLLER])) { + $params['controller'] = $params[\Zend\Mvc\ModuleRouteListener::ORIGINAL_CONTROLLER]; + } } - + $options['name'] = $name; return $this->router->assemble($params, $options); From 515305ca62106789350af6bca3c224f864f3e5ca Mon Sep 17 00:00:00 2001 From: Matej Szendi Date: Tue, 10 Jul 2012 15:21:02 +0200 Subject: [PATCH 52/78] Replace controller param with original controller when reuseMatchedParams is enable. --- src/Helper/Url.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index f18960b7..c5007922 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -92,11 +92,13 @@ public function __invoke($name = null, array $params = array(), array $options = } if ($reuseMatchedParams && $this->routeMatch !== null) { - $params = array_merge($this->routeMatch->getParams(), $params); + $paramOriginalController = $this->routeMatch->getParam(\Zend\Mvc\ModuleRouteListener::ORIGINAL_CONTROLLER); - if(isset($params[\Zend\Mvc\ModuleRouteListener::ORIGINAL_CONTROLLER])) { - $params['controller'] = $params[\Zend\Mvc\ModuleRouteListener::ORIGINAL_CONTROLLER]; + if(null !== $paramOriginalController) { + $this->routeMatch->setParam('controller', $paramOriginalController); } + + $params = array_merge($this->routeMatch->getParams(), $params); } $options['name'] = $name; From 9a749e0bc8be7bca8780ffebdd403b2c428e3370 Mon Sep 17 00:00:00 2001 From: Matej Szendi Date: Tue, 10 Jul 2012 15:39:42 +0200 Subject: [PATCH 53/78] Update use statement --- src/Helper/Url.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index c5007922..9b0fb156 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -10,6 +10,7 @@ namespace Zend\View\Helper; +use Zend\Mvc\ModuleRouteListener; use Zend\Mvc\Router\RouteMatch; use Zend\Mvc\Router\RouteStackInterface; use Zend\View\Exception; @@ -92,7 +93,7 @@ public function __invoke($name = null, array $params = array(), array $options = } if ($reuseMatchedParams && $this->routeMatch !== null) { - $paramOriginalController = $this->routeMatch->getParam(\Zend\Mvc\ModuleRouteListener::ORIGINAL_CONTROLLER); + $paramOriginalController = $this->routeMatch->getParam(ModuleRouteListener::ORIGINAL_CONTROLLER); if(null !== $paramOriginalController) { $this->routeMatch->setParam('controller', $paramOriginalController); From c2dc97accd195fbf46acc3097845ada7248045b7 Mon Sep 17 00:00:00 2001 From: Matej Szendi Date: Wed, 11 Jul 2012 12:43:01 +0200 Subject: [PATCH 54/78] The route match object is not altered. Reformatted to Zend Framework Coding standard. --- src/Helper/Url.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Helper/Url.php b/src/Helper/Url.php index 9b0fb156..ab59608b 100644 --- a/src/Helper/Url.php +++ b/src/Helper/Url.php @@ -93,13 +93,13 @@ public function __invoke($name = null, array $params = array(), array $options = } if ($reuseMatchedParams && $this->routeMatch !== null) { - $paramOriginalController = $this->routeMatch->getParam(ModuleRouteListener::ORIGINAL_CONTROLLER); + $paramsRouteMatch = $this->routeMatch->getParams(); - if(null !== $paramOriginalController) { - $this->routeMatch->setParam('controller', $paramOriginalController); + if (isset($paramsRouteMatch[ModuleRouteListener::ORIGINAL_CONTROLLER])) { + $paramsRouteMatch['controller'] = $paramsRouteMatch[ModuleRouteListener::ORIGINAL_CONTROLLER]; } - $params = array_merge($this->routeMatch->getParams(), $params); + $params = array_merge($paramsRouteMatch, $params); } $options['name'] = $name; From 8e7816a8d0b463d9cfdf7f5ce1f41043d4deb66d Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 11 Jul 2012 22:09:11 +0200 Subject: [PATCH 55/78] [zen-46] Replace use statements in documentation and tests --- test/Helper/BasePathTest.php | 4 ++-- test/Helper/EscapeCssTest.php | 6 +++--- test/Helper/EscapeHtmlAttrTest.php | 6 +++--- test/Helper/EscapeHtmlTest.php | 6 +++--- test/Helper/EscapeJsTest.php | 6 +++--- test/Helper/EscapeUrlTest.php | 6 +++--- test/Helper/GravatarTest.php | 6 +++--- test/Helper/JsonTest.php | 8 ++++---- test/Helper/PartialLoopTest.php | 8 ++++---- test/Helper/PartialTest.php | 6 +++--- test/Helper/RenderChildModelTest.php | 10 +++++----- test/Model/JsonModelTest.php | 10 +++++----- test/Model/ViewModelTest.php | 8 ++++---- test/Renderer/FeedRendererTest.php | 12 ++++++------ test/Renderer/JsonRendererTest.php | 10 +++++----- test/Resolver/AggregateResolverTest.php | 6 +++--- test/Resolver/TemplateMapResolverTest.php | 6 +++--- test/Strategy/FeedStrategyTest.php | 22 ++++++++++----------- test/Strategy/JsonStrategyTest.php | 22 ++++++++++----------- test/Strategy/PhpRendererStrategyTest.php | 18 ++++++++--------- test/ViewEventTest.php | 12 ++++++------ test/ViewTest.php | 24 +++++++++++------------ 22 files changed, 111 insertions(+), 111 deletions(-) diff --git a/test/Helper/BasePathTest.php b/test/Helper/BasePathTest.php index 4bd6aa8b..4c5ac7de 100644 --- a/test/Helper/BasePathTest.php +++ b/test/Helper/BasePathTest.php @@ -10,8 +10,8 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - Zend\View\Helper\BasePath; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Helper\BasePath; /** * @category Zend diff --git a/test/Helper/EscapeCssTest.php b/test/Helper/EscapeCssTest.php index 4fe3d317..c7e06357 100644 --- a/test/Helper/EscapeCssTest.php +++ b/test/Helper/EscapeCssTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - stdClass, - Zend\View\Helper\EscapeCss as EscapeHelper; +use PHPUnit_Framework_TestCase as TestCase; +use stdClass; +use Zend\View\Helper\EscapeCss as EscapeHelper; class EscapeCssTest extends TestCase { diff --git a/test/Helper/EscapeHtmlAttrTest.php b/test/Helper/EscapeHtmlAttrTest.php index f1100392..3e2e99b9 100644 --- a/test/Helper/EscapeHtmlAttrTest.php +++ b/test/Helper/EscapeHtmlAttrTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - stdClass, - Zend\View\Helper\EscapeHtmlAttr as EscapeHelper; +use PHPUnit_Framework_TestCase as TestCase; +use stdClass; +use Zend\View\Helper\EscapeHtmlAttr as EscapeHelper; class EscapeHtmlAttrTest extends TestCase { diff --git a/test/Helper/EscapeHtmlTest.php b/test/Helper/EscapeHtmlTest.php index d2f08f65..6bece4ff 100644 --- a/test/Helper/EscapeHtmlTest.php +++ b/test/Helper/EscapeHtmlTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - stdClass, - Zend\View\Helper\EscapeHtml as EscapeHelper; +use PHPUnit_Framework_TestCase as TestCase; +use stdClass; +use Zend\View\Helper\EscapeHtml as EscapeHelper; class EscapeHtmlTest extends TestCase { diff --git a/test/Helper/EscapeJsTest.php b/test/Helper/EscapeJsTest.php index 53567c3f..a605bfac 100644 --- a/test/Helper/EscapeJsTest.php +++ b/test/Helper/EscapeJsTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - stdClass, - Zend\View\Helper\EscapeJs as EscapeHelper; +use PHPUnit_Framework_TestCase as TestCase; +use stdClass; +use Zend\View\Helper\EscapeJs as EscapeHelper; class EscapeJsTest extends TestCase { diff --git a/test/Helper/EscapeUrlTest.php b/test/Helper/EscapeUrlTest.php index 3562e869..ab894e70 100644 --- a/test/Helper/EscapeUrlTest.php +++ b/test/Helper/EscapeUrlTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - stdClass, - Zend\View\Helper\EscapeUrl as EscapeHelper; +use PHPUnit_Framework_TestCase as TestCase; +use stdClass; +use Zend\View\Helper\EscapeUrl as EscapeHelper; class EscapeUrlTest extends TestCase { diff --git a/test/Helper/GravatarTest.php b/test/Helper/GravatarTest.php index 9752f7e9..a4ae0a81 100644 --- a/test/Helper/GravatarTest.php +++ b/test/Helper/GravatarTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - Zend\View\Renderer\PhpRenderer as View, - Zend\View\Helper\Gravatar; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Renderer\PhpRenderer as View; +use Zend\View\Helper\Gravatar; /** * @category Zend diff --git a/test/Helper/JsonTest.php b/test/Helper/JsonTest.php index bda94b3d..a9780e56 100644 --- a/test/Helper/JsonTest.php +++ b/test/Helper/JsonTest.php @@ -10,10 +10,10 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - Zend\Http\Response, - Zend\Json\Json as JsonFormatter, - Zend\View\Helper\Json as JsonHelper; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\Http\Response; +use Zend\Json\Json as JsonFormatter; +use Zend\View\Helper\Json as JsonHelper; /** * Test class for Zend_View_Helper_Json diff --git a/test/Helper/PartialLoopTest.php b/test/Helper/PartialLoopTest.php index c6290e01..f976419c 100644 --- a/test/Helper/PartialLoopTest.php +++ b/test/Helper/PartialLoopTest.php @@ -11,10 +11,10 @@ namespace ZendTest\View\Helper; use ArrayObject; -use Iterator, - PHPUnit_Framework_TestCase as TestCase, - Zend\View\Helper\PartialLoop, - Zend\View\Renderer\PhpRenderer as View; +use Iterator; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Helper\PartialLoop; +use Zend\View\Renderer\PhpRenderer as View; /** * Test class for Zend_View_Helper_PartialLoop. diff --git a/test/Helper/PartialTest.php b/test/Helper/PartialTest.php index a9b3eef0..46d69973 100644 --- a/test/Helper/PartialTest.php +++ b/test/Helper/PartialTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - Zend\View\Helper\Partial, - Zend\View\Renderer\PhpRenderer as View; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Helper\Partial; +use Zend\View\Renderer\PhpRenderer as View; /** * Test class for Partial view helper. diff --git a/test/Helper/RenderChildModelTest.php b/test/Helper/RenderChildModelTest.php index d430087d..ea008faf 100644 --- a/test/Helper/RenderChildModelTest.php +++ b/test/Helper/RenderChildModelTest.php @@ -10,11 +10,11 @@ namespace ZendTest\View\Helper; -use PHPUnit_Framework_TestCase as TestCase, - Zend\View\Helper\RenderChildModel, - Zend\View\Model\ViewModel, - Zend\View\Renderer\PhpRenderer, - Zend\View\Resolver\TemplateMapResolver; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Helper\RenderChildModel; +use Zend\View\Model\ViewModel; +use Zend\View\Renderer\PhpRenderer; +use Zend\View\Resolver\TemplateMapResolver; /** * @category Zend diff --git a/test/Model/JsonModelTest.php b/test/Model/JsonModelTest.php index a63f8f4e..45686d41 100644 --- a/test/Model/JsonModelTest.php +++ b/test/Model/JsonModelTest.php @@ -11,11 +11,11 @@ namespace ZendTest\View\Model; use ArrayObject; -use stdClass, - PHPUnit_Framework_TestCase as TestCase, - Zend\View\Model\JsonModel, - Zend\View\Variables as ViewVariables, - Zend\Json\Json; +use stdClass; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Model\JsonModel; +use Zend\View\Variables as ViewVariables; +use Zend\Json\Json; /** * @category Zend diff --git a/test/Model/ViewModelTest.php b/test/Model/ViewModelTest.php index c48a6294..76be4e2e 100644 --- a/test/Model/ViewModelTest.php +++ b/test/Model/ViewModelTest.php @@ -11,10 +11,10 @@ namespace ZendTest\View\Model; use ArrayObject; -use stdClass, - PHPUnit_Framework_TestCase as TestCase, - Zend\View\Model\ViewModel, - Zend\View\Variables as ViewVariables; +use stdClass; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Model\ViewModel; +use Zend\View\Variables as ViewVariables; /** * @category Zend diff --git a/test/Renderer/FeedRendererTest.php b/test/Renderer/FeedRendererTest.php index 9ddec66e..eab1bfac 100644 --- a/test/Renderer/FeedRendererTest.php +++ b/test/Renderer/FeedRendererTest.php @@ -10,12 +10,12 @@ namespace ZendTest\View\Renderer; -use PHPUnit_Framework_TestCase as TestCase, - Zend\Feed\Writer\Factory as FeedFactory, - Zend\View\Model\ModelInterface as Model, - Zend\View\Model\FeedModel, - Zend\View\Model\ViewModel, - Zend\View\Renderer\FeedRenderer; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\Feed\Writer\Factory as FeedFactory; +use Zend\View\Model\ModelInterface as Model; +use Zend\View\Model\FeedModel; +use Zend\View\Model\ViewModel; +use Zend\View\Renderer\FeedRenderer; /** * @category Zend diff --git a/test/Renderer/JsonRendererTest.php b/test/Renderer/JsonRendererTest.php index 3b95e352..7dc7c9eb 100644 --- a/test/Renderer/JsonRendererTest.php +++ b/test/Renderer/JsonRendererTest.php @@ -10,11 +10,11 @@ namespace ZendTest\View\Renderer; -use ArrayObject, - PHPUnit_Framework_TestCase as TestCase, - stdClass, - Zend\View\Renderer\JsonRenderer, - Zend\View\Model\ViewModel; +use ArrayObject; +use PHPUnit_Framework_TestCase as TestCase; +use stdClass; +use Zend\View\Renderer\JsonRenderer; +use Zend\View\Model\ViewModel; /** * @category Zend diff --git a/test/Resolver/AggregateResolverTest.php b/test/Resolver/AggregateResolverTest.php index acb87737..fa773673 100644 --- a/test/Resolver/AggregateResolverTest.php +++ b/test/Resolver/AggregateResolverTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Resolver; -use ArrayObject, - PHPUnit_Framework_TestCase as TestCase, - Zend\View\Resolver; +use ArrayObject; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Resolver; /** * @category Zend diff --git a/test/Resolver/TemplateMapResolverTest.php b/test/Resolver/TemplateMapResolverTest.php index ad32765e..7c74ad1f 100644 --- a/test/Resolver/TemplateMapResolverTest.php +++ b/test/Resolver/TemplateMapResolverTest.php @@ -10,9 +10,9 @@ namespace ZendTest\View\Resolver; -use ArrayObject, - PHPUnit_Framework_TestCase as TestCase, - Zend\View\Resolver\TemplateMapResolver; +use ArrayObject; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\View\Resolver\TemplateMapResolver; /** * @category Zend diff --git a/test/Strategy/FeedStrategyTest.php b/test/Strategy/FeedStrategyTest.php index fbecd79a..a6e6f3a0 100644 --- a/test/Strategy/FeedStrategyTest.php +++ b/test/Strategy/FeedStrategyTest.php @@ -10,17 +10,17 @@ namespace ZendTest\View\Strategy; -use PHPUnit_Framework_TestCase as TestCase, - Zend\EventManager\EventManager, - Zend\Feed\Writer\FeedFactory, - Zend\Http\Request as HttpRequest, - Zend\Http\Response as HttpResponse, - Zend\View\Model\ModelInterface as Model, - Zend\View\Model\FeedModel, - Zend\View\Model\ViewModel, - Zend\View\Renderer\FeedRenderer, - Zend\View\Strategy\FeedStrategy, - Zend\View\ViewEvent; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\EventManager\EventManager; +use Zend\Feed\Writer\FeedFactory; +use Zend\Http\Request as HttpRequest; +use Zend\Http\Response as HttpResponse; +use Zend\View\Model\ModelInterface as Model; +use Zend\View\Model\FeedModel; +use Zend\View\Model\ViewModel; +use Zend\View\Renderer\FeedRenderer; +use Zend\View\Strategy\FeedStrategy; +use Zend\View\ViewEvent; /** * @category Zend diff --git a/test/Strategy/JsonStrategyTest.php b/test/Strategy/JsonStrategyTest.php index 9d65c9c7..f2b598e2 100644 --- a/test/Strategy/JsonStrategyTest.php +++ b/test/Strategy/JsonStrategyTest.php @@ -10,17 +10,17 @@ namespace ZendTest\View\Strategy; -use PHPUnit_Framework_TestCase as TestCase, - Zend\EventManager\EventManager, - Zend\Http\Request as HttpRequest, - Zend\Http\Response as HttpResponse, - Zend\View\Model\ModelInterface as Model, - Zend\View\Model\JsonModel, - Zend\View\Model\ViewModel, - Zend\View\Renderer\JsonRenderer, - Zend\View\Strategy\JsonStrategy, - Zend\View\ViewEvent, - Zend\Stdlib\Parameters; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\EventManager\EventManager; +use Zend\Http\Request as HttpRequest; +use Zend\Http\Response as HttpResponse; +use Zend\View\Model\ModelInterface as Model; +use Zend\View\Model\JsonModel; +use Zend\View\Model\ViewModel; +use Zend\View\Renderer\JsonRenderer; +use Zend\View\Strategy\JsonStrategy; +use Zend\View\ViewEvent; +use Zend\Stdlib\Parameters; /** * @category Zend diff --git a/test/Strategy/PhpRendererStrategyTest.php b/test/Strategy/PhpRendererStrategyTest.php index 08f4b4cd..ac5dc30f 100644 --- a/test/Strategy/PhpRendererStrategyTest.php +++ b/test/Strategy/PhpRendererStrategyTest.php @@ -10,15 +10,15 @@ namespace ZendTest\View\Strategy; -use PHPUnit_Framework_TestCase as TestCase, - Zend\EventManager\EventManager, - Zend\Http\Request as HttpRequest, - Zend\Http\Response as HttpResponse, - Zend\View\Helper\Placeholder\Registry as PlaceholderRegistry, - Zend\View\Model\ModelInterface as Model, - Zend\View\Renderer\PhpRenderer, - Zend\View\Strategy\PhpRendererStrategy, - Zend\View\ViewEvent; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\EventManager\EventManager; +use Zend\Http\Request as HttpRequest; +use Zend\Http\Response as HttpResponse; +use Zend\View\Helper\Placeholder\Registry as PlaceholderRegistry; +use Zend\View\Model\ModelInterface as Model; +use Zend\View\Renderer\PhpRenderer; +use Zend\View\Strategy\PhpRendererStrategy; +use Zend\View\ViewEvent; /** * @category Zend diff --git a/test/ViewEventTest.php b/test/ViewEventTest.php index 329f641a..65ff0104 100644 --- a/test/ViewEventTest.php +++ b/test/ViewEventTest.php @@ -10,12 +10,12 @@ namespace ZendTest\View; -use PHPUnit_Framework_TestCase as TestCase, - Zend\Http\Request, - Zend\Http\Response, - Zend\View\Model\ViewModel, - Zend\View\Renderer\PhpRenderer, - Zend\View\ViewEvent; +use PHPUnit_Framework_TestCase as TestCase; +use Zend\Http\Request; +use Zend\Http\Response; +use Zend\View\Model\ViewModel; +use Zend\View\Renderer\PhpRenderer; +use Zend\View\ViewEvent; class ViewEventTest extends TestCase { diff --git a/test/ViewTest.php b/test/ViewTest.php index 8db36866..d35639c8 100644 --- a/test/ViewTest.php +++ b/test/ViewTest.php @@ -10,18 +10,18 @@ namespace ZendTest\View; -use ArrayObject, - PHPUnit_Framework_TestCase as TestCase, - stdClass, - Zend\Http\Request, - Zend\Http\Response, - Zend\View\Model\ViewModel, - Zend\View\Model\JsonModel, - Zend\View\Renderer\PhpRenderer, - Zend\View\Renderer, - Zend\View\Resolver, - Zend\View\Variables as ViewVariables, - Zend\View\View; +use ArrayObject; +use PHPUnit_Framework_TestCase as TestCase; +use stdClass; +use Zend\Http\Request; +use Zend\Http\Response; +use Zend\View\Model\ViewModel; +use Zend\View\Model\JsonModel; +use Zend\View\Renderer\PhpRenderer; +use Zend\View\Renderer; +use Zend\View\Resolver; +use Zend\View\Variables as ViewVariables; +use Zend\View\View; class ViewTest extends TestCase { From ccba82c97259039c791e9e7ea78fef7e633cd60e Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 11 Jul 2012 22:20:59 +0200 Subject: [PATCH 56/78] Add blank lines around the use block --- test/Helper/CycleTest.php | 1 + test/Helper/DoctypeTest.php | 1 + test/Helper/HeadScriptTest.php | 1 + test/Helper/HeadStyleTest.php | 1 + test/Helper/InlineScriptTest.php | 1 + test/Helper/Placeholder/RegistryTest.php | 1 + test/Helper/ServerUrlTest.php | 1 + 7 files changed, 7 insertions(+) diff --git a/test/Helper/CycleTest.php b/test/Helper/CycleTest.php index f0c88a4d..465689a0 100644 --- a/test/Helper/CycleTest.php +++ b/test/Helper/CycleTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\View\Helper; + use Zend\View\Helper; /** diff --git a/test/Helper/DoctypeTest.php b/test/Helper/DoctypeTest.php index 29329895..d7cc26fa 100644 --- a/test/Helper/DoctypeTest.php +++ b/test/Helper/DoctypeTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\View\Helper; + use Zend\View\Helper; /** diff --git a/test/Helper/HeadScriptTest.php b/test/Helper/HeadScriptTest.php index 356d4495..efa78428 100644 --- a/test/Helper/HeadScriptTest.php +++ b/test/Helper/HeadScriptTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\View\Helper; + use Zend\View\Helper\Placeholder\Registry; use Zend\View\Helper; use Zend\View; diff --git a/test/Helper/HeadStyleTest.php b/test/Helper/HeadStyleTest.php index cc1b3887..b8984979 100644 --- a/test/Helper/HeadStyleTest.php +++ b/test/Helper/HeadStyleTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\View\Helper; + use Zend\View\Helper\Placeholder\Registry; use Zend\View\Helper; use Zend\View; diff --git a/test/Helper/InlineScriptTest.php b/test/Helper/InlineScriptTest.php index 0ba91df1..18c2e08d 100644 --- a/test/Helper/InlineScriptTest.php +++ b/test/Helper/InlineScriptTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\View\Helper; + use Zend\View\Helper\Placeholder\Registry; use Zend\View\Helper; diff --git a/test/Helper/Placeholder/RegistryTest.php b/test/Helper/Placeholder/RegistryTest.php index 70f2d307..312e3873 100644 --- a/test/Helper/Placeholder/RegistryTest.php +++ b/test/Helper/Placeholder/RegistryTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\View\Helper\Placeholder; + use Zend\View\Helper\Placeholder\Registry; use Zend\View\Helper\Placeholder\Container; diff --git a/test/Helper/ServerUrlTest.php b/test/Helper/ServerUrlTest.php index 0d9e81bb..3e24b880 100644 --- a/test/Helper/ServerUrlTest.php +++ b/test/Helper/ServerUrlTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\View\Helper; + use Zend\View\Helper; /** From 698dbe0ad36dbc444cda4e413e7c49991ed5b8cf Mon Sep 17 00:00:00 2001 From: Maks3w Date: Thu, 12 Jul 2012 21:11:36 +0200 Subject: [PATCH 57/78] [PSR-2] fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed Applied php-cs-fixer --fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed --- src/Helper/AbstractHelper.php | 2 +- src/Helper/DeclareVars.php | 2 +- src/Helper/EscapeCss.php | 4 +- src/Helper/EscapeHtml.php | 2 +- src/Helper/EscapeHtmlAttr.php | 2 +- src/Helper/EscapeJs.php | 2 +- src/Helper/EscapeUrl.php | 2 +- src/Helper/Escaper/AbstractHelper.php | 10 +- src/Helper/HeadMeta.php | 4 +- src/Helper/HeadScript.php | 4 +- src/Helper/Layout.php | 4 +- src/Helper/Navigation/Breadcrumbs.php | 18 ++-- src/Helper/Navigation/HelperInterface.php | 20 ++-- src/Helper/Navigation/Links.php | 4 +- src/Helper/Navigation/Menu.php | 36 +++---- src/Helper/Navigation/PluginManager.php | 8 +- src/Helper/Placeholder/Registry.php | 4 +- src/Helper/RenderChildModel.php | 18 ++-- src/Helper/ServerUrl.php | 4 +- src/Helper/ViewModel.php | 16 +-- src/Model/JsonModel.php | 17 ++- src/Model/ModelInterface.php | 60 +++++------ src/Model/ViewModel.php | 104 +++++++++---------- src/Renderer/FeedRenderer.php | 6 +- src/Renderer/JsonRenderer.php | 12 +-- src/Renderer/RendererInterface.php | 4 +- src/Renderer/TreeRendererInterface.php | 2 +- src/Resolver/AggregateResolver.php | 22 ++-- src/Resolver/ResolverInterface.php | 6 +- src/Resolver/TemplateMapResolver.php | 36 +++---- src/Resolver/TemplatePathStack.php | 10 +- src/Stream.php | 2 +- src/Variables.php | 36 +++---- src/View.php | 3 +- test/Helper/BasePathTest.php | 10 +- test/Helper/DoctypeTest.php | 3 +- test/Helper/EscapeCssTest.php | 4 +- test/Helper/EscapeHtmlAttrTest.php | 4 +- test/Helper/EscapeHtmlTest.php | 4 +- test/Helper/EscapeJsTest.php | 4 +- test/Helper/EscapeUrlTest.php | 4 +- test/Helper/Navigation/LinksTest.php | 2 +- test/Helper/Navigation/MenuTest.php | 2 +- test/Helper/Navigation/NavigationTest.php | 8 +- test/Helper/Navigation/_files/navigation.xml | 88 ++++++++-------- test/Helper/RenderChildModelTest.php | 2 +- test/PhpRendererTest.php | 6 +- test/Strategy/FeedStrategyTest.php | 2 +- test/Strategy/JsonStrategyTest.php | 2 +- test/TemplatePathStackTest.php | 12 +-- test/TestAsset/Invokable.php | 4 +- 51 files changed, 323 insertions(+), 324 deletions(-) diff --git a/src/Helper/AbstractHelper.php b/src/Helper/AbstractHelper.php index 2dbdf3e7..1ced3587 100644 --- a/src/Helper/AbstractHelper.php +++ b/src/Helper/AbstractHelper.php @@ -41,7 +41,7 @@ public function setView(Renderer $view) /** * Get the view object - * + * * @return null|Renderer */ public function getView() diff --git a/src/Helper/DeclareVars.php b/src/Helper/DeclareVars.php index 8e2e7937..2a24dcc2 100644 --- a/src/Helper/DeclareVars.php +++ b/src/Helper/DeclareVars.php @@ -57,7 +57,7 @@ public function __invoke() foreach ($key as $name => $value) { $this->_declareVar($name, $value); } - } else if (!isset($view->vars()->$key)) { + } elseif (!isset($view->vars()->$key)) { $this->_declareVar($key); } } diff --git a/src/Helper/EscapeCss.php b/src/Helper/EscapeCss.php index 4143ad23..597d4486 100644 --- a/src/Helper/EscapeCss.php +++ b/src/Helper/EscapeCss.php @@ -21,7 +21,7 @@ */ class EscapeCss extends Escaper\AbstractHelper { - + /** * Escape a value for current escaping strategy * @@ -32,5 +32,5 @@ protected function escape($value) { return $this->getEscaper()->escapeCss($value); } - + } diff --git a/src/Helper/EscapeHtml.php b/src/Helper/EscapeHtml.php index 43bb4286..0ee00dcc 100644 --- a/src/Helper/EscapeHtml.php +++ b/src/Helper/EscapeHtml.php @@ -21,7 +21,7 @@ */ class EscapeHtml extends Escaper\AbstractHelper { - + /** * Escape a value for current escaping strategy * diff --git a/src/Helper/EscapeHtmlAttr.php b/src/Helper/EscapeHtmlAttr.php index 606a0344..e674f089 100644 --- a/src/Helper/EscapeHtmlAttr.php +++ b/src/Helper/EscapeHtmlAttr.php @@ -21,7 +21,7 @@ */ class EscapeHtmlAttr extends Escaper\AbstractHelper { - + /** * Escape a value for current escaping strategy * diff --git a/src/Helper/EscapeJs.php b/src/Helper/EscapeJs.php index e5ac73f2..c186e109 100644 --- a/src/Helper/EscapeJs.php +++ b/src/Helper/EscapeJs.php @@ -21,7 +21,7 @@ */ class EscapeJs extends Escaper\AbstractHelper { - + /** * Escape a value for current escaping strategy * diff --git a/src/Helper/EscapeUrl.php b/src/Helper/EscapeUrl.php index bef570f8..a687f133 100644 --- a/src/Helper/EscapeUrl.php +++ b/src/Helper/EscapeUrl.php @@ -21,7 +21,7 @@ */ class EscapeUrl extends Escaper\AbstractHelper { - + /** * Escape a value for current escaping strategy * diff --git a/src/Helper/Escaper/AbstractHelper.php b/src/Helper/Escaper/AbstractHelper.php index dc391af2..4a9385a9 100644 --- a/src/Helper/Escaper/AbstractHelper.php +++ b/src/Helper/Escaper/AbstractHelper.php @@ -58,8 +58,8 @@ public function getEscaper() /** * Set the encoding to use for escape operations - * - * @param string $encoding + * + * @param string $encoding * @return AbstractEscaper */ public function setEncoding($encoding) @@ -76,7 +76,7 @@ public function setEncoding($encoding) /** * Get the encoding to use for escape operations - * + * * @return string */ public function getEncoding() @@ -86,8 +86,8 @@ public function getEncoding() /** * Invoke this helper: escape a value - * - * @param mixed $value + * + * @param mixed $value * @param int $recurse Expects one of the recursion constants; used to decide whether or not to recurse the given value when escaping * @return mixed Given a scalar, a scalar value is returned. Given an object, with the $recurse flag not allowing object recursion, returns a string. Otherwise, returns an array. * @throws Exception\InvalidArgumentException diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index c0b05450..a193cd72 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -164,10 +164,10 @@ public function __call($method, $args) /** * Create an HTML5-style meta charset tag. Something like - * + * * Not valid in a non-HTML5 doctype * - * @param string $charset + * @param string $charset * @return \Zend\View\Helper\HeadMeta Provides a fluent interface */ public function setCharset($charset) diff --git a/src/Helper/HeadScript.php b/src/Helper/HeadScript.php index 6411a121..27bebac7 100644 --- a/src/Helper/HeadScript.php +++ b/src/Helper/HeadScript.php @@ -395,7 +395,7 @@ 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)) + if ((!$this->arbitraryAttributesAllowed() && !in_array($key, $this->_optionalAttributes)) || in_array($key, array('conditional', 'noescape'))) { continue; @@ -424,7 +424,7 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd) if ($addScriptEscape) { $html .= $indent . ' ' . $escapeEnd . PHP_EOL; } - + $html .= $indent; } $html .= ''; diff --git a/src/Helper/Layout.php b/src/Helper/Layout.php index ff8478bc..e9787e41 100644 --- a/src/Helper/Layout.php +++ b/src/Helper/Layout.php @@ -69,7 +69,7 @@ public function __invoke($template = null) /** * Get the root view model - * + * * @return null|Model */ protected function getRoot() @@ -86,7 +86,7 @@ protected function getRoot() /** * Retrieve the view model helper - * + * * @return ViewModel */ protected function getViewModelHelper() diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php index 0bc615d5..6c39e97d 100644 --- a/src/Helper/Navigation/Breadcrumbs.php +++ b/src/Helper/Navigation/Breadcrumbs.php @@ -121,9 +121,9 @@ public function getLinkLast() * Sets which partial view script to use for rendering 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 + * 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 fluent interface, returns self */ @@ -209,13 +209,13 @@ public function renderStraight($container = null) * so in the script it will be available in $this->container. * * @param AbstractContainer $container [optional] container to pass to view script. - * Default is to use the container registered + * 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 + * @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 helper output * @throws Exception\RuntimeException if no partial provided diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index 07b96780..43fd4889 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -27,8 +27,8 @@ interface HelperInterface * Sets navigation container the helper should operate on by default * * @param string|Navigation\AbstractContainer $container [optional] container to operate - * on. Default is null, which - * indicates that the container + * on. Default is null, which + * indicates that the container * should be reset. * @return HelperInterface fluent interface, returns self */ @@ -44,9 +44,9 @@ public function getContainer(); /** * Sets translator to use in helper * - * @param mixed $translator [optional] translator. Expects an object of - * type {@link \Zend\Translator\Adapter} or - * {@link \Zend\Translator\Translator}, or null. + * @param mixed $translator [optional] translator. Expects an object of + * type {@link \Zend\Translator\Adapter} or + * {@link \Zend\Translator\Translator}, or null. * Default is null. * @return HelperInterface fluent interface, returns self */ @@ -78,8 +78,8 @@ 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 + * @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 if $role is invalid * @return HelperInterface fluent interface, returns @@ -179,9 +179,9 @@ public function __toString(); * Renders helper * * @param string|Navigation\AbstractContainer $container [optional] container to render. - * Default is null, which indicates - * that the helper should render - * the container returned by {@link + * 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 if unable to render diff --git a/src/Helper/Navigation/Links.php b/src/Helper/Navigation/Links.php index 6c494460..aababd3e 100644 --- a/src/Helper/Navigation/Links.php +++ b/src/Helper/Navigation/Links.php @@ -724,8 +724,8 @@ public function renderLink(AbstractPage $page, $attrib, $relation) * Implements {@link HelperInterface::render()}. * * @param AbstractContainer string|$container [optional] container to render. - * Default is to render the - * container registered in the + * Default is to render the + * container registered in the * helper. * @return string helper output */ diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php index 2c97d5f0..9d8b1330 100644 --- a/src/Helper/Navigation/Menu.php +++ b/src/Helper/Navigation/Menu.php @@ -151,9 +151,9 @@ public function getRenderParents() * Sets which partial view script to use for rendering 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 + * 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 fluent interface, returns self */ @@ -306,10 +306,10 @@ protected function renderDeepestMenu(AbstractContainer $container, if (!$active['page']->hasPages()) { return ''; } - } else if (!$active['page']->hasPages()) { + } elseif (!$active['page']->hasPages()) { // found pages has no children; render siblings $active['page'] = $active['page']->getParent(); - } else if (is_int($maxDepth) && $active['depth'] +1 > $maxDepth) { + } elseif (is_int($maxDepth) && $active['depth'] +1 > $maxDepth) { // children are below max depth; render siblings $active['page'] = $active['page']->getParent(); } @@ -376,14 +376,14 @@ protected function _renderMenu(AbstractContainer $container, if ($depth < $minDepth || !$this->accept($page)) { // page is below minDepth or not accepted by acl/visibilty continue; - } else if ($onlyActive && !$isActive) { + } elseif ($onlyActive && !$isActive) { // page is not active itself, but might be in the active branch $accept = false; if ($foundPage) { if ($foundPage->hasPage($page)) { // accept if page is a direct child of the active page $accept = true; - } else if ($foundPage->getParent()->hasPage($page)) { + } elseif ($foundPage->getParent()->hasPage($page)) { // page is a sibling of the active page... if (!$foundPage->hasPages() || is_int($maxDepth) && $foundDepth + 1 > $maxDepth) { @@ -411,7 +411,7 @@ protected function _renderMenu(AbstractContainer $container, $ulClass = ''; } $html .= $myIndent . '' . self::EOL; - } else if ($prevDepth > $depth) { + } elseif ($prevDepth > $depth) { // close li/ul tags until we're at current depth for ($i = $prevDepth; $i > $depth; $i--) { $ind = $indent . str_repeat(' ', $i); @@ -457,9 +457,9 @@ protected function _renderMenu(AbstractContainer $container, * * * @param AbstractContainer $container [optional] container to create menu from. - * Default is to use the container retrieved + * Default is to use the container retrieved * from {@link getContainer()}. - * @param array $options [optional] options for controlling rendering + * @param array $options [optional] options for controlling rendering * @return string rendered menu */ public function renderMenu($container = null, array $options = array()) @@ -542,14 +542,14 @@ public function renderSubMenu(AbstractContainer $container = null, * echo 'Number of pages: ', count($this->container);. * * @param AbstractContainer $container [optional] container to pass to view - * script. Default is to use the container + * 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 + * @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 helper output * @throws Exception\RuntimeException if no partial provided @@ -608,7 +608,7 @@ public function renderPartial($container = null, $partial = null) * @see renderMenu() * * @param AbstractContainer $container [optional] container to render. Default is - * to render the container registered in the + * to render the container registered in the * helper. * @return string helper output */ diff --git a/src/Helper/Navigation/PluginManager.php b/src/Helper/Navigation/PluginManager.php index b7865349..c743bb8c 100644 --- a/src/Helper/Navigation/PluginManager.php +++ b/src/Helper/Navigation/PluginManager.php @@ -17,7 +17,7 @@ * Plugin manager implementation for navigation helpers * * Enforces that helpers retrieved are instances of - * Navigation\HelperInterface. Additionally, it registers a number of default + * Navigation\HelperInterface. Additionally, it registers a number of default * helpers. * * @category Zend @@ -28,7 +28,7 @@ class PluginManager extends HelperPluginManager { /** * Default set of helpers - * + * * @var array */ protected $invokableClasses = array( @@ -42,8 +42,8 @@ class PluginManager extends HelperPluginManager * Validate the plugin * * Checks that the helper loaded is an instance of AbstractHelper. - * - * @param mixed $plugin + * + * @param mixed $plugin * @return void * @throws Exception\InvalidArgumentException if invalid */ diff --git a/src/Helper/Placeholder/Registry.php b/src/Helper/Placeholder/Registry.php index 8bca19c1..369d3248 100644 --- a/src/Helper/Placeholder/Registry.php +++ b/src/Helper/Placeholder/Registry.php @@ -21,7 +21,7 @@ class Registry { /** - * @var Registry Singleton instance + * @var Registry Singleton instance */ protected static $instance; @@ -55,7 +55,7 @@ public static function getRegistry() * Unset the singleton * * Primarily useful for testing purposes; sets {@link $instance} to null. - * + * * @return void */ public static function unsetRegistry() diff --git a/src/Helper/RenderChildModel.php b/src/Helper/RenderChildModel.php index f8400331..f597922b 100644 --- a/src/Helper/RenderChildModel.php +++ b/src/Helper/RenderChildModel.php @@ -16,7 +16,7 @@ /** * Helper for rendering child view models * - * Finds children matching "capture-to" values, and renders them using the + * Finds children matching "capture-to" values, and renders them using the * composed view instance. * * @package Zend_View @@ -38,8 +38,8 @@ class RenderChildModel extends AbstractHelper * Invoke as a function * * Proxies to {render()}. - * - * @param string $child + * + * @param string $child * @return string */ public function __invoke($child) @@ -52,8 +52,8 @@ public function __invoke($child) * * If a matching child model is found, it is rendered. If not, an empty * string is returned. - * - * @param string $child + * + * @param string $child * @return string */ public function render($child) @@ -77,8 +77,8 @@ public function render($child) * Iterates through the current view model, looking for a child model that * has a captureTo value matching the requested $child. If found, that child * model is returned; otherwise, a boolean false is returned. - * - * @param string $child + * + * @param string $child * @return false|Model */ protected function findChild($child) @@ -94,7 +94,7 @@ protected function findChild($child) /** * Get the current view model - * + * * @return null|Model */ protected function getCurrent() @@ -111,7 +111,7 @@ protected function getCurrent() /** * Retrieve the view model helper - * + * * @return ViewModel */ protected function getViewModelHelper() diff --git a/src/Helper/ServerUrl.php b/src/Helper/ServerUrl.php index aec523d6..5208316e 100644 --- a/src/Helper/ServerUrl.php +++ b/src/Helper/ServerUrl.php @@ -53,7 +53,7 @@ public function __construct() if (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) { $this->setHost($_SERVER['HTTP_HOST']); - } else if (isset($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'])) { + } elseif (isset($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'])) { $name = $_SERVER['SERVER_NAME']; $port = $_SERVER['SERVER_PORT']; @@ -81,7 +81,7 @@ public function __invoke($requestUri = null) { if ($requestUri === true) { $path = $_SERVER['REQUEST_URI']; - } else if (is_string($requestUri)) { + } elseif (is_string($requestUri)) { $path = $requestUri; } else { $path = ''; diff --git a/src/Helper/ViewModel.php b/src/Helper/ViewModel.php index e732c755..a73cc28f 100644 --- a/src/Helper/ViewModel.php +++ b/src/Helper/ViewModel.php @@ -32,7 +32,7 @@ class ViewModel extends AbstractHelper /** * Get the root view model - * + * * @return null|Model */ public function getRoot() @@ -42,7 +42,7 @@ public function getRoot() /** * Is a root view model composed? - * + * * @return bool */ public function hasRoot() @@ -52,7 +52,7 @@ public function hasRoot() /** * Get the current view model - * + * * @return null|Model */ public function getCurrent() @@ -62,7 +62,7 @@ public function getCurrent() /** * Is a current view model composed? - * + * * @return bool */ public function hasCurrent() @@ -72,8 +72,8 @@ public function hasCurrent() /** * Set the root view model - * - * @param Model $model + * + * @param Model $model * @return ViewModel */ public function setRoot(Model $model) @@ -84,8 +84,8 @@ public function setRoot(Model $model) /** * Set the current view model - * - * @param Model $model + * + * @param Model $model * @return ViewModel */ public function setCurrent(Model $model) diff --git a/src/Model/JsonModel.php b/src/Model/JsonModel.php index 68d8f0a7..b22c431b 100644 --- a/src/Model/JsonModel.php +++ b/src/Model/JsonModel.php @@ -22,31 +22,31 @@ class JsonModel extends ViewModel { /** - * JSON probably won't need to be captured into a + * JSON probably won't need to be captured into a * a parent container by default. - * + * * @var string */ protected $captureTo = null; /** * JSONP callback (if set, wraps the return in a function call) - * + * * @var string */ protected $jsonpCallback = null; /** * JSON is usually terminal - * + * * @var bool */ protected $terminate = true; /** * Set the JSONP callback function name - * - * @param string $callback + * + * @param string $callback * @return JsonModel */ public function setJsonpCallback($callback) @@ -57,7 +57,7 @@ public function setJsonpCallback($callback) /** * Serialize to JSON - * + * * @return string */ public function serialize() @@ -67,8 +67,7 @@ public function serialize() $variables = ArrayUtils::iteratorToArray($variables); } - if(!is_null($this->jsonpCallback)) - { + if(!is_null($this->jsonpCallback)) { return $this->jsonpCallback.'('.Json::encode($variables).');'; } else { return Json::encode($variables); diff --git a/src/Model/ModelInterface.php b/src/Model/ModelInterface.php index 71f186b7..8ab8f718 100644 --- a/src/Model/ModelInterface.php +++ b/src/Model/ModelInterface.php @@ -29,55 +29,55 @@ interface ModelInterface extends Countable, IteratorAggregate { /** * Set renderer option/hint - * - * @param string $name - * @param mixed $value + * + * @param string $name + * @param mixed $value * @return ModelInterface */ public function setOption($name, $value); /** * Set renderer options/hints en masse - * - * @param array|\Traversable $name + * + * @param array|\Traversable $name * @return ModelInterface */ public function setOptions($options); /** * Get renderer options/hints - * + * * @return array|\Traversable */ public function getOptions(); - + /** * Set view variable - * - * @param string $name - * @param mixed $value + * + * @param string $name + * @param mixed $value * @return ModelInterface */ public function setVariable($name, $value); /** * Set view variables en masse - * - * @param array|\ArrayAccess $variables + * + * @param array|\ArrayAccess $variables * @return ModelInterface */ public function setVariables($variables); /** * Get view variables - * + * * @return array|\ArrayAccess */ public function getVariables(); /** - * Set the template to be used by this model - * + * Set the template to be used by this model + * * @param string $template * @return ModelInterface */ @@ -85,14 +85,14 @@ public function setTemplate($template); /** * Get the template to be used by this model - * + * * @return string */ public function getTemplate(); /** * Add a child model - * + * * @param ModelInterface $child * @param null|string $captureTo Optional; if specified, the "capture to" value to set on the child * @param null|bool $append Optional; if specified, append to child with the same capture @@ -110,54 +110,54 @@ public function addChild(ModelInterface $child, $captureTo = null, $append = fal public function getChildren(); /** - * Does the model have any children? - * + * Does the model have any children? + * * @return bool */ public function hasChildren(); /** * Set the name of the variable to capture this model to, if it is a child model - * - * @param string $capture + * + * @param string $capture * @return ModelInterface */ public function setCaptureTo($capture); /** * Get the name of the variable to which to capture this model - * + * * @return string */ public function captureTo(); /** * Set flag indicating whether or not this is considered a terminal or standalone model - * - * @param bool $terminate + * + * @param bool $terminate * @return ModelInterface */ public function setTerminal($terminate); /** * Is this considered a terminal or standalone model? - * + * * @return bool */ public function terminate(); - - + + /** * Set flag indicating whether or not append to child with the same capture - * - * @param bool $append + * + * @param bool $append * @return ModelInterface */ public function setAppend($append); /** * Is this append to child with the same capture? - * + * * @return bool */ public function isAppend(); diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index 191ca713..d8d5a276 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -26,8 +26,8 @@ class ViewModel implements ModelInterface { /** - * What variable a parent model should capture this model to - * + * What variable a parent model should capture this model to + * * @var string */ protected $captureTo = 'content'; @@ -45,15 +45,15 @@ class ViewModel implements ModelInterface protected $options = array(); /** - * Template to use when rendering this model - * + * Template to use when rendering this model + * * @var string */ protected $template = ''; /** * Is this a standalone, or terminal, model? - * + * * @var bool */ protected $terminate = false; @@ -63,20 +63,20 @@ class ViewModel implements ModelInterface * @var array|ArrayAccess&Traversable */ protected $variables = array(); - - + + /** * Is this append to child with the same capture? - * + * * @var bool */ protected $append = false; /** * Constructor - * - * @param null|array|Traversable $variables - * @param array|Traversable $options + * + * @param null|array|Traversable $variables + * @param array|Traversable $options * @return void */ public function __construct($variables = null, $options = null) @@ -93,9 +93,9 @@ public function __construct($variables = null, $options = null) /** * Property overloading: set variable value - * - * @param string $name - * @param mixed $value + * + * @param string $name + * @param mixed $value * @return void */ public function __set($name, $value) @@ -106,8 +106,8 @@ public function __set($name, $value) /** * Property overloading: get variable value - * - * @param string $name + * + * @param string $name * @return mixed */ public function __get($name) @@ -122,8 +122,8 @@ public function __get($name) /** * Property overloading: do we have the requested variable value? - * - * @param string $name + * + * @param string $name * @return bool */ public function __isset($name) @@ -134,8 +134,8 @@ public function __isset($name) /** * Property overloading: unset the requested variable - * - * @param string $name + * + * @param string $name * @return void */ public function __unset($name) @@ -150,9 +150,9 @@ public function __unset($name) /** * Set renderer option/hint - * - * @param string $name - * @param mixed $value + * + * @param string $name + * @param mixed $value * @return ViewModel */ public function setOption($name, $value) @@ -163,8 +163,8 @@ public function setOption($name, $value) /** * Set renderer options/hints en masse - * - * @param array|Traversable $name + * + * @param array|Traversable $name * @return ViewModel */ public function setOptions($options) @@ -189,19 +189,19 @@ public function setOptions($options) /** * Get renderer options/hints - * + * * @return array */ public function getOptions() { return $this->options; } - + /** * Set view variable - * - * @param string $name - * @param mixed $value + * + * @param string $name + * @param mixed $value * @return ViewModel */ public function setVariable($name, $value) @@ -214,8 +214,8 @@ public function setVariable($name, $value) * Set view variables en masse * * Can be an array or a Traversable + ArrayAccess object. - * - * @param array|ArrayAccess&Traversable $variables + * + * @param array|ArrayAccess&Traversable $variables * @return ViewModel */ public function setVariables($variables) @@ -244,7 +244,7 @@ public function setVariables($variables) /** * Get view variables - * + * * @return array|ArrayAccess|Traversable */ public function getVariables() @@ -253,8 +253,8 @@ public function getVariables() } /** - * Set the template to be used by this model - * + * Set the template to be used by this model + * * @param string $template * @return ViewModel */ @@ -266,7 +266,7 @@ public function setTemplate($template) /** * Get the template to be used by this model - * + * * @return string */ public function getTemplate() @@ -276,7 +276,7 @@ public function getTemplate() /** * Add a child model - * + * * @param ModelInterface $child * @param null|string $captureTo Optional; if specified, the "capture to" value to set on the child * @param null|bool $append Optional; if specified, append to child with the same capture @@ -291,7 +291,7 @@ public function addChild(ModelInterface $child, $captureTo = null, $append = nul if (null !== $captureTo) { $child->setAppend($append); } - + return $this; } @@ -308,8 +308,8 @@ public function getChildren() } /** - * Does the model have any children? - * + * Does the model have any children? + * * @return bool */ public function hasChildren() @@ -319,8 +319,8 @@ public function hasChildren() /** * Set the name of the variable to capture this model to, if it is a child model - * - * @param string $capture + * + * @param string $capture * @return ViewModel */ public function setCaptureTo($capture) @@ -331,7 +331,7 @@ public function setCaptureTo($capture) /** * Get the name of the variable to which to capture this model - * + * * @return string */ public function captureTo() @@ -341,8 +341,8 @@ public function captureTo() /** * Set flag indicating whether or not this is considered a terminal or standalone model - * - * @param bool $terminate + * + * @param bool $terminate * @return ViewModel */ public function setTerminal($terminate) @@ -353,18 +353,18 @@ public function setTerminal($terminate) /** * Is this considered a terminal or standalone model? - * + * * @return bool */ public function terminate() { return $this->terminate; } - + /** * Set flag indicating whether or not append to child with the same capture - * - * @param bool $append + * + * @param bool $append * @return ViewModel */ public function setAppend($append) @@ -375,7 +375,7 @@ public function setAppend($append) /** * Is this append to child with the same capture? - * + * * @return bool */ public function isAppend() @@ -385,7 +385,7 @@ public function isAppend() /** * Return count of children - * + * * @return int */ public function count() @@ -395,7 +395,7 @@ public function count() /** * Get iterator of children - * + * * @return ArrayIterator */ public function getIterator() diff --git a/src/Renderer/FeedRenderer.php b/src/Renderer/FeedRenderer.php index b4128c91..f4f36256 100644 --- a/src/Renderer/FeedRenderer.php +++ b/src/Renderer/FeedRenderer.php @@ -50,9 +50,9 @@ public function getEngine() /** * Set the resolver used to map a template name to a resource the renderer may consume. - * + * * @todo Determine use case for resolvers for feeds - * @param Resolver $resolver + * @param Resolver $resolver * @return FeedRenderer */ public function setResolver(Resolver $resolver) @@ -128,7 +128,7 @@ public function setFeedType($feedType) $this->feedType = $feedType; return $this; } - + /** * Get feed type * diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php index 564d6f9e..c2b9aabe 100644 --- a/src/Renderer/JsonRenderer.php +++ b/src/Renderer/JsonRenderer.php @@ -63,9 +63,9 @@ public function getEngine() /** * Set the resolver used to map a template name to a resource the renderer may consume. - * + * * @todo Determine use case for resolvers when rendering JSON - * @param Resolver $resolver + * @param Resolver $resolver * @return Renderer */ public function setResolver(Resolver $resolver) @@ -175,7 +175,7 @@ public function render($nameOrModel, $values = null) * Can this renderer render trees of view models? * * Yes. - * + * * @return true */ public function canRenderTrees() @@ -185,8 +185,8 @@ public function canRenderTrees() /** * Retrieve values from a model and recurse its children to build a data structure - * - * @param Model $model + * + * @param Model $model * @return array */ protected function recurseModel(Model $model) @@ -195,7 +195,7 @@ protected function recurseModel(Model $model) if ($values instanceof Traversable) { $values = ArrayUtils::iteratorToArray($values); } - + if (!$model->hasChildren()) { return $values; } diff --git a/src/Renderer/RendererInterface.php b/src/Renderer/RendererInterface.php index d2df9670..c97355b5 100644 --- a/src/Renderer/RendererInterface.php +++ b/src/Renderer/RendererInterface.php @@ -34,8 +34,8 @@ public function getEngine(); /** * Set the resolver used to map a template name to a resource the renderer may consume. - * - * @param Resolver $resolver + * + * @param Resolver $resolver * @return RendererInterface */ public function setResolver(Resolver $resolver); diff --git a/src/Renderer/TreeRendererInterface.php b/src/Renderer/TreeRendererInterface.php index e53044d5..99c050a9 100644 --- a/src/Renderer/TreeRendererInterface.php +++ b/src/Renderer/TreeRendererInterface.php @@ -19,7 +19,7 @@ interface TreeRendererInterface { /** * Indicate whether the renderer is capable of rendering trees of view models - * + * * @return bool */ public function canRenderTrees(); diff --git a/src/Resolver/AggregateResolver.php b/src/Resolver/AggregateResolver.php index a08ccccb..02e8f796 100644 --- a/src/Resolver/AggregateResolver.php +++ b/src/Resolver/AggregateResolver.php @@ -47,7 +47,7 @@ class AggregateResolver implements Countable, IteratorAggregate, ResolverInterfa * Constructor * * Instantiate the internal priority queue - * + * * @return void */ public function __construct() @@ -57,7 +57,7 @@ public function __construct() /** * Return count of attached resolvers - * + * * @return void */ public function count() @@ -67,7 +67,7 @@ public function count() /** * IteratorAggregate: return internal iterator - * + * * @return Traversable */ public function getIterator() @@ -77,9 +77,9 @@ public function getIterator() /** * Attach a resolver - * - * @param Resolver $resolver - * @param int $priority + * + * @param Resolver $resolver + * @param int $priority * @return AggregateResolver */ public function attach(Resolver $resolver, $priority = 1) @@ -90,9 +90,9 @@ public function attach(Resolver $resolver, $priority = 1) /** * Resolve a template/pattern name to a resource the renderer can consume - * - * @param string $name - * @param null|Renderer $renderer + * + * @param string $name + * @param null|Renderer $renderer * @return false|string */ public function resolve($name, Renderer $renderer = null) @@ -123,7 +123,7 @@ public function resolve($name, Renderer $renderer = null) /** * Return the last successful resolver, if any - * + * * @return Resolver */ public function getLastSuccessfulResolver() @@ -133,7 +133,7 @@ public function getLastSuccessfulResolver() /** * Get last lookup failure - * + * * @return false|string */ public function getLastLookupFailure() diff --git a/src/Resolver/ResolverInterface.php b/src/Resolver/ResolverInterface.php index bed8ea4a..2759be09 100644 --- a/src/Resolver/ResolverInterface.php +++ b/src/Resolver/ResolverInterface.php @@ -21,9 +21,9 @@ interface ResolverInterface { /** * Resolve a template/pattern name to a resource the renderer can consume - * - * @param string $name - * @param null|Renderer $renderer + * + * @param string $name + * @param null|Renderer $renderer * @return mixed */ public function resolve($name, Renderer $renderer = null); diff --git a/src/Resolver/TemplateMapResolver.php b/src/Resolver/TemplateMapResolver.php index 3345f6e3..a6a0bdde 100644 --- a/src/Resolver/TemplateMapResolver.php +++ b/src/Resolver/TemplateMapResolver.php @@ -33,8 +33,8 @@ class TemplateMapResolver implements IteratorAggregate, ResolverInterface * Constructor * * Instantiate and optionally populate template map. - * - * @param array|Traversable $map + * + * @param array|Traversable $map * @return void */ public function __construct($map = array()) @@ -44,7 +44,7 @@ public function __construct($map = array()) /** * IteratorAggregate: return internal iterator - * + * * @return Traversable */ public function getIterator() @@ -56,8 +56,8 @@ public function getIterator() * Set (overwrite) template map * * Maps should be arrays or Traversable objects with name => path pairs - * - * @param array|Traversable $map + * + * @param array|Traversable $map * @return TemplateMapResolver */ public function setMap($map) @@ -80,9 +80,9 @@ public function setMap($map) /** * Add an entry to the map - * - * @param string|array|Traversable $nameOrMap - * @param null|string $path + * + * @param string|array|Traversable $nameOrMap + * @param null|string $path * @return TemplateResolver */ public function add($nameOrMap, $path = null) @@ -113,8 +113,8 @@ public function add($nameOrMap, $path = null) /** * Merge internal map with provided map - * - * @param array|Traversable $map + * + * @param array|Traversable $map * @return TemplateMapResolver */ public function merge($map) @@ -137,8 +137,8 @@ public function merge($map) /** * Does the resolver contain an entry for the given name? - * - * @param string $name + * + * @param string $name * @return bool */ public function has($name) @@ -148,8 +148,8 @@ public function has($name) /** * Retrieve a template path by name - * - * @param string $name + * + * @param string $name * @return false|string * @throws Exception\DomainException if no entry exists */ @@ -163,7 +163,7 @@ public function get($name) /** * Retrieve the template map - * + * * @return array */ public function getMap() @@ -173,9 +173,9 @@ public function getMap() /** * Resolve a template/pattern name to a resource the renderer can consume - * - * @param string $name - * @param null|Renderer $renderer + * + * @param string $name + * @param null|Renderer $renderer * @return string */ public function resolve($name, Renderer $renderer = null) diff --git a/src/Resolver/TemplatePathStack.php b/src/Resolver/TemplatePathStack.php index e47c264e..ae2a601c 100644 --- a/src/Resolver/TemplatePathStack.php +++ b/src/Resolver/TemplatePathStack.php @@ -31,7 +31,7 @@ class TemplatePathStack implements ResolverInterface * Default suffix to use * * Appends this suffix if the template requested does not use it. - * + * * @var string */ protected $defaultSuffix = 'phtml'; @@ -43,7 +43,7 @@ class TemplatePathStack implements ResolverInterface /** * Reason for last lookup failure - * + * * @var false|string */ protected $lastLookupFailure = false; @@ -128,7 +128,7 @@ public function setDefaultSuffix($defaultSuffix) $this->defaultSuffix = ltrim($this->defaultSuffix, '.'); return $this; } - + /** * Get default file suffix * @@ -315,7 +315,7 @@ public function resolve($name, Renderer $renderer = null) if (!file_exists($filePath)) { break; } - } + } if ($this->useStreamWrapper()) { // If using a stream wrapper, prepend the spec to the path $filePath = 'zend.view://' . $filePath; @@ -330,7 +330,7 @@ public function resolve($name, Renderer $renderer = null) /** * Get the last lookup failure message, if any - * + * * @return false|string */ public function getLastLookupFailure() diff --git a/src/Stream.php b/src/Stream.php index ce9d067c..5183e99e 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -68,7 +68,7 @@ public function stream_open($path, $mode, $options, &$opened_path) } /** - * Convert to long-form and to + * Convert to long-form and to * */ $this->_data = preg_replace('/\<\?\=/', "_data); diff --git a/src/Variables.php b/src/Variables.php index eee4168b..e367b449 100644 --- a/src/Variables.php +++ b/src/Variables.php @@ -27,22 +27,22 @@ class Variables extends ArrayObject * Strict variables flag; when on, undefined variables accessed in the view * scripts will trigger notices * - * @var bool + * @var bool */ protected $strictVars = false; /** * Constructor - * - * @param array $variables - * @param array $options + * + * @param array $variables + * @param array $options * @return void */ - public function __construct(array $variables = array(), array $options = array()) + public function __construct(array $variables = array(), array $options = array()) { parent::__construct( - $variables, - ArrayObject::ARRAY_AS_PROPS, + $variables, + ArrayObject::ARRAY_AS_PROPS, 'ArrayIterator' ); @@ -51,8 +51,8 @@ public function __construct(array $variables = array(), array $options = array() /** * Configure object - * - * @param array $options + * + * @param array $options * @return Variables */ public function setOptions(array $options) @@ -73,8 +73,8 @@ public function setOptions(array $options) /** * Set status of "strict vars" flag - * - * @param bool $flag + * + * @param bool $flag * @return Variables */ public function setStrictVars($flag) @@ -85,7 +85,7 @@ public function setStrictVars($flag) /** * Are we operating with strict variables? - * + * * @return bool */ public function isStrict() @@ -95,8 +95,8 @@ public function isStrict() /** * Assign many values at once - * - * @param array|object $spec + * + * @param array|object $spec * @return Variables * @throws Exception\InvalidArgumentException */ @@ -125,12 +125,12 @@ public function assign($spec) /** * Get the variable value * - * If the value has not been defined, a null value will be returned; if + * If the value has not been defined, a null value will be returned; if * strict vars on in place, a notice will also be raised. * * Otherwise, returns _escaped_ version of the value. - * - * @param mixed $key + * + * @param mixed $key * @return void */ public function offsetGet($key) @@ -156,7 +156,7 @@ public function offsetGet($key) /** * Clear all variables - * + * * @return void */ public function clear() diff --git a/src/View.php b/src/View.php index bd849445..52fe0010 100644 --- a/src/View.php +++ b/src/View.php @@ -234,8 +234,7 @@ protected function renderChildren(Model $model) if($child->isAppend()) { $oldResult=$model->{$capture}; $model->setVariable($capture, $oldResult.$result); - } - else { + } else { $model->setVariable($capture, $result); } } diff --git a/test/Helper/BasePathTest.php b/test/Helper/BasePathTest.php index 4c5ac7de..29cbd840 100644 --- a/test/Helper/BasePathTest.php +++ b/test/Helper/BasePathTest.php @@ -26,18 +26,18 @@ public function testBasePathWithoutFile() { $helper = new BasePath(); $helper->setBasePath('/foo'); - + $this->assertEquals('/foo', $helper()); } - + public function testBasePathWithFile() { $helper = new BasePath(); $helper->setBasePath('/foo'); - + $this->assertEquals('/foo/bar', $helper('bar')); } - + public function testBasePathNoDoubleSlashes() { $helper = new BasePath(); @@ -50,7 +50,7 @@ public function testBasePathWithFilePrefixedBySlash() { $helper = new BasePath(); $helper->setBasePath('/foo'); - + $this->assertEquals('/foo/bar', $helper('/bar')); } } diff --git a/test/Helper/DoctypeTest.php b/test/Helper/DoctypeTest.php index d7cc26fa..cb0e1f1e 100644 --- a/test/Helper/DoctypeTest.php +++ b/test/Helper/DoctypeTest.php @@ -163,7 +163,8 @@ public function testIsRdfa() $this->assertFalse($doctype->isRdfa()); } - public function testCanRegisterCustomHtml5Doctype() { + public function testCanRegisterCustomHtml5Doctype() + { $doctype = $this->helper->__invoke(''); $this->assertEquals('CUSTOM', $doctype->getDoctype()); $this->assertTrue($doctype->isHtml5()); diff --git a/test/Helper/EscapeCssTest.php b/test/Helper/EscapeCssTest.php index c7e06357..29014ac0 100644 --- a/test/Helper/EscapeCssTest.php +++ b/test/Helper/EscapeCssTest.php @@ -166,7 +166,7 @@ public function testCanRecurseObjectProperties() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * PHP 5.3 instates default encoding on empty string instead of the expected * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts * to guess the encoding or take it from php.ini default_charset when an empty @@ -189,7 +189,7 @@ public function testSettingValidEncodingShouldNotThrowExceptions() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * All versions of PHP - when an invalid encoding is set on htmlspecialchars() * a warning level error is issued and escaping continues with the default encoding * for that PHP version. Preventing the continuation behaviour offsets display_errors diff --git a/test/Helper/EscapeHtmlAttrTest.php b/test/Helper/EscapeHtmlAttrTest.php index 3e2e99b9..09f663f5 100644 --- a/test/Helper/EscapeHtmlAttrTest.php +++ b/test/Helper/EscapeHtmlAttrTest.php @@ -166,7 +166,7 @@ public function testCanRecurseObjectProperties() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * PHP 5.3 instates default encoding on empty string instead of the expected * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts * to guess the encoding or take it from php.ini default_charset when an empty @@ -189,7 +189,7 @@ public function testSettingValidEncodingShouldNotThrowExceptions() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * All versions of PHP - when an invalid encoding is set on htmlspecialchars() * a warning level error is issued and escaping continues with the default encoding * for that PHP version. Preventing the continuation behaviour offsets display_errors diff --git a/test/Helper/EscapeHtmlTest.php b/test/Helper/EscapeHtmlTest.php index 6bece4ff..6a81493b 100644 --- a/test/Helper/EscapeHtmlTest.php +++ b/test/Helper/EscapeHtmlTest.php @@ -163,7 +163,7 @@ public function testCanRecurseObjectProperties() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * PHP 5.3 instates default encoding on empty string instead of the expected * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts * to guess the encoding or take it from php.ini default_charset when an empty @@ -186,7 +186,7 @@ public function testSettingValidEncodingShouldNotThrowExceptions() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * All versions of PHP - when an invalid encoding is set on htmlspecialchars() * a warning level error is issued and escaping continues with the default encoding * for that PHP version. Preventing the continuation behaviour offsets display_errors diff --git a/test/Helper/EscapeJsTest.php b/test/Helper/EscapeJsTest.php index a605bfac..34c7e460 100644 --- a/test/Helper/EscapeJsTest.php +++ b/test/Helper/EscapeJsTest.php @@ -166,7 +166,7 @@ public function testCanRecurseObjectProperties() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * PHP 5.3 instates default encoding on empty string instead of the expected * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts * to guess the encoding or take it from php.ini default_charset when an empty @@ -189,7 +189,7 @@ public function testSettingValidEncodingShouldNotThrowExceptions() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * All versions of PHP - when an invalid encoding is set on htmlspecialchars() * a warning level error is issued and escaping continues with the default encoding * for that PHP version. Preventing the continuation behaviour offsets display_errors diff --git a/test/Helper/EscapeUrlTest.php b/test/Helper/EscapeUrlTest.php index ab894e70..a69ef612 100644 --- a/test/Helper/EscapeUrlTest.php +++ b/test/Helper/EscapeUrlTest.php @@ -166,7 +166,7 @@ public function testCanRecurseObjectProperties() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * PHP 5.3 instates default encoding on empty string instead of the expected * warning level error for htmlspecialchars() encoding param. PHP 5.4 attempts * to guess the encoding or take it from php.ini default_charset when an empty @@ -189,7 +189,7 @@ public function testSettingValidEncodingShouldNotThrowExceptions() /** * @expectedException \Zend\Escaper\Exception\InvalidArgumentException - * + * * All versions of PHP - when an invalid encoding is set on htmlspecialchars() * a warning level error is issued and escaping continues with the default encoding * for that PHP version. Preventing the continuation behaviour offsets display_errors diff --git a/test/Helper/Navigation/LinksTest.php b/test/Helper/Navigation/LinksTest.php index f617644c..a341bf76 100644 --- a/test/Helper/Navigation/LinksTest.php +++ b/test/Helper/Navigation/LinksTest.php @@ -716,7 +716,7 @@ public function testSetMinDepth() $this->assertEquals($expected, $actual); } - + /** * Returns the contens of the expected $file, normalizes newlines * @param string $file diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php index 5b18f07f..fb971e5a 100644 --- a/test/Helper/Navigation/MenuTest.php +++ b/test/Helper/Navigation/MenuTest.php @@ -483,7 +483,7 @@ public function testOptionOnlyActiveBranchNoParentsAndBothDepthsSpecified() $this->assertEquals($expected, $actual); } - + /** * Returns the contens of the expected $file, normalizes newlines * @param string $file diff --git a/test/Helper/Navigation/NavigationTest.php b/test/Helper/Navigation/NavigationTest.php index 6defb829..32d18884 100644 --- a/test/Helper/Navigation/NavigationTest.php +++ b/test/Helper/Navigation/NavigationTest.php @@ -53,18 +53,18 @@ public function testHelperEntryPointWithContainerParam() $this->assertEquals($this->_helper, $returned); $this->assertEquals($this->_nav2, $returned->getContainer()); } - + public function testAcceptAclShouldReturnGracefullyWithUnknownResource() { // setup $acl = $this->_getAcl(); $this->_helper->setAcl($acl['acl']); $this->_helper->setRole($acl['role']); - + $accepted = $this->_helper->accept( new \Zend\Navigation\Page\Uri(array( 'resource' => 'unknownresource', - 'privilege' => 'someprivilege' + 'privilege' => 'someprivilege' ), false) ); @@ -407,7 +407,7 @@ public function testRenderInvisibleItem() $this->assertTrue(strpos($render, 'p2') !== false); } - + /** * Returns the contens of the expected $file, normalizes newlines * @param string $file diff --git a/test/Helper/Navigation/_files/navigation.xml b/test/Helper/Navigation/_files/navigation.xml index 87bb6c1a..caed03f9 100644 --- a/test/Helper/Navigation/_files/navigation.xml +++ b/test/Helper/Navigation/_files/navigation.xml @@ -2,82 +2,82 @@ - + http://www.zym-project.com/ 100 - + page1 - + page1/page1_1 - + - + page2 - + page2/page2_1 - + page2/page2_2 - + page2/page2_2/page2_2_1 - + page2/page2_2/page2_2_2 1 - + - + page2/page2_3 - + page2/page2_3/page2_3_1 - + page2/page2_3/page2_3_2 0 - + page2/page2_3/page2_3_2/1 1 - + page2/page2_3/page2_3_2/2 1 - + @@ -86,127 +86,127 @@ - + - + page2/page2_3/page2_3_3 admin_foo - + page2/page2_3/page2_3_3/1 1 - + page2/page2_3/page2_3_3/2 guest_foo 1 - + - + - + - + page3 - + page3/page3_1 guest_foo - + page3/page3_2 member_foo - + page3/page3_2/page3_2_1 - + page3/page3_2/page3_2_2 admin_foo read - + - + page3/page3_3 special_foo - + page3/page3_3/page3_3_1 0 - + page3/page3_3/page3_3_2 admin_foo - + - + - + index Go home -100 - + - - - + + + - + site1 daily 0.9 - + site2 1 earlier - + site3 often - + - + \ No newline at end of file diff --git a/test/Helper/RenderChildModelTest.php b/test/Helper/RenderChildModelTest.php index ea008faf..97d2afdd 100644 --- a/test/Helper/RenderChildModelTest.php +++ b/test/Helper/RenderChildModelTest.php @@ -67,7 +67,7 @@ public function testRendersChildTemplateWhenAbleToResolveChildModelByCaptureToVa $result = $this->helper->render('child1'); $this->assertContains('Content for layout', $result, $result); } - + public function setupSecondChild() { $child2 = new ViewModel(); diff --git a/test/PhpRendererTest.php b/test/PhpRendererTest.php index b507914d..348e23e2 100644 --- a/test/PhpRendererTest.php +++ b/test/PhpRendererTest.php @@ -169,14 +169,14 @@ public function testCanAccessHelpersInTemplates() $this->assertContains("
  • $value
  • ", $content); } } - + /** * @group ZF2-68 */ public function testCanSpecifyArrayForVarsAndGetAlwaysArrayObject() { $vars = array('foo' => 'bar'); - $this->renderer->setVars($vars); + $this->renderer->setVars($vars); $this->assertTrue($this->renderer->vars() instanceof Variables); } @@ -252,7 +252,7 @@ public function testRenderingLocalVariables() $this->renderer->resolver()->addPath(__DIR__ . '/_templates'); $test = $this->renderer->render('testLocalVars.phtml'); $this->assertContains($expected, $test); - } + } public function testRendersTemplatesInAStack() { diff --git a/test/Strategy/FeedStrategyTest.php b/test/Strategy/FeedStrategyTest.php index a6e6f3a0..7d8cc70f 100644 --- a/test/Strategy/FeedStrategyTest.php +++ b/test/Strategy/FeedStrategyTest.php @@ -117,7 +117,7 @@ public function testMatchingRendererAndStringResultInjectsResponse() $this->assertTrue($headers->has('content-type')); $this->assertEquals('application/atom+xml', $headers->get('content-type')->getFieldValue()); } - + protected function getFeedData($type) { return array( diff --git a/test/Strategy/JsonStrategyTest.php b/test/Strategy/JsonStrategyTest.php index f2b598e2..cf2cce6b 100644 --- a/test/Strategy/JsonStrategyTest.php +++ b/test/Strategy/JsonStrategyTest.php @@ -177,7 +177,7 @@ public function testAttachesListenersAtExpectedPriorities() $this->assertTrue($found, 'Listener not found'); } } - + public function testCanAttachListenersAtSpecifiedPriority() { $events = new EventManager(); diff --git a/test/TemplatePathStackTest.php b/test/TemplatePathStackTest.php index 43af88ab..d277a0f3 100644 --- a/test/TemplatePathStackTest.php +++ b/test/TemplatePathStackTest.php @@ -225,13 +225,13 @@ public function testAllowsPassingOptionsToConstructor($arg) public function testAllowsRelativePharPath() { - $path = 'phar://' . __DIR__ - . DIRECTORY_SEPARATOR . '_templates' - . DIRECTORY_SEPARATOR . 'view.phar' - . DIRECTORY_SEPARATOR . 'start' - . DIRECTORY_SEPARATOR . '..' + $path = 'phar://' . __DIR__ + . DIRECTORY_SEPARATOR . '_templates' + . DIRECTORY_SEPARATOR . 'view.phar' + . DIRECTORY_SEPARATOR . 'start' + . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'views'; - + $this->stack->addPath($path); $test = $this->stack->resolve('foo' . DIRECTORY_SEPARATOR . 'hello.phtml'); $this->assertEquals($path . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'hello.phtml', $test); diff --git a/test/TestAsset/Invokable.php b/test/TestAsset/Invokable.php index 849d00a5..7cf64a9a 100644 --- a/test/TestAsset/Invokable.php +++ b/test/TestAsset/Invokable.php @@ -40,8 +40,8 @@ public function getView() /** * Invokable functor - * - * @param string $message + * + * @param string $message * @return string */ public function __invoke($message) From 376bf70270036f122bc9bab58e6482b9350c2453 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Wed, 11 Jul 2012 21:47:49 +0200 Subject: [PATCH 58/78] uppdate case hex escapings --- test/Helper/EscapeCssTest.php | 20 ++++++++++---------- test/Helper/EscapeHtmlAttrTest.php | 20 ++++++++++---------- test/Helper/EscapeJsTest.php | 20 ++++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/test/Helper/EscapeCssTest.php b/test/Helper/EscapeCssTest.php index dee85928..29014ac0 100644 --- a/test/Helper/EscapeCssTest.php +++ b/test/Helper/EscapeCssTest.php @@ -86,11 +86,11 @@ public function testAllowsRecursiveEscapingOfArrays() ), ); $expected = array( - 'foo' => '\3c b\3e bar\3c \2f b\3e ', + 'foo' => '\3C b\3E bar\3C \2F b\3E ', 'baz' => array( - '\3c em\3e bat\3c \2f em\3e ', + '\3C em\3E bat\3C \2F em\3E ', 'second' => array( - '\3c i\3e third\3c \2f i\3e ', + '\3C i\3E third\3C \2F i\3E ', ), ), ); @@ -103,7 +103,7 @@ public function testWillCastObjectsToStringsBeforeEscaping() $object = new TestAsset\Stringified; $test = $this->helper->__invoke($object); $this->assertEquals( - 'ZendTest\5c View\5c Helper\5c TestAsset\5c Stringified', + 'ZendTest\5C View\5C Helper\5C TestAsset\5C Stringified', $test ); } @@ -123,11 +123,11 @@ public function testCanRecurseObjectImplementingToArray() $object->array = $original; $expected = array( - 'foo' => '\3c b\3e bar\3c \2f b\3e ', + 'foo' => '\3C b\3E bar\3C \2F b\3E ', 'baz' => array( - '\3c em\3e bat\3c \2f em\3e ', + '\3C em\3E bat\3C \2F em\3E ', 'second' => array( - '\3c i\3e third\3c \2f i\3e ', + '\3C i\3E third\3C \2F i\3E ', ), ), ); @@ -152,11 +152,11 @@ public function testCanRecurseObjectProperties() } $expected = array( - 'foo' => '\3c b\3e bar\3c \2f b\3e ', + 'foo' => '\3C b\3E bar\3C \2F b\3E ', 'baz' => array( - '\3c em\3e bat\3c \2f em\3e ', + '\3C em\3E bat\3C \2F em\3E ', 'second' => array( - '\3c i\3e third\3c \2f i\3e ', + '\3C i\3E third\3C \2F i\3E ', ), ), ); diff --git a/test/Helper/EscapeHtmlAttrTest.php b/test/Helper/EscapeHtmlAttrTest.php index 045df0da..09f663f5 100644 --- a/test/Helper/EscapeHtmlAttrTest.php +++ b/test/Helper/EscapeHtmlAttrTest.php @@ -86,11 +86,11 @@ public function testAllowsRecursiveEscapingOfArrays() ), ); $expected = array( - 'foo' => '<b>bar</b>', + 'foo' => '<b>bar</b>', 'baz' => array( - '<em>bat</em>', + '<em>bat</em>', 'second' => array( - '<i>third</i>', + '<i>third</i>', ), ), ); @@ -103,7 +103,7 @@ public function testWillCastObjectsToStringsBeforeEscaping() $object = new TestAsset\Stringified; $test = $this->helper->__invoke($object); $this->assertEquals( - 'ZendTest\View\Helper\TestAsset\Stringified', + 'ZendTest\View\Helper\TestAsset\Stringified', $test ); } @@ -123,11 +123,11 @@ public function testCanRecurseObjectImplementingToArray() $object->array = $original; $expected = array( - 'foo' => '<b>bar</b>', + 'foo' => '<b>bar</b>', 'baz' => array( - '<em>bat</em>', + '<em>bat</em>', 'second' => array( - '<i>third</i>', + '<i>third</i>', ), ), ); @@ -152,11 +152,11 @@ public function testCanRecurseObjectProperties() } $expected = array( - 'foo' => '<b>bar</b>', + 'foo' => '<b>bar</b>', 'baz' => array( - '<em>bat</em>', + '<em>bat</em>', 'second' => array( - '<i>third</i>', + '<i>third</i>', ), ), ); diff --git a/test/Helper/EscapeJsTest.php b/test/Helper/EscapeJsTest.php index 90e6400b..34c7e460 100644 --- a/test/Helper/EscapeJsTest.php +++ b/test/Helper/EscapeJsTest.php @@ -86,11 +86,11 @@ public function testAllowsRecursiveEscapingOfArrays() ), ); $expected = array( - 'foo' => '\x3cb\x3ebar\x3c\x2fb\x3e', + 'foo' => '\x3Cb\x3Ebar\x3C\x2Fb\x3E', 'baz' => array( - '\x3cem\x3ebat\x3c\x2fem\x3e', + '\x3Cem\x3Ebat\x3C\x2Fem\x3E', 'second' => array( - '\x3ci\x3ethird\x3c\x2fi\x3e', + '\x3Ci\x3Ethird\x3C\x2Fi\x3E', ), ), ); @@ -103,7 +103,7 @@ public function testWillCastObjectsToStringsBeforeEscaping() $object = new TestAsset\Stringified; $test = $this->helper->__invoke($object); $this->assertEquals( - 'ZendTest\x5cView\x5cHelper\x5cTestAsset\x5cStringified', + 'ZendTest\x5CView\x5CHelper\x5CTestAsset\x5CStringified', $test ); } @@ -123,11 +123,11 @@ public function testCanRecurseObjectImplementingToArray() $object->array = $original; $expected = array( - 'foo' => '\x3cb\x3ebar\x3c\x2fb\x3e', + 'foo' => '\x3Cb\x3Ebar\x3C\x2Fb\x3E', 'baz' => array( - '\x3cem\x3ebat\x3c\x2fem\x3e', + '\x3Cem\x3Ebat\x3C\x2Fem\x3E', 'second' => array( - '\x3ci\x3ethird\x3c\x2fi\x3e', + '\x3Ci\x3Ethird\x3C\x2Fi\x3E', ), ), ); @@ -152,11 +152,11 @@ public function testCanRecurseObjectProperties() } $expected = array( - 'foo' => '\x3cb\x3ebar\x3c\x2fb\x3e', + 'foo' => '\x3Cb\x3Ebar\x3C\x2Fb\x3E', 'baz' => array( - '\x3cem\x3ebat\x3c\x2fem\x3e', + '\x3Cem\x3Ebat\x3C\x2Fem\x3E', 'second' => array( - '\x3ci\x3ethird\x3c\x2fi\x3e', + '\x3Ci\x3Ethird\x3C\x2Fi\x3E', ), ), ); From 067594d35ab46a43f8ac69c291826049bdb1c194 Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Sat, 14 Jul 2012 04:04:58 +0200 Subject: [PATCH 59/78] Fixed strategy BC break --- src/Strategy/FeedStrategy.php | 19 ++++++++----------- src/Strategy/JsonStrategy.php | 21 ++++++++++----------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/Strategy/FeedStrategy.php b/src/Strategy/FeedStrategy.php index 7cfc5c6c..b43b4fe0 100644 --- a/src/Strategy/FeedStrategy.php +++ b/src/Strategy/FeedStrategy.php @@ -100,17 +100,14 @@ public function selectRenderer(ViewEvent $e) $headers = $request->getHeaders(); if ($headers->has('accept')) { $accept = $headers->get('accept'); - foreach ($accept->getPrioritized() as $mediaType) { - if (0 === strpos($mediaType, 'application/rss+xml')) { - // application/rss+xml Accept header found - $this->renderer->setFeedType('rss'); - return $this->renderer; - } - if (0 === strpos($mediaType, 'application/atom+xml')) { - // application/atom+xml Accept header found - $this->renderer->setFeedType('atom'); - return $this->renderer; - } + if ($accept->match('application/rss+xml')) { + $this->renderer->setFeedType('rss'); + return $this->renderer; + } + + if ($accept->match('application/atom+xml')) { + $this->renderer->setFeedType('atom'); + return $this->renderer; } } diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 2a11f7d7..67fa7912 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -99,18 +99,17 @@ public function selectRenderer(ViewEvent $e) $headers = $request->getHeaders(); if ($headers->has('accept')) { $accept = $headers->get('Accept'); - foreach ($accept->getPrioritized() as $mediaType) { - if (0 === strpos($mediaType, 'application/json')) { - // application/json Accept header found - return $this->renderer; - } - if (0 === strpos($mediaType, 'application/javascript')) { - // application/javascript Accept header found - if (false != ($callback = $request->getQuery()->get('callback'))) { - $this->renderer->setJsonpCallback($callback); - } - return $this->renderer; + if ($accept->match('application/json')) { + // application/json Accept header found + return $this->renderer; + } + + if ($accept->match('application/javascript')) { + // application/javascript Accept header found + if (false != ($callback = $request->getQuery()->get('callback'))) { + $this->renderer->setJsonpCallback($callback); } + return $this->renderer; } } From 91342b184a1c08761ef4f60864db759ee67e230b Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Sat, 14 Jul 2012 04:31:34 +0200 Subject: [PATCH 60/78] CS --- src/Strategy/PhpRendererStrategy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Strategy/PhpRendererStrategy.php b/src/Strategy/PhpRendererStrategy.php index 86c0374f..95b11bf9 100644 --- a/src/Strategy/PhpRendererStrategy.php +++ b/src/Strategy/PhpRendererStrategy.php @@ -130,7 +130,7 @@ public function selectRenderer(ViewEvent $e) * Populates the content of the response object from the view rendering * results. * - * @param ViewEvent $e + * @param ViewEvent $e * @return void */ public function injectResponse(ViewEvent $e) From 7917cc40d8821cd5fe736b7ff006c0fc3e4d0771 Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Sat, 14 Jul 2012 18:50:58 +0200 Subject: [PATCH 61/78] Improved zend\view\strategy accept header matching --- src/Strategy/FeedStrategy.php | 4 ++-- src/Strategy/JsonStrategy.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Strategy/FeedStrategy.php b/src/Strategy/FeedStrategy.php index b43b4fe0..b2456862 100644 --- a/src/Strategy/FeedStrategy.php +++ b/src/Strategy/FeedStrategy.php @@ -100,12 +100,12 @@ public function selectRenderer(ViewEvent $e) $headers = $request->getHeaders(); if ($headers->has('accept')) { $accept = $headers->get('accept'); - if ($accept->match('application/rss+xml')) { + if ($accept->hasMediaType('application/rss+xml')) { $this->renderer->setFeedType('rss'); return $this->renderer; } - if ($accept->match('application/atom+xml')) { + if ($accept->hasMediaType('application/atom+xml')) { $this->renderer->setFeedType('atom'); return $this->renderer; } diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 67fa7912..0be5be68 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -99,12 +99,12 @@ public function selectRenderer(ViewEvent $e) $headers = $request->getHeaders(); if ($headers->has('accept')) { $accept = $headers->get('Accept'); - if ($accept->match('application/json')) { + if ($accept->hasMediaType('application/json')) { // application/json Accept header found return $this->renderer; } - if ($accept->match('application/javascript')) { + if ($accept->hasMediaType('application/javascript')) { // application/javascript Accept header found if (false != ($callback = $request->getQuery()->get('callback'))) { $this->renderer->setJsonpCallback($callback); From 4dc27f83ef1d3ebae04e891a7d9fad34ea322873 Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Sat, 14 Jul 2012 19:57:03 +0200 Subject: [PATCH 62/78] Fixing view strategy priorization --- src/Strategy/FeedStrategy.php | 6 ++++-- src/Strategy/JsonStrategy.php | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Strategy/FeedStrategy.php b/src/Strategy/FeedStrategy.php index b2456862..cccb2f60 100644 --- a/src/Strategy/FeedStrategy.php +++ b/src/Strategy/FeedStrategy.php @@ -100,12 +100,14 @@ public function selectRenderer(ViewEvent $e) $headers = $request->getHeaders(); if ($headers->has('accept')) { $accept = $headers->get('accept'); - if ($accept->hasMediaType('application/rss+xml')) { + + $match = $accept->match('application/rss+xml, application/atom+xml'); + if ($match && $match->getTypeString() == 'application/rss+xml') { $this->renderer->setFeedType('rss'); return $this->renderer; } - if ($accept->hasMediaType('application/atom+xml')) { + if ($match && $match->getTypeString() == 'application/atom+xml') { $this->renderer->setFeedType('atom'); return $this->renderer; } diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 0be5be68..744d1128 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -99,12 +99,15 @@ public function selectRenderer(ViewEvent $e) $headers = $request->getHeaders(); if ($headers->has('accept')) { $accept = $headers->get('Accept'); - if ($accept->hasMediaType('application/json')) { + + $match = $accept->match('application/json, application/javascript'); + + if ($match && $match->getFormat() == 'json') { // application/json Accept header found return $this->renderer; } - if ($accept->hasMediaType('application/javascript')) { + if ($match) { // application/javascript Accept header found if (false != ($callback = $request->getQuery()->get('callback'))) { $this->renderer->setJsonpCallback($callback); From 79b036aa4ad321d138660a69b2c34a92481ce38a Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Sat, 14 Jul 2012 20:03:44 +0200 Subject: [PATCH 63/78] refactoring view strategy priorization --- src/Strategy/FeedStrategy.php | 28 +++++++++++++++------------- src/Strategy/JsonStrategy.php | 32 ++++++++++++++++---------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/Strategy/FeedStrategy.php b/src/Strategy/FeedStrategy.php index cccb2f60..cca82db2 100644 --- a/src/Strategy/FeedStrategy.php +++ b/src/Strategy/FeedStrategy.php @@ -98,23 +98,25 @@ public function selectRenderer(ViewEvent $e) } $headers = $request->getHeaders(); - if ($headers->has('accept')) { - $accept = $headers->get('accept'); + if (!$headers->has('accept')) { + return; + } - $match = $accept->match('application/rss+xml, application/atom+xml'); - if ($match && $match->getTypeString() == 'application/rss+xml') { - $this->renderer->setFeedType('rss'); - return $this->renderer; - } + $accept = $headers->get('accept'); + if (($match = $accept->match('application/rss+xml, application/atom+xml')) == false) { + return; + } - if ($match && $match->getTypeString() == 'application/atom+xml') { - $this->renderer->setFeedType('atom'); - return $this->renderer; - } + if ($match->getTypeString() == 'application/rss+xml') { + $this->renderer->setFeedType('rss'); + return $this->renderer; + } + + if ($match->getTypeString() == 'application/atom+xml') { + $this->renderer->setFeedType('atom'); + return $this->renderer; } - // Not matched! - return; } /** diff --git a/src/Strategy/JsonStrategy.php b/src/Strategy/JsonStrategy.php index 744d1128..9d7c8206 100644 --- a/src/Strategy/JsonStrategy.php +++ b/src/Strategy/JsonStrategy.php @@ -97,27 +97,27 @@ public function selectRenderer(ViewEvent $e) } $headers = $request->getHeaders(); - if ($headers->has('accept')) { - $accept = $headers->get('Accept'); + if (!$headers->has('accept')) { + return; + } - $match = $accept->match('application/json, application/javascript'); - if ($match && $match->getFormat() == 'json') { - // application/json Accept header found - return $this->renderer; - } + $accept = $headers->get('Accept'); + if (($match = $accept->match('application/json, application/javascript')) == false) { + return; + } - if ($match) { - // application/javascript Accept header found - if (false != ($callback = $request->getQuery()->get('callback'))) { - $this->renderer->setJsonpCallback($callback); - } - return $this->renderer; - } + if ($match->getFormat() == 'json') { + // application/json Accept header found + return $this->renderer; + } + + // application/javascript Accept header found + if (false != ($callback = $request->getQuery()->get('callback'))) { + $this->renderer->setJsonpCallback($callback); } - // Not matched! - return; + return $this->renderer; } /** From 4a324f7f2e31060e874a3033180a8b4bf73c60bc Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Sun, 15 Jul 2012 13:14:25 +0200 Subject: [PATCH 64/78] Refactor to latest zf2 master, prepare for Console-specific bootstrapping and dispatch. - WIP, unstable! - Refactor to use ArrayUtils. - Refactor to new class and interface names after zf2 beta4. - Move all strategies from Zend\Mvc\View\* to Zend\Mvc\View\Http. This allows for separation of behavior for rendering Http content as opposed to Console content. - Request, Response and ViewManager services in SM are now created via factories, which choose Http/Console classes depending on current environment. - Console adapter and charset is now created by a SM factory. It is auto-detected by default, but can be forced to a specific class (or instantiated by custom factory) by setting config variables "console.adapter" and "console.charset". If not in an Console environment, the factory will return dummy stdClass thus preventing any potentially unsafe console operations. - Zend\View\Model\ConsoleModel errorLevel is now stored as an option, thus allowing to be set using standard methods. - Zend\Console\Console::detectBestAdapter() now properly returns an adapter, or null if not in a console env. --- src/Model/ConsoleModel.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Model/ConsoleModel.php b/src/Model/ConsoleModel.php index 481513c6..dd72cb37 100644 --- a/src/Model/ConsoleModel.php +++ b/src/Model/ConsoleModel.php @@ -41,27 +41,20 @@ class ConsoleModel extends ViewModel protected $captureTo = null; /** - * Console output should be terminal. + * Console output should always be terminal. * * @var bool */ protected $terminate = true; /** - * The error level to return after the application ends. - * - * @var int - */ - protected $errorLevel = 0; - - /** - * Set error level to return from the application. + * Set error level to return after the application ends. * * @param int $errorLevel */ public function setErrorLevel($errorLevel) { - $this->errorLevel = $errorLevel; + $this->options['errorLevel'] = $errorLevel; } /** @@ -69,6 +62,8 @@ public function setErrorLevel($errorLevel) */ public function getErrorLevel() { - return $this->errorLevel; + if(array_key_exists('errorLevel', $this->options)){ + return $this->options['errorLevel']; + } } } From e813a0fa5e856f48007c0e8441be3df83857b4a1 Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Sun, 15 Jul 2012 19:30:22 +0200 Subject: [PATCH 65/78] [WIP] Introduce Console rendering strategies and more incremental changes. - Console\Response now supports setting and getting errorLevel (stored as metadata). - Console\Response now properly supports send()ing, including exiting the application with an error level. - Add Mvc\View\Console\DefaultRenderingStrategy for building console response from plain-text action controller responses. - Currently, the default console rendering strategy does NOT use Zend\View nor Rendering to produce responses (it just concatenates plain-text responses from controllers and puts them into console response object) - Remove View\Strategy\ConsoleStrategy because of its bad design. --- src/Strategy/ConsoleStrategy.php | 141 ------------------------------- 1 file changed, 141 deletions(-) delete mode 100644 src/Strategy/ConsoleStrategy.php diff --git a/src/Strategy/ConsoleStrategy.php b/src/Strategy/ConsoleStrategy.php deleted file mode 100644 index e5ad1bf3..00000000 --- a/src/Strategy/ConsoleStrategy.php +++ /dev/null @@ -1,141 +0,0 @@ -renderer = $renderer; - $this->console = $console; - } - - /** - * Retrieve the composed renderer - * - * @return ConsoleRenderer - */ - public function getRenderer() - { - return $this->renderer; - } - - /** - * Attach the aggregate to the specified event manager - * - * @param EventCollection $events - * @param int $priority - * @return void - */ - public function attach(EventCollection $events, $priority = 1) - { - $this->listeners[] = $events->attach('renderer', array($this, 'selectRenderer'), $priority); - $this->listeners[] = $events->attach('response', array($this, 'outputToConsole'), $priority); - } - - /** - * Detach aggregate listeners from the specified event manager - * - * @param EventCollection $events - * @return void - */ - public function detach(EventCollection $events) - { - foreach ($this->listeners as $index => $listener) { - if ($events->detach($listener)) { - unset($this->listeners[$index]); - } - } - } - - /** - * Select the ConsoleRenderer; typically, this will be registered last or at - * low priority. - * - * @param ViewEvent $e - * @return ConsoleRenderer - */ - public function selectRenderer(ViewEvent $e) - { - return $this->renderer; - } - - /** - * Populate the response object from the View - * - * Populates the content of the response object from the view rendering - * results. - * - * @param ViewEvent $e - * @return void - */ - public function outputToConsole(ViewEvent $e) - { - $renderer = $e->getRenderer(); - if ($renderer !== $this->renderer) { - return; - } - - $result = $e->getResult(); - $response = $e->getResponse(); - $response->setContent($result); - - $this->console->write($result); - } -} From b55f91b921ba9b6291dd0f5dd9087eae8aaf1aeb Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Mon, 16 Jul 2012 14:52:31 +0200 Subject: [PATCH 66/78] [WIP] Fix Console view model rendering (outputing) - fix collection of textual results from view models and appending them to the final response. - remove createViewModelFromString() from previous Mvc\View\Http\CreateviewModelListener. - add View\Model\ModelInterface::getVariable() for fetching a single variable. - fix probe command result parsing in Console\Adapter\Windows. --- src/Model/ConsoleModel.php | 2 ++ src/Model/ModelInterface.php | 9 +++++++++ src/Model/ViewModel.php | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/Model/ConsoleModel.php b/src/Model/ConsoleModel.php index dd72cb37..06886baa 100644 --- a/src/Model/ConsoleModel.php +++ b/src/Model/ConsoleModel.php @@ -33,6 +33,8 @@ */ class ConsoleModel extends ViewModel { + const RESULT = 'result'; + /** * Console output doesn't support containers. * diff --git a/src/Model/ModelInterface.php b/src/Model/ModelInterface.php index a63fd279..99548c63 100644 --- a/src/Model/ModelInterface.php +++ b/src/Model/ModelInterface.php @@ -51,6 +51,15 @@ public function setOptions($options); */ public function getOptions(); + /** + * Get a single view variable + * + * @param string $name + * @param mixed|null $default (optional) default value if the variable is not present. + * @return mixed + */ + public function getVariable($name, $default = null); + /** * Set view variable * diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index 9dcff962..486435ea 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -196,6 +196,23 @@ public function getOptions() return $this->options; } + /** + * Get a single view variable + * + * @param string $name + * @param mixed|null $default (optional) default value if the variable is not present. + * @return mixed + */ + public function getVariable($name, $default = null) + { + $name = (string)$name; + if(array_key_exists($name,$this->variables)){ + return $this->variables[$name]; + }else{ + return $default; + } + } + /** * Set view variable * From d1534ec7ad768bc0c926208c6c5696f886030908 Mon Sep 17 00:00:00 2001 From: Evan Coury Date: Mon, 16 Jul 2012 09:13:07 -0700 Subject: [PATCH 67/78] s/Configuration/Config in Navigation tests --- test/Helper/Navigation/AbstractTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Helper/Navigation/AbstractTest.php b/test/Helper/Navigation/AbstractTest.php index 70906ace..ed8737c0 100644 --- a/test/Helper/Navigation/AbstractTest.php +++ b/test/Helper/Navigation/AbstractTest.php @@ -16,7 +16,7 @@ use Zend\Acl\Resource\GenericResource; use Zend\Config\Factory as ConfigFactory; use Zend\Mvc\Router\RouteMatch; -use Zend\Mvc\Service\ServiceManagerConfiguration; +use Zend\Mvc\Service\ServiceManagerConfig; use Zend\ServiceManager\ServiceManager; use Zend\I18n\Translator\Translator; use Zend\View\Renderer\PhpRenderer; @@ -114,7 +114,7 @@ protected function setUp() 'extra_config' => array( 'service_manager' => array( 'factories' => array( - 'Configuration' => function() use ($config) { + 'Config' => function() use ($config) { return array( 'navigation' => array( 'default' => $config->get('nav_test1'), @@ -127,8 +127,8 @@ protected function setUp() ), ); - $sm = $this->serviceManager = new ServiceManager(new ServiceManagerConfiguration); - $sm->setService('ApplicationConfiguration', $smConfig); + $sm = $this->serviceManager = new ServiceManager(new ServiceManagerConfig); + $sm->setService('ApplicationConfig', $smConfig); $sm->get('ModuleManager')->loadModules(); $sm->get('Application')->bootstrap(); $sm->setFactory('Navigation', 'Zend\Navigation\Service\DefaultNavigationFactory'); From 1990974f202c62886b5e29e2d836ffa1967381e9 Mon Sep 17 00:00:00 2001 From: Artur Bodera Date: Thu, 19 Jul 2012 21:46:36 +0200 Subject: [PATCH 68/78] Add console usage and banner support. - add ConsoleBanner and ConsoleUsage -ProviderInterface as a ModuleManager\Feature. - ConsoleBannerProviderInterface allows modules to return a text that described the application in console. - ConsoleUsageProviderInterface allows modules to provide detailed (localized) usage information including available commands, switches, syntax, requirements etc. - add View\Model\ViewModel::getOption() to match ::setOption() and complement ::getOptions() - add Mvc\View\Console\RouteNotFoundStrategy that shows application banner and usage info in console window in case a route cannot be found or dispatched. - fix View\Console\CreateViewModelListener to construct ConsoleModel from null and arrays (instead of standard ViewModel class) - fix View\Console\DefaultRenderingStrategy PHP notices when there was no output to display. - add View\Model\ConsoleModel::setResult() and ::getResult() as shorthands for providing and retrieving the data to output to console window. --- src/Model/ConsoleModel.php | 20 ++++++++++++++++++++ src/Model/ViewModel.php | 18 ++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Model/ConsoleModel.php b/src/Model/ConsoleModel.php index 06886baa..dd221bd6 100644 --- a/src/Model/ConsoleModel.php +++ b/src/Model/ConsoleModel.php @@ -68,4 +68,24 @@ public function getErrorLevel() return $this->options['errorLevel']; } } + + /** + * Set result text. + * + * @param string $text + * @return \Zend\View\Model\ConsoleModel + */ + public function setResult($text){ + $this->setVariable(self::RESULT, $text); + return $this; + } + + /** + * Get result text. + * + * @return mixed + */ + public function getResult(){ + return $this->getVariable(self::RESULT); + } } diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index 486435ea..309b8e84 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -148,7 +148,7 @@ public function __unset($name) } /** - * Set renderer option/hint + * Set a single option * * @param string $name * @param mixed $value @@ -160,10 +160,24 @@ public function setOption($name, $value) return $this; } + /** + * Get a single option + * + * @param string $name The option to get. + * @param mixed|null $default (optional) A default value if the option is not yet set. + * @return mixed + */ + public function getOption($name, $default = null) + { + $name = (string)$name; + return array_key_exists($name, $this->options) ? $this->options[$name] : $default; + } + /** * Set renderer options/hints en masse * - * @param array|Traversable $name + * @param array|\Traversable $options + * @throws \Zend\View\Exception\InvalidArgumentException * @return ViewModel */ public function setOptions($options) From b8be073df818567e1e348501cab9ce94f0948143 Mon Sep 17 00:00:00 2001 From: Jurian Sluiman Date: Sun, 22 Jul 2012 09:26:46 +0200 Subject: [PATCH 69/78] Expand use statements to multi-line --- src/Model/ConsoleModel.php | 4 ++-- src/Renderer/ConsoleRenderer.php | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Model/ConsoleModel.php b/src/Model/ConsoleModel.php index dd221bd6..217d3476 100644 --- a/src/Model/ConsoleModel.php +++ b/src/Model/ConsoleModel.php @@ -21,8 +21,8 @@ namespace Zend\View\Model; -use Traversable, - Zend\Stdlib\ArrayUtils; +use Traversable; +use Zend\Stdlib\ArrayUtils; /** * @category Zend diff --git a/src/Renderer/ConsoleRenderer.php b/src/Renderer/ConsoleRenderer.php index cb0c3e40..c11f042b 100644 --- a/src/Renderer/ConsoleRenderer.php +++ b/src/Renderer/ConsoleRenderer.php @@ -23,15 +23,15 @@ */ namespace Zend\View\Renderer; -use ArrayAccess, - Zend\Filter\FilterChain, - Zend\Loader\Pluggable, - Zend\View\Exception, - Zend\View\HelperBroker, - Zend\View\Model, - Zend\View\Renderer, - Zend\View\Resolver, - Zend\View\Variables; +use ArrayAccess; +use Zend\Filter\FilterChain; +use Zend\Loader\Pluggable; +use Zend\View\Exception; +use Zend\View\HelperBroker; +use Zend\View\Model; +use Zend\View\Renderer; +use Zend\View\Resolver; +use Zend\View\Variables; /** * Abstract class for Zend_View to help enforce private constructs. From 810c959dc5ba14b2aa6280be9d57ea5747f0d211 Mon Sep 17 00:00:00 2001 From: Arse Date: Sun, 22 Jul 2012 22:37:44 +0100 Subject: [PATCH 70/78] changing var names to adhere to coding standards as well --- src/Helper/PaginationControl.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Helper/PaginationControl.php b/src/Helper/PaginationControl.php index b7d0ef60..0bf6093a 100644 --- a/src/Helper/PaginationControl.php +++ b/src/Helper/PaginationControl.php @@ -25,14 +25,14 @@ class PaginationControl extends AbstractHelper * * @var string|array */ - protected static $_defaultViewPartial = null; + protected static $defaultViewPartial = null; /** * Default Scrolling Style * * @var string */ - protected static $_defaultScrollingStyle = 'sliding'; + protected static $defaultScrollingStyle = 'sliding'; /** * Sets the default view partial. @@ -41,7 +41,7 @@ class PaginationControl extends AbstractHelper */ public static function setDefaultViewPartial($partial) { - self::$_defaultViewPartial = $partial; + self::$defaultViewPartial = $partial; } /** @@ -51,9 +51,9 @@ public static function setDefaultViewPartial($partial) */ public static function getDefaultViewPartial() { - return self::$_defaultViewPartial; + return self::$defaultViewPartial; } - + /** * Gets the default scrolling style * @@ -61,7 +61,7 @@ public static function getDefaultViewPartial() */ public static function getDefaultScrollingStyle() { - return self::$_defaultScrollingStyle; + return self::$defaultScrollingStyle; } /** @@ -71,7 +71,7 @@ public static function getDefaultScrollingStyle() */ public static function setDefaultScrollingStyle($style) { - self::$_defaultScrollingStyle = $style; + self::$defaultScrollingStyle = $style; } /** @@ -98,15 +98,15 @@ public function __invoke(Paginator\Paginator $paginator = null, $scrollingStyle } if ($partial === null) { - if (self::$_defaultViewPartial === null) { + if (self::$defaultViewPartial === null) { throw new Exception\RuntimeException('No view partial provided and no default set'); } - $partial = self::$_defaultViewPartial; + $partial = self::$defaultViewPartial; } - + if ($scrollingStyle === null) { - $scrollingStyle = self::$_defaultScrollingStyle; + $scrollingStyle = self::$defaultScrollingStyle; } $pages = get_object_vars($paginator->getPages($scrollingStyle)); From b80b35b75fcc43f0b329053707b499c1612cb29c Mon Sep 17 00:00:00 2001 From: Christopher Martin Date: Sat, 14 Jul 2012 01:49:41 -0400 Subject: [PATCH 71/78] Made translator methods consistent across validators/helpers; Added tests --- src/Helper/AbstractHelper.php | 18 ++--- src/Helper/HeadTitle.php | 2 +- src/Helper/Navigation/AbstractHelper.php | 8 ++- src/Helper/Navigation/Breadcrumbs.php | 6 +- src/Helper/Navigation/HelperInterface.php | 12 ++-- src/Helper/Navigation/Menu.php | 8 ++- test/Helper/AbstractTest.php | 80 ++++++++++++++++++++++ test/Helper/HeadTitleTest.php | 2 +- test/Helper/Navigation/BreadcrumbsTest.php | 2 +- test/Helper/Navigation/MenuTest.php | 2 +- test/Helper/TestAsset/ConcreteHelper.php | 21 ++++++ 11 files changed, 134 insertions(+), 27 deletions(-) create mode 100644 test/Helper/AbstractTest.php create mode 100644 test/Helper/TestAsset/ConcreteHelper.php diff --git a/src/Helper/AbstractHelper.php b/src/Helper/AbstractHelper.php index fb480d24..a696bc29 100644 --- a/src/Helper/AbstractHelper.php +++ b/src/Helper/AbstractHelper.php @@ -47,7 +47,7 @@ abstract class AbstractHelper implements HelperInterface * * @var bool */ - protected $useTranslator = true; + protected $translatorEnabled = true; /** * Default translation object for all validate objects @@ -128,26 +128,26 @@ public function hasTranslator() } /** - * Sets whether translator should be used + * Sets whether translator is enabled and should be used * - * @param bool $useTranslator [optional] whether translator should be used. - * Default is true. + * @param bool $enabled [optional] whether translator should be used. + * Default is true. * @return AbstractHelper */ - public function setUseTranslator($useTranslator = true) + public function setTranslatorEnabled($enabled = true) { - $this->useTranslator = (bool) $useTranslator; + $this->translatorEnabled = (bool) $enabled; return $this; } /** - * Returns whether translator should be used + * Returns whether translator is enabled and should be used * * @return bool */ - public function getUseTranslator() + public function isTranslatorEnabled() { - return $this->useTranslator; + return $this->translatorEnabled; } /** diff --git a/src/Helper/HeadTitle.php b/src/Helper/HeadTitle.php index e63d9685..b6966939 100644 --- a/src/Helper/HeadTitle.php +++ b/src/Helper/HeadTitle.php @@ -109,7 +109,7 @@ public function toString($indent = null) $items = array(); - if ($this->getUseTranslator() + if ($this->isTranslatorEnabled() && null !== ($translator = $this->getTranslator()) ) { foreach ($this as $item) { diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 890f6ff9..8444faea 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -559,12 +559,14 @@ public function htmlify(AbstractPage $page) $label = $page->getLabel(); $title = $page->getTitle(); - if ($this->getUseTranslator() && $t = $this->getTranslator()) { + if ($this->isTranslatorEnabled() + && null !== ($translator = $this->getTranslator()) + ) { if (is_string($label) && !empty($label)) { - $label = $t->translate($label); + $label = $translator->translate($label); } if (is_string($title) && !empty($title)) { - $title = $t->translate($title); + $title = $translator->translate($title); } } diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php index 4b5f6a09..7d3fbaf5 100644 --- a/src/Helper/Navigation/Breadcrumbs.php +++ b/src/Helper/Navigation/Breadcrumbs.php @@ -175,8 +175,10 @@ public function renderStraight($container = null) $html = $this->htmlify($active); } else { $html = $active->getLabel(); - if ($this->getUseTranslator() && $t = $this->getTranslator()) { - $html = $t->translate($html, $this->getTranslatorTextDomain()); + if ($this->isTranslatorEnabled() + && null !== ($translator = $this->getTranslator()) + ) { + $html = $translator->translate($html, $this->getTranslatorTextDomain()); } $escaper = $this->view->plugin('escapeHtml'); $html = $escaper($html); diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index 43fd4889..edab8a69 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -125,20 +125,20 @@ public function getRenderInvisible(); public function setRenderInvisible($renderInvisible = true); /** - * Sets whether translator should be used + * Sets whether translator should be enabled and used * - * @param bool $useTranslator [optional] whether translator should be used. - * Default is true. + * @param bool $enabled [optional] whether translator should be used. + * Default is true. * @return HelperInterface fluent interface, returns self */ - public function setUseTranslator($useTranslator = true); + public function setTranslatorEnabled($enabled = true); /** - * Returns whether translator should be used + * Returns whether translator should be enabled and used * * @return bool whether translator should be used */ - public function getUseTranslator(); + public function isTranslatorEnabled(); /** * Checks if the helper has a container diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php index 517496ce..45ff5e08 100644 --- a/src/Helper/Navigation/Menu.php +++ b/src/Helper/Navigation/Menu.php @@ -194,13 +194,15 @@ public function htmlify(AbstractPage $page) $title = $page->getTitle(); // translate label and title? - if ($this->getUseTranslator() && $t = $this->getTranslator()) { + if ($this->isTranslatorEnabled() + && null !== ($translator = $this->getTranslator()) + ) { $textDomain = $this->getTranslatorTextDomain(); if (is_string($label) && !empty($label)) { - $label = $t->translate($label, $textDomain); + $label = $translator->translate($label, $textDomain); } if (is_string($title) && !empty($title)) { - $title = $t->translate($title, $textDomain); + $title = $translator->translate($title, $textDomain); } } diff --git a/test/Helper/AbstractTest.php b/test/Helper/AbstractTest.php new file mode 100644 index 00000000..7d20466d --- /dev/null +++ b/test/Helper/AbstractTest.php @@ -0,0 +1,80 @@ +helper = new ConcreteHelper(); + } + + public function tearDown() + { + AbstractHelper::setDefaultTranslator(null, 'default'); + } + + public function testViewSettersGetters() + { + $viewMock = $this->getMock('Zend\View\Renderer\RendererInterface'); + + $this->helper->setView($viewMock); + $this->assertEquals($viewMock, $this->helper->getView()); + } + + public function testTranslatorMethods() + { + $translatorMock = $this->getMock('Zend\I18n\Translator\Translator'); + $this->helper->setTranslator($translatorMock, 'foo'); + + $this->assertEquals($translatorMock, $this->helper->getTranslator()); + $this->assertEquals('foo', $this->helper->getTranslatorTextDomain()); + $this->assertTrue($this->helper->hasTranslator()); + $this->assertTrue($this->helper->isTranslatorEnabled()); + + $this->helper->setTranslatorEnabled(false); + $this->assertFalse($this->helper->isTranslatorEnabled()); + } + + public function testDefaultTranslatorMethods() + { + $this->assertFalse(AbstractHelper::hasDefaultTranslator()); + $this->assertNull(AbstractHelper::getDefaultTranslator()); + $this->assertEquals('default', AbstractHelper::getDefaultTranslatorTextDomain()); + + $this->assertFalse($this->helper->hasTranslator()); + + $translatorMock = $this->getMock('Zend\I18n\Translator\Translator'); + AbstractHelper::setDefaultTranslator($translatorMock, 'foo'); + + $this->assertEquals($translatorMock, AbstractHelper::getDefaultTranslator()); + $this->assertEquals($translatorMock, $this->helper->getTranslator()); + $this->assertEquals('foo', AbstractHelper::getDefaultTranslatorTextDomain()); + $this->assertEquals('foo', $this->helper->getTranslatorTextDomain()); + $this->assertTrue(AbstractHelper::hasDefaultTranslator()); + } +} diff --git a/test/Helper/HeadTitleTest.php b/test/Helper/HeadTitleTest.php index d8aad779..e0aff214 100644 --- a/test/Helper/HeadTitleTest.php +++ b/test/Helper/HeadTitleTest.php @@ -182,7 +182,7 @@ public function testCanTranslateTitle() $translator->getPluginManager()->setService('default', $loader); $translator->addTranslationFile('default', null); - $this->helper->enableTranslation(); + $this->helper->setTranslatorEnabled(true); $this->helper->setTranslator($translator); $this->helper->__invoke('Message_1'); $this->assertEquals('Message 1 (en)', $this->helper->toString()); diff --git a/test/Helper/Navigation/BreadcrumbsTest.php b/test/Helper/Navigation/BreadcrumbsTest.php index de2f929d..6b45eb74 100644 --- a/test/Helper/Navigation/BreadcrumbsTest.php +++ b/test/Helper/Navigation/BreadcrumbsTest.php @@ -173,7 +173,7 @@ public function testDisablingTranslation() { $translator = $this->_getTranslator(); $this->_helper->setTranslator($translator); - $this->_helper->setUseTranslator(false); + $this->_helper->setTranslatorEnabled(false); $expected = $this->_getExpected('bc/default.html'); $this->assertEquals($expected, $this->_helper->render()); diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php index fb971e5a..62c284e5 100644 --- a/test/Helper/Navigation/MenuTest.php +++ b/test/Helper/Navigation/MenuTest.php @@ -196,7 +196,7 @@ public function testDisablingTranslation() { $translator = $this->_getTranslator(); $this->_helper->setTranslator($translator); - $this->_helper->setUseTranslator(false); + $this->_helper->setTranslatorEnabled(false); $expected = $this->_getExpected('menu/default1.html'); $this->assertEquals($expected, $this->_helper->render()); diff --git a/test/Helper/TestAsset/ConcreteHelper.php b/test/Helper/TestAsset/ConcreteHelper.php new file mode 100644 index 00000000..2803224d --- /dev/null +++ b/test/Helper/TestAsset/ConcreteHelper.php @@ -0,0 +1,21 @@ + Date: Mon, 16 Jul 2012 22:51:02 -0400 Subject: [PATCH 72/78] Added initializer to the view helper and validator plugin managers; Misc clean up --- src/Helper/AbstractHelper.php | 5 ++ src/Helper/HeadTitle.php | 4 +- src/Helper/HelperInterface.php | 61 +++++++++++++++++++++++ src/Helper/Navigation.php | 4 +- src/Helper/Navigation/AbstractHelper.php | 9 ++-- src/Helper/Navigation/Breadcrumbs.php | 4 +- src/Helper/Navigation/HelperInterface.php | 18 ++++++- src/Helper/Navigation/Menu.php | 4 +- src/HelperPluginManager.php | 19 ++++++- test/TestAsset/Invokable.php | 27 +--------- test/TestAsset/Uninvokable.php | 30 ++--------- 11 files changed, 115 insertions(+), 70 deletions(-) diff --git a/src/Helper/AbstractHelper.php b/src/Helper/AbstractHelper.php index a696bc29..4b64f8d3 100644 --- a/src/Helper/AbstractHelper.php +++ b/src/Helper/AbstractHelper.php @@ -111,9 +111,14 @@ public function setTranslator(Translator $translator = null, $textDomain = null) */ public function getTranslator() { + if (! $this->isTranslatorEnabled()) { + return null; + } + if (null === $this->translator) { $this->translator = self::getDefaultTranslator(); } + return $this->translator; } diff --git a/src/Helper/HeadTitle.php b/src/Helper/HeadTitle.php index b6966939..dffaa87e 100644 --- a/src/Helper/HeadTitle.php +++ b/src/Helper/HeadTitle.php @@ -109,9 +109,7 @@ public function toString($indent = null) $items = array(); - if ($this->isTranslatorEnabled() - && null !== ($translator = $this->getTranslator()) - ) { + if (null !== ($translator = $this->getTranslator())) { foreach ($this as $item) { $items[] = $translator->translate( $item, $this->getTranslatorTextDomain() diff --git a/src/Helper/HelperInterface.php b/src/Helper/HelperInterface.php index 4c341a02..445fcdfa 100644 --- a/src/Helper/HelperInterface.php +++ b/src/Helper/HelperInterface.php @@ -10,6 +10,7 @@ namespace Zend\View\Helper; +use Zend\I18n\Translator\Translator; use Zend\View\Renderer\RendererInterface as Renderer; /** @@ -33,4 +34,64 @@ public function setView(Renderer $view); * @return Renderer */ public function getView(); + + /** + * Sets translator to use in helper + * + * Implements {@link HelperInterface::setTranslator()}. + * + * @param mixed $translator [optional] translator. Expects an object of + * type {@link Translator\Adapter\AbstractAdapter} + * or {@link Translator\Translator}, or null. + * Default is null, which sets no translator. + * @param string $textDomain + * @return AbstractHelper + */ + public function setTranslator(Translator $translator, $textDomain); + + /** + * Returns translator used in helper + * + * @return Translator|null + */ + public function getTranslator(); + + /** + * Checks if the helper has a translator + * + * @return bool + */ + public function hasTranslator(); + + /** + * Sets whether translator is enabled and should be used + * + * @param bool $enabled [optional] whether translator should be used. + * Default is true. + * @return AbstractHelper + */ + public function setTranslatorEnabled($enabled); + + /** + * Returns whether translator is enabled and should be used + * + * @return bool + */ + public function isTranslatorEnabled(); + + /** + * Set translation text domain + * + * @param string $textDomain + * @return AbstractValidator + */ + public function setTranslatorTextDomain($textDomain); + + /** + * Return the translation text domain + * + * @return string + */ + public function getTranslatorTextDomain(); + } diff --git a/src/Helper/Navigation.php b/src/Helper/Navigation.php index 8e92d477..00bb9ba5 100644 --- a/src/Helper/Navigation.php +++ b/src/Helper/Navigation.php @@ -223,7 +223,9 @@ protected function _inject(NavigationHelper $helper) } if ($this->getInjectTranslator() && !$helper->hasTranslator()) { - $helper->setTranslator($this->getTranslator()); + $helper->setTranslator( + $this->getTranslator(), $this->getTranslatorTextDomain() + ); } } diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 8444faea..5020c894 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -559,14 +559,13 @@ public function htmlify(AbstractPage $page) $label = $page->getLabel(); $title = $page->getTitle(); - if ($this->isTranslatorEnabled() - && null !== ($translator = $this->getTranslator()) - ) { + if (null !== ($translator = $this->getTranslator())) { + $textDomain = $this->getTranslatorTextDomain(); if (is_string($label) && !empty($label)) { - $label = $translator->translate($label); + $label = $translator->translate($label, $textDomain); } if (is_string($title) && !empty($title)) { - $title = $translator->translate($title); + $title = $translator->translate($title, $textDomain); } } diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php index 7d3fbaf5..39f0c580 100644 --- a/src/Helper/Navigation/Breadcrumbs.php +++ b/src/Helper/Navigation/Breadcrumbs.php @@ -175,9 +175,7 @@ public function renderStraight($container = null) $html = $this->htmlify($active); } else { $html = $active->getLabel(); - if ($this->isTranslatorEnabled() - && null !== ($translator = $this->getTranslator()) - ) { + if (null !== ($translator = $this->getTranslator())) { $html = $translator->translate($html, $this->getTranslatorTextDomain()); } $escaper = $this->view->plugin('escapeHtml'); diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index edab8a69..be46d732 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -48,9 +48,10 @@ public function getContainer(); * type {@link \Zend\Translator\Adapter} or * {@link \Zend\Translator\Translator}, or null. * Default is null. + * @param string $textDomain * @return HelperInterface fluent interface, returns self */ - public function setTranslator(Translator $translator = null); + public function setTranslator(Translator $translator = null, $textDomain = null); /** * Returns translator used in helper @@ -59,6 +60,21 @@ public function setTranslator(Translator $translator = null); */ public function getTranslator(); + /** + * Set translation text domain + * + * @param string $textDomain + * @return HelperInterface + */ + public function setTranslatorTextDomain($textDomain); + + /** + * Return the translation text domain + * + * @return string + */ + public function getTranslatorTextDomain(); + /** * Sets ACL to use when iterating pages * diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php index 45ff5e08..372287af 100644 --- a/src/Helper/Navigation/Menu.php +++ b/src/Helper/Navigation/Menu.php @@ -194,9 +194,7 @@ public function htmlify(AbstractPage $page) $title = $page->getTitle(); // translate label and title? - if ($this->isTranslatorEnabled() - && null !== ($translator = $this->getTranslator()) - ) { + if (null !== ($translator = $this->getTranslator())) { $textDomain = $this->getTranslatorTextDomain(); if (is_string($label) && !empty($label)) { $label = $translator->translate($label, $textDomain); diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 541e98b8..171786fa 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -78,7 +78,7 @@ class HelperPluginManager extends AbstractPluginManager * Constructor * * After invoking parent constructor, add an initializer to inject the - * attached renderer, if any, to the currently requested helper. + * attached renderer and translator, if any, to the currently requested helper. * * @param null|ConfigurationInterface $configuration * @return void @@ -86,7 +86,8 @@ class HelperPluginManager extends AbstractPluginManager public function __construct(ConfigurationInterface $configuration = null) { parent::__construct($configuration); - $this->addInitializer(array($this, 'injectRenderer')); + $this->addInitializer(array($this, 'injectRenderer')) + ->addInitializer(array($this, 'injectTranslator')); } /** @@ -126,6 +127,20 @@ public function injectRenderer($helper) $helper->setView($renderer); } + /** + * Inject a helper instance with the registered translator + * + * @param Helper\HelperInterface $helper + * @return void + */ + public function injectTranslator($helper) + { + $locator = $this->getServiceLocator(); + if ($locator && $locator->has('translator')) { + $helper->setTranslator($locator->get('translator')); + } + } + /** * Validate the plugin * diff --git a/test/TestAsset/Invokable.php b/test/TestAsset/Invokable.php index 7cf64a9a..3c8aa72d 100644 --- a/test/TestAsset/Invokable.php +++ b/test/TestAsset/Invokable.php @@ -11,33 +11,10 @@ namespace ZendTest\View\TestAsset; use Zend\View\Renderer\RendererInterface as Renderer; -use Zend\View\Helper\HelperInterface as Helper; +use Zend\View\Helper\AbstractHelper as Helper; -class Invokable implements Helper +class Invokable extends Helper { - protected $view; - - /** - * Set the View object - * - * @param Renderer $view - * @return Helper - */ - public function setView(Renderer $view) - { - $this->view = $view; - } - - /** - * Get the View object - * - * @return Renderer - */ - public function getView() - { - return $this->view; - } - /** * Invokable functor * diff --git a/test/TestAsset/Uninvokable.php b/test/TestAsset/Uninvokable.php index 040a1e68..3dbfbf6d 100644 --- a/test/TestAsset/Uninvokable.php +++ b/test/TestAsset/Uninvokable.php @@ -11,31 +11,7 @@ namespace ZendTest\View\TestAsset; use Zend\View\Renderer\RendererInterface as Renderer; -use Zend\View\Helper\HelperInterface as Helper; +use Zend\View\Helper\AbstractHelper as Helper; -class Uninvokable implements Helper -{ - protected $view; - - /** - * Set the View object - * - * @param Renderer $view - * @return Uninvokable - */ - public function setView(Renderer $view) - { - $this->view = $view; - return $this; - } - - /** - * Get the View object - * - * @return Renderer - */ - public function getView() - { - return $this->view; - } -} +class Uninvokable extends Helper +{ } From a65f6fe35803801e9bd281bcfecd5f9d3f539eac Mon Sep 17 00:00:00 2001 From: Christopher Martin Date: Mon, 16 Jul 2012 23:16:57 -0400 Subject: [PATCH 73/78] Fix broken build interface inheritance in php 5.3.3 --- src/Helper/Navigation/HelperInterface.php | 60 +---------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php index be46d732..ce65e6f8 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -13,6 +13,7 @@ use Zend\Acl; use Zend\I18n\Translator\Translator; use Zend\Navigation; +use Zend\View\Helper\HelperInterface as BaseHelperInterface; /** * Interface for navigational helpers @@ -21,7 +22,7 @@ * @package Zend_View * @subpackage Helper */ -interface HelperInterface +interface HelperInterface extends BaseHelperInterface { /** * Sets navigation container the helper should operate on by default @@ -41,40 +42,6 @@ public function setContainer($container = null); */ public function getContainer(); - /** - * Sets translator to use in helper - * - * @param mixed $translator [optional] translator. Expects an object of - * type {@link \Zend\Translator\Adapter} or - * {@link \Zend\Translator\Translator}, or null. - * Default is null. - * @param string $textDomain - * @return HelperInterface fluent interface, returns self - */ - public function setTranslator(Translator $translator = null, $textDomain = null); - - /** - * Returns translator used in helper - * - * @return \Zend\Translator\Adapter|null translator or null - */ - public function getTranslator(); - - /** - * Set translation text domain - * - * @param string $textDomain - * @return HelperInterface - */ - public function setTranslatorTextDomain($textDomain); - - /** - * Return the translation text domain - * - * @return string - */ - public function getTranslatorTextDomain(); - /** * Sets ACL to use when iterating pages * @@ -140,22 +107,6 @@ public function getRenderInvisible(); */ public function setRenderInvisible($renderInvisible = true); - /** - * Sets whether translator should be enabled and used - * - * @param bool $enabled [optional] whether translator should be used. - * Default is true. - * @return HelperInterface fluent interface, returns self - */ - public function setTranslatorEnabled($enabled = true); - - /** - * Returns whether translator should be enabled and used - * - * @return bool whether translator should be used - */ - public function isTranslatorEnabled(); - /** * Checks if the helper has a container * @@ -177,13 +128,6 @@ public function hasAcl(); */ public function hasRole(); - /** - * Checks if the helper has a translator - * - * @return bool whether the helper has a translator or not - */ - public function hasTranslator(); - /** * Magic overload: Should proxy to {@link render()}. * From 77d7d32f58030095c6f81a35f98048e7dc491cd1 Mon Sep 17 00:00:00 2001 From: Christopher Martin Date: Sat, 21 Jul 2012 00:11:18 -0400 Subject: [PATCH 74/78] 2nd refactor of translator methods, added a TranslatorAwareInterface --- src/Helper/AbstractHelper.php | 190 ---------------------- src/Helper/HeadTitle.php | 120 +++++++++++++- src/Helper/HelperInterface.php | 60 ------- src/Helper/Navigation/AbstractHelper.php | 118 +++++++++++++- src/HelperPluginManager.php | 9 +- test/Helper/AbstractTest.php | 37 ----- test/Helper/HeadTitleTest.php | 20 ++- test/Helper/Navigation/NavigationTest.php | 14 ++ 8 files changed, 270 insertions(+), 298 deletions(-) diff --git a/src/Helper/AbstractHelper.php b/src/Helper/AbstractHelper.php index 4b64f8d3..1ced3587 100644 --- a/src/Helper/AbstractHelper.php +++ b/src/Helper/AbstractHelper.php @@ -10,7 +10,6 @@ namespace Zend\View\Helper; -use Zend\I18n\Translator\Translator; use Zend\View\Helper\HelperInterface; use Zend\View\Renderer\RendererInterface as Renderer; @@ -28,39 +27,6 @@ abstract class AbstractHelper implements HelperInterface */ protected $view = null; - /** - * Translator (optional) - * - * @var Translator - */ - protected $translator; - - /** - * Translator text domain (optional) - * - * @var string - */ - protected $translatorTextDomain; - - /** - * Whether translator should be used - * - * @var bool - */ - protected $translatorEnabled = true; - - /** - * Default translation object for all validate objects - * @var Translator - */ - protected static $defaultTranslator; - - /** - * Default text domain to be used with translator - * @var string - */ - protected static $defaultTranslatorTextDomain = 'default'; - /** * Set the View object * @@ -82,160 +48,4 @@ public function getView() { return $this->view; } - - /** - * Sets translator to use in helper - * - * Implements {@link HelperInterface::setTranslator()}. - * - * @param mixed $translator [optional] translator. Expects an object of - * type {@link Translator\Adapter\AbstractAdapter} - * or {@link Translator\Translator}, or null. - * Default is null, which sets no translator. - * @param string $textDomain - * @return AbstractHelper - */ - public function setTranslator(Translator $translator = null, $textDomain = null) - { - $this->translator = $translator; - if (null !== $textDomain) { - $this->setTranslatorTextDomain($textDomain); - } - return $this; - } - - /** - * Returns translator used in helper - * - * @return Translator|null - */ - public function getTranslator() - { - if (! $this->isTranslatorEnabled()) { - return null; - } - - if (null === $this->translator) { - $this->translator = self::getDefaultTranslator(); - } - - return $this->translator; - } - - /** - * Checks if the helper has a translator - * - * @return bool - */ - public function hasTranslator() - { - return (bool) $this->getTranslator(); - } - - /** - * Sets whether translator is enabled and should be used - * - * @param bool $enabled [optional] whether translator should be used. - * Default is true. - * @return AbstractHelper - */ - public function setTranslatorEnabled($enabled = true) - { - $this->translatorEnabled = (bool) $enabled; - return $this; - } - - /** - * Returns whether translator is enabled and should be used - * - * @return bool - */ - public function isTranslatorEnabled() - { - return $this->translatorEnabled; - } - - /** - * Set translation text domain - * - * @param string $textDomain - * @return AbstractValidator - */ - public function setTranslatorTextDomain($textDomain = 'default') - { - $this->translatorTextDomain = $textDomain; - return $this; - } - - /** - * Return the translation text domain - * - * @return string - */ - public function getTranslatorTextDomain() - { - if (null === $this->translatorTextDomain) { - $this->translatorTextDomain = self::getDefaultTranslatorTextDomain(); - } - return $this->translatorTextDomain; - } - - /** - * Set default translation object for all validate objects - * - * @param Translator|null $translator - * @param string $textDomain (optional) - * @return void - * @throws Exception\InvalidArgumentException - */ - public static function setDefaultTranslator( - Translator $translator = null, $textDomain = null - ) { - self::$defaultTranslator = $translator; - if (null !== $textDomain) { - self::setDefaultTranslatorTextDomain($textDomain); - } - } - - /** - * Get default translation object for all validate objects - * - * @return Translator|null - */ - public static function getDefaultTranslator() - { - return self::$defaultTranslator; - } - - /** - * Is there a default translation object set? - * - * @return boolean - */ - public static function hasDefaultTranslator() - { - return (bool) self::$defaultTranslator; - } - - /** - * Set default translation text domain for all validate objects - * - * @param string $textDomain - * @return void - */ - public static function setDefaultTranslatorTextDomain($textDomain = 'default') - { - self::$defaultTranslatorTextDomain = $textDomain; - } - - /** - * Get default translation text domain for all validate objects - * - * @return string - */ - public static function getDefaultTranslatorTextDomain() - { - return self::$defaultTranslatorTextDomain; - } - } diff --git a/src/Helper/HeadTitle.php b/src/Helper/HeadTitle.php index dffaa87e..ceab1b4a 100644 --- a/src/Helper/HeadTitle.php +++ b/src/Helper/HeadTitle.php @@ -10,6 +10,8 @@ namespace Zend\View\Helper; +use Zend\I18n\Translator\Translator; +use Zend\I18n\Translator\TranslatorAwareInterface; use Zend\View\Exception; /** @@ -18,7 +20,9 @@ * @package Zend_View * @subpackage Helper */ -class HeadTitle extends Placeholder\Container\AbstractStandalone +class HeadTitle + extends Placeholder\Container\AbstractStandalone + implements TranslatorAwareInterface { /** * Registry key for placeholder @@ -33,6 +37,27 @@ class HeadTitle extends Placeholder\Container\AbstractStandalone */ protected $_defaultAttachOrder = null; + /** + * Translator (optional) + * + * @var Translator + */ + protected $translator; + + /** + * Translator text domain (optional) + * + * @var string + */ + protected $translatorTextDomain = 'default'; + + /** + * Whether translator should be used + * + * @var bool + */ + protected $translatorEnabled = true; + /** * Retrieve placeholder for title element and optionally set state * @@ -125,14 +150,14 @@ public function toString($indent = null) $output = ''; $prefix = $this->getPrefix(); - if($prefix) { + if ($prefix) { $output .= $prefix; } $output .= implode($separator, $items); $postfix = $this->getPostfix(); - if($postfix) { + if ($postfix) { $output .= $postfix; } @@ -140,4 +165,93 @@ public function toString($indent = null) return $indent . '' . $output . ''; } + + // Translator methods - Good candidate to refactor as a trait with PHP 5.4 + + /** + * Sets translator to use in helper + * + * @param Translator $translator [optional] translator. + * Default is null, which sets no translator. + * @param string $textDomain [optional] text domain + * Default is null, which skips setTranslatorTextDomain + * @return HeadTitle + */ + public function setTranslator(Translator $translator = null, $textDomain = null) + { + $this->translator = $translator; + if (null !== $textDomain) { + $this->setTranslatorTextDomain($textDomain); + } + return $this; + } + + /** + * Returns translator used in helper + * + * @return Translator|null + */ + public function getTranslator() + { + if (! $this->isTranslatorEnabled()) { + return null; + } + + return $this->translator; + } + + /** + * Checks if the helper has a translator + * + * @return bool + */ + public function hasTranslator() + { + return (bool) $this->getTranslator(); + } + + /** + * Sets whether translator is enabled and should be used + * + * @param bool $enabled [optional] whether translator should be used. + * Default is true. + * @return HeadTitle + */ + public function setTranslatorEnabled($enabled = true) + { + $this->translatorEnabled = (bool) $enabled; + return $this; + } + + /** + * Returns whether translator is enabled and should be used + * + * @return bool + */ + public function isTranslatorEnabled() + { + return $this->translatorEnabled; + } + + /** + * Set translation text domain + * + * @param string $textDomain + * @return HeadTitle + */ + public function setTranslatorTextDomain($textDomain = 'default') + { + $this->translatorTextDomain = $textDomain; + return $this; + } + + /** + * Return the translation text domain + * + * @return string + */ + public function getTranslatorTextDomain() + { + return $this->translatorTextDomain; + } } diff --git a/src/Helper/HelperInterface.php b/src/Helper/HelperInterface.php index 445fcdfa..1c3909be 100644 --- a/src/Helper/HelperInterface.php +++ b/src/Helper/HelperInterface.php @@ -10,7 +10,6 @@ namespace Zend\View\Helper; -use Zend\I18n\Translator\Translator; use Zend\View\Renderer\RendererInterface as Renderer; /** @@ -35,63 +34,4 @@ public function setView(Renderer $view); */ public function getView(); - /** - * Sets translator to use in helper - * - * Implements {@link HelperInterface::setTranslator()}. - * - * @param mixed $translator [optional] translator. Expects an object of - * type {@link Translator\Adapter\AbstractAdapter} - * or {@link Translator\Translator}, or null. - * Default is null, which sets no translator. - * @param string $textDomain - * @return AbstractHelper - */ - public function setTranslator(Translator $translator, $textDomain); - - /** - * Returns translator used in helper - * - * @return Translator|null - */ - public function getTranslator(); - - /** - * Checks if the helper has a translator - * - * @return bool - */ - public function hasTranslator(); - - /** - * Sets whether translator is enabled and should be used - * - * @param bool $enabled [optional] whether translator should be used. - * Default is true. - * @return AbstractHelper - */ - public function setTranslatorEnabled($enabled); - - /** - * Returns whether translator is enabled and should be used - * - * @return bool - */ - public function isTranslatorEnabled(); - - /** - * Set translation text domain - * - * @param string $textDomain - * @return AbstractValidator - */ - public function setTranslatorTextDomain($textDomain); - - /** - * Return the translation text domain - * - * @return string - */ - public function getTranslatorTextDomain(); - } diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 5020c894..7537ffb9 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -12,6 +12,8 @@ use RecursiveIteratorIterator; use Zend\Acl; +use Zend\I18n\Translator\Translator; +use Zend\I18n\Translator\TranslatorAwareInterface; use Zend\Navigation; use Zend\Navigation\Page\AbstractPage; use Zend\ServiceManager\ServiceLocatorAwareInterface; @@ -29,7 +31,8 @@ abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements HelperInterface, - ServiceLocatorAwareInterface + ServiceLocatorAwareInterface, + TranslatorAwareInterface { /** * @var ServiceLocatorInterface @@ -92,6 +95,27 @@ abstract class AbstractHelper */ protected $useAcl = true; + /** + * Translator (optional) + * + * @var Translator + */ + protected $translator; + + /** + * Translator text domain (optional) + * + * @var string + */ + protected $translatorTextDomain = 'default'; + + /** + * Whether translator should be used + * + * @var bool + */ + protected $translatorEnabled = true; + /** * Default ACL to use when iterating pages if not explicitly set in the * instance by calling {@link setAcl()} @@ -135,7 +159,8 @@ public function getServiceLocator() * * Implements {@link HelperInterface::setContainer()}. * - * @param string|Navigation\AbstractContainer $container [optional] container to operate on. Default is null, meaning container will be reset. + * @param string|Navigation\AbstractContainer $container [optional] container to operate on. + * Default is null, meaning container will be reset. * @return AbstractHelper fluent interface, returns self */ public function setContainer($container = null) @@ -585,6 +610,95 @@ public function htmlify(AbstractPage $page) . ''; } + // Translator methods - Good candidate to refactor as a trait with PHP 5.4 + + /** + * Sets translator to use in helper + * + * @param Translator $translator [optional] translator. + * Default is null, which sets no translator. + * @param string $textDomain [optional] text domain + * Default is null, which skips setTranslatorTextDomain + * @return AbstractHelper + */ + public function setTranslator(Translator $translator = null, $textDomain = null) + { + $this->translator = $translator; + if (null !== $textDomain) { + $this->setTranslatorTextDomain($textDomain); + } + return $this; + } + + /** + * Returns translator used in helper + * + * @return Translator|null + */ + public function getTranslator() + { + if (! $this->isTranslatorEnabled()) { + return null; + } + + return $this->translator; + } + + /** + * Checks if the helper has a translator + * + * @return bool + */ + public function hasTranslator() + { + return (bool) $this->getTranslator(); + } + + /** + * Sets whether translator is enabled and should be used + * + * @param bool $enabled [optional] whether translator should be used. + * Default is true. + * @return AbstractHelper + */ + public function setTranslatorEnabled($enabled = true) + { + $this->translatorEnabled = (bool) $enabled; + return $this; + } + + /** + * Returns whether translator is enabled and should be used + * + * @return bool + */ + public function isTranslatorEnabled() + { + return $this->translatorEnabled; + } + + /** + * Set translation text domain + * + * @param string $textDomain + * @return AbstractHelper + */ + public function setTranslatorTextDomain($textDomain = 'default') + { + $this->translatorTextDomain = $textDomain; + return $this; + } + + /** + * Return the translation text domain + * + * @return string + */ + public function getTranslatorTextDomain() + { + return $this->translatorTextDomain; + } + // Iterator filter methods: /** diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 171786fa..76011330 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -10,6 +10,7 @@ namespace Zend\View; +use Zend\I18n\Translator\TranslatorAwareInterface; use Zend\ServiceManager\AbstractPluginManager; use Zend\ServiceManager\ConfigurationInterface; @@ -135,9 +136,11 @@ public function injectRenderer($helper) */ public function injectTranslator($helper) { - $locator = $this->getServiceLocator(); - if ($locator && $locator->has('translator')) { - $helper->setTranslator($locator->get('translator')); + if ($helper instanceof TranslatorAwareInterface) { + $locator = $this->getServiceLocator(); + if ($locator && $locator->has('translator')) { + $helper->setTranslator($locator->get('translator')); + } } } diff --git a/test/Helper/AbstractTest.php b/test/Helper/AbstractTest.php index 7d20466d..858370e6 100644 --- a/test/Helper/AbstractTest.php +++ b/test/Helper/AbstractTest.php @@ -33,11 +33,6 @@ public function setUp() $this->helper = new ConcreteHelper(); } - public function tearDown() - { - AbstractHelper::setDefaultTranslator(null, 'default'); - } - public function testViewSettersGetters() { $viewMock = $this->getMock('Zend\View\Renderer\RendererInterface'); @@ -45,36 +40,4 @@ public function testViewSettersGetters() $this->helper->setView($viewMock); $this->assertEquals($viewMock, $this->helper->getView()); } - - public function testTranslatorMethods() - { - $translatorMock = $this->getMock('Zend\I18n\Translator\Translator'); - $this->helper->setTranslator($translatorMock, 'foo'); - - $this->assertEquals($translatorMock, $this->helper->getTranslator()); - $this->assertEquals('foo', $this->helper->getTranslatorTextDomain()); - $this->assertTrue($this->helper->hasTranslator()); - $this->assertTrue($this->helper->isTranslatorEnabled()); - - $this->helper->setTranslatorEnabled(false); - $this->assertFalse($this->helper->isTranslatorEnabled()); - } - - public function testDefaultTranslatorMethods() - { - $this->assertFalse(AbstractHelper::hasDefaultTranslator()); - $this->assertNull(AbstractHelper::getDefaultTranslator()); - $this->assertEquals('default', AbstractHelper::getDefaultTranslatorTextDomain()); - - $this->assertFalse($this->helper->hasTranslator()); - - $translatorMock = $this->getMock('Zend\I18n\Translator\Translator'); - AbstractHelper::setDefaultTranslator($translatorMock, 'foo'); - - $this->assertEquals($translatorMock, AbstractHelper::getDefaultTranslator()); - $this->assertEquals($translatorMock, $this->helper->getTranslator()); - $this->assertEquals('foo', AbstractHelper::getDefaultTranslatorTextDomain()); - $this->assertEquals('foo', $this->helper->getTranslatorTextDomain()); - $this->assertTrue(AbstractHelper::hasDefaultTranslator()); - } } diff --git a/test/Helper/HeadTitleTest.php b/test/Helper/HeadTitleTest.php index e0aff214..e62dd9cf 100644 --- a/test/Helper/HeadTitleTest.php +++ b/test/Helper/HeadTitleTest.php @@ -188,9 +188,23 @@ public function testCanTranslateTitle() $this->assertEquals('Message 1 (en)', $this->helper->toString()); } - /** - * @group ZF-8036 - */ + public function testTranslatorMethods() + { + $translatorMock = $this->getMock('Zend\I18n\Translator\Translator'); + $this->helper->setTranslator($translatorMock, 'foo'); + + $this->assertEquals($translatorMock, $this->helper->getTranslator()); + $this->assertEquals('foo', $this->helper->getTranslatorTextDomain()); + $this->assertTrue($this->helper->hasTranslator()); + $this->assertTrue($this->helper->isTranslatorEnabled()); + + $this->helper->setTranslatorEnabled(false); + $this->assertFalse($this->helper->isTranslatorEnabled()); + } + + /** + * @group ZF-8036 + */ public function testHeadTitleZero() { $this->helper->__invoke('0'); diff --git a/test/Helper/Navigation/NavigationTest.php b/test/Helper/Navigation/NavigationTest.php index 32d18884..c1bf9361 100644 --- a/test/Helper/Navigation/NavigationTest.php +++ b/test/Helper/Navigation/NavigationTest.php @@ -178,6 +178,20 @@ public function testDisablingTranslatorInjection() $this->assertEquals($expected, $actual); } + public function testTranslatorMethods() + { + $translatorMock = $this->getMock('Zend\I18n\Translator\Translator'); + $this->_helper->setTranslator($translatorMock, 'foo'); + + $this->assertEquals($translatorMock, $this->_helper->getTranslator()); + $this->assertEquals('foo', $this->_helper->getTranslatorTextDomain()); + $this->assertTrue($this->_helper->hasTranslator()); + $this->assertTrue($this->_helper->isTranslatorEnabled()); + + $this->_helper->setTranslatorEnabled(false); + $this->assertFalse($this->_helper->isTranslatorEnabled()); + } + public function testSpecifyingDefaultProxy() { $expected = array( From a19a78a54a895b445d1199e34b8ca57ddcc77e60 Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Mon, 23 Jul 2012 14:23:17 -0400 Subject: [PATCH 75/78] Fix for PluginManagers to use ConfigInterface --- src/HelperPluginManager.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php index 76011330..4343f135 100644 --- a/src/HelperPluginManager.php +++ b/src/HelperPluginManager.php @@ -12,7 +12,7 @@ use Zend\I18n\Translator\TranslatorAwareInterface; use Zend\ServiceManager\AbstractPluginManager; -use Zend\ServiceManager\ConfigurationInterface; +use Zend\ServiceManager\ConfigInterface; /** * Plugin manager implementation for view helpers @@ -81,10 +81,10 @@ class HelperPluginManager extends AbstractPluginManager * After invoking parent constructor, add an initializer to inject the * attached renderer and translator, if any, to the currently requested helper. * - * @param null|ConfigurationInterface $configuration + * @param null|ConfigInterface $configuration * @return void */ - public function __construct(ConfigurationInterface $configuration = null) + public function __construct(ConfigInterface $configuration = null) { parent::__construct($configuration); $this->addInitializer(array($this, 'injectRenderer')) From 5d2770e9d126e816247759e77a8f9d004c720391 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 23 Jul 2012 14:42:11 -0500 Subject: [PATCH 76/78] [zendframework/zf2#1890] CS fixes - interfaces are only part of class declaration that should go on separate line - one interface per line --- src/Helper/HeadTitle.php | 5 ++--- src/Helper/Navigation/AbstractHelper.php | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Helper/HeadTitle.php b/src/Helper/HeadTitle.php index ceab1b4a..45a235fe 100644 --- a/src/Helper/HeadTitle.php +++ b/src/Helper/HeadTitle.php @@ -20,9 +20,8 @@ * @package Zend_View * @subpackage Helper */ -class HeadTitle - extends Placeholder\Container\AbstractStandalone - implements TranslatorAwareInterface +class HeadTitle extends Placeholder\Container\AbstractStandalone implements + TranslatorAwareInterface { /** * Registry key for placeholder diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 7537ffb9..3ea354c6 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -28,11 +28,10 @@ * @package Zend_View * @subpackage Helper */ -abstract class AbstractHelper - extends View\Helper\AbstractHtmlElement - implements HelperInterface, - ServiceLocatorAwareInterface, - TranslatorAwareInterface +abstract class AbstractHelper extends View\Helper\AbstractHtmlElement implements + HelperInterface, + ServiceLocatorAwareInterface, + TranslatorAwareInterface { /** * @var ServiceLocatorInterface From 1fb0425ea507d49a34484f7fc09f52d85b3142a5 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 24 Jul 2012 14:15:45 -0500 Subject: [PATCH 77/78] Updated all classes depending on Zend\Acl to use Zend\Permissions\Acl - Navigation and navigation view helpers --- src/Helper/Navigation/AbstractHelper.php | 2 +- src/Helper/Navigation/HelperInterface.php | 2 +- test/Helper/Navigation/AbstractTest.php | 6 +++--- test/Helper/Navigation/LinksTest.php | 8 ++++---- test/Helper/Navigation/MenuTest.php | 2 +- test/Helper/Navigation/NavigationTest.php | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php index 3ea354c6..d8e74870 100644 --- a/src/Helper/Navigation/AbstractHelper.php +++ b/src/Helper/Navigation/AbstractHelper.php @@ -11,11 +11,11 @@ namespace Zend\View\Helper\Navigation; use RecursiveIteratorIterator; -use Zend\Acl; use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\TranslatorAwareInterface; use Zend\Navigation; use Zend\Navigation\Page\AbstractPage; +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 ce65e6f8..0dc134d5 100644 --- a/src/Helper/Navigation/HelperInterface.php +++ b/src/Helper/Navigation/HelperInterface.php @@ -10,9 +10,9 @@ namespace Zend\View\Helper\Navigation; -use Zend\Acl; use Zend\I18n\Translator\Translator; use Zend\Navigation; +use Zend\Permissions\Acl; use Zend\View\Helper\HelperInterface as BaseHelperInterface; /** diff --git a/test/Helper/Navigation/AbstractTest.php b/test/Helper/Navigation/AbstractTest.php index e9afe020..10973362 100644 --- a/test/Helper/Navigation/AbstractTest.php +++ b/test/Helper/Navigation/AbstractTest.php @@ -11,12 +11,12 @@ namespace ZendTest\View\Helper\Navigation; use Zend\Navigation\Navigation; -use Zend\Acl\Acl; -use Zend\Acl\Role\GenericRole; -use Zend\Acl\Resource\GenericResource; use Zend\Config\Factory as ConfigFactory; use Zend\Mvc\Router\RouteMatch; use Zend\Mvc\Service\ServiceManagerConfig; +use Zend\Permissions\Acl\Acl; +use Zend\Permissions\Acl\Role\GenericRole; +use Zend\Permissions\Acl\Resource\GenericResource; use Zend\ServiceManager\ServiceManager; use Zend\I18n\Translator\Translator; use Zend\View\Renderer\PhpRenderer; diff --git a/test/Helper/Navigation/LinksTest.php b/test/Helper/Navigation/LinksTest.php index a341bf76..725f6348 100644 --- a/test/Helper/Navigation/LinksTest.php +++ b/test/Helper/Navigation/LinksTest.php @@ -10,12 +10,12 @@ namespace ZendTest\View\Helper\Navigation; +use Zend\Config; use Zend\Navigation\Page\AbstractPage; use Zend\Navigation\Page\Uri as UriPage; -use Zend\Config; -use Zend\Acl; -use Zend\Acl\Role; -use Zend\Acl\Resource; +use Zend\Permissions\Acl; +use Zend\Permissions\Acl\Role; +use Zend\Permissions\Acl\Resource; use Zend\View; use Zend\View\Helper\Navigation; diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php index 62c284e5..73abee18 100644 --- a/test/Helper/Navigation/MenuTest.php +++ b/test/Helper/Navigation/MenuTest.php @@ -161,7 +161,7 @@ public function testUseConstructedAclRolesNotFromAclObject() { $acl = $this->_getAcl(); $this->_helper->setAcl($acl['acl']); - $this->_helper->setRole(new \Zend\Acl\Role\GenericRole('member')); + $this->_helper->setRole(new \Zend\Permissions\Acl\Role\GenericRole('member')); $expected = $this->_getExpected('menu/acl_role_interface.html'); $this->assertEquals($expected, $this->_helper->render()); diff --git a/test/Helper/Navigation/NavigationTest.php b/test/Helper/Navigation/NavigationTest.php index c1bf9361..3fcec6db 100644 --- a/test/Helper/Navigation/NavigationTest.php +++ b/test/Helper/Navigation/NavigationTest.php @@ -10,10 +10,10 @@ namespace ZendTest\View\Helper\Navigation; -use Zend\Acl; -use Zend\View\Helper\Navigation; -use Zend\Acl\Role; +use Zend\Permissions\Acl; +use Zend\Permissions\Acl\Role; use Zend\View; +use Zend\View\Helper\Navigation; /** * Tests Zend_View_Helper_Navigation From 76b3e1cd937e776a73bad44e7ad95c8efba29b81 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 25 Jul 2012 10:14:24 -0500 Subject: [PATCH 78/78] Fixed failing navigation tests - Removed $defaultServiceConfig from ModuleManagerFactory - Modified ModuleManagerFactory to add the ServiceListenerFactory - Removed adding the ServiceListenerFactory from Application::init() - Updated $defaultServiceConfig in ServiceListenerFactory to reflect changes needed for Console - Fixed ZendTest\View\Helper\Navigation\AbstractTest to remove adding the ServiceListenerFactory (since the ModuleManagerFactory now does that) --- test/Helper/Navigation/AbstractTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Helper/Navigation/AbstractTest.php b/test/Helper/Navigation/AbstractTest.php index 10973362..dce8445e 100644 --- a/test/Helper/Navigation/AbstractTest.php +++ b/test/Helper/Navigation/AbstractTest.php @@ -129,7 +129,6 @@ protected function setUp() $sm = $this->serviceManager = new ServiceManager(new ServiceManagerConfig); $sm->setService('ApplicationConfig', $smConfig); - $sm->setFactory('ServiceListener', 'Zend\Mvc\Service\ServiceListenerFactory'); $sm->get('ModuleManager')->loadModules(); $sm->get('Application')->bootstrap(); $sm->setFactory('Navigation', 'Zend\Navigation\Service\DefaultNavigationFactory');