Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c86bc36
spelling fixes
Apr 9, 2017
2c89b46
Test for ensuring, that the PhpRenderer doesnt use previous rendered …
Apr 26, 2017
2841a1d
Closing parentheses of the attach method parameters
alessandrofeitoza May 11, 2017
b0f159d
PHP 7 - Catching Error - Bug fix
Jun 4, 2017
54bc355
add missing Greater-than sign
ooghry Aug 11, 2017
ad737ab
Added navigation helpers in DocBlock of navigation proxy helper for c…
froschdesign Aug 23, 2017
b80a013
Fixes #134 : add Exception on HeadeMeta::setCharset() when the doctyp…
samsonasik Aug 30, 2017
895f222
move isXhtml with type = charset check in HeadMeta::isValid() and cal…
samsonasik Aug 30, 2017
6b6690d
update exception messages and docblock param in HeadMeta::set(), appe…
samsonasik Aug 30, 2017
01ddf68
apply RuntimException in setCharset() when isValid() = false
samsonasik Aug 30, 2017
ed6cc45
use InvalidArgumentException instead for exception in setCharset
samsonasik Aug 30, 2017
dfcbbed
Merge branch 'samsonasik-fix-134'
froschdesign Aug 31, 2017
6ec0518
Fixes DocBlocks in HeadMeta helper
froschdesign Aug 31, 2017
5523511
Merge branch 'hotfix/head-meta-docblocks'
froschdesign Aug 31, 2017
7736896
Merge pull request #136 from froschdesign/hotfix/docblock-navigation
weierophinney Jan 16, 2018
7245817
Adds CHANGELOG entry for #136
weierophinney Jan 16, 2018
eda66b8
Merge branch 'hotfix/136'
weierophinney Jan 16, 2018
2d7f18b
Updated HelperPluginManager::injectTranslator(), return early when he…
bacinsky May 17, 2017
dcd1dac
Adds CHANGELOG entry for #123
weierophinney Jan 16, 2018
bd01e81
Merge branch 'hotfix/123'
weierophinney Jan 16, 2018
8ce49c8
Merge pull request #119 from ka7/feature/spelling
weierophinney Jan 16, 2018
6109c5b
Merge branch 'hotfix/119'
weierophinney Jan 16, 2018
eed5ed6
Merge pull request #122 from alessandrofeitoza/patch-1
weierophinney Jan 16, 2018
92e5533
Merge branch 'hotfix/122'
weierophinney Jan 16, 2018
e3dc78f
Merge pull request #125 from aft-christophe/master
weierophinney Jan 16, 2018
c0d23f1
Adds CHANGELOG entry for #125
weierophinney Jan 16, 2018
146fff4
Merge branch 'hotfix/125'
weierophinney Jan 16, 2018
2849f34
Merge pull request #132 from ooghry/patch-1
weierophinney Jan 16, 2018
449c4d9
Merge branch 'hotfix/132'
weierophinney Jan 16, 2018
29ae610
Merge pull request #121 from porebskk/master
weierophinney Jan 16, 2018
d48c1d9
Adds `@see` annotations to new tests
weierophinney Jan 16, 2018
ffc1523
Do not cache results of previous render
weierophinney Jan 16, 2018
61c8ac2
sort-packages should be a boolean
weierophinney Jan 17, 2018
827a43c
Make the composer process timeout longer so we can run tests with cov…
weierophinney Jan 17, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cache:

env:
global:
- COMPOSER_PROCESS_TIMEOUT=600
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="satooshi/php-coveralls"
- LEGACY_DEPS="phpunit/phpunit"
Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ All notable changes to this project will be documented in this file, in reverse

### Added

- Nothing.
- [#136](https://github.com/zendframework/zend-view/pull/136) updates the
`Navigation` helper class to document the various proxy methods it allows via
method overloading via `@method` annotations.

### Deprecated

Expand All @@ -18,7 +20,14 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#123](https://github.com/zendframework/zend-view/pull/123) updates the
`HelperPluginManager` such that it no longer injects a translator in a helper
if one is already present.

- [#125](https://github.com/zendframework/zend-view/pull/125) provides an update
to the `PhpRenderer:render()` method such that it will now catch not only
`Exception` instances, but also PHP 7 `Throwable` instances, and properly
cleanup the output buffers when it does.

## 2.9.0 - 2017-03-21

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": "true"
"sort-packages": true
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion doc/book/helpers/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ determine how to handle the content.
> `enableJsonExprFinder` key of the options array:
>
> ```php
> <?= $this-json($this-data, ['enableJsonExprFinder' = true]) ?>
> <?= $this->json($this->data, ['enableJsonExprFinder' => true]) ?>
> ```
4 changes: 2 additions & 2 deletions doc/book/php-renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ $stack = new Resolver\TemplatePathStack([
$resolver
->attach($map) // this will be consulted first, and is the fastest lookup
->attach($stack) // filesystem-based lookup
->attach(new Resolver\RelativeFallbackResolver($map) // allow short template names
->attach(new Resolver\RelativeFallbackResolver($stack);
->attach(new Resolver\RelativeFallbackResolver($map)) // allow short template names
->attach(new Resolver\RelativeFallbackResolver($stack));
```

You can also specify a specific priority value when registering resolvers, with
Expand Down
41 changes: 25 additions & 16 deletions src/Helper/HeadMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ protected function normalizeType($type)
/**
* Determine if item is valid
*
* @param mixed $item
* @param stdClass $item
* @return bool
*/
protected function isValid($item)
Expand All @@ -334,22 +334,27 @@ protected function isValid($item)
return false;
}

$doctype = $this->view->plugin('doctype');
if ($item->type === 'charset' && $doctype->isXhtml()) {
return false;
}

if (! isset($item->content)
&& (! $this->view->plugin('doctype')->isHtml5()
|| (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset'))
&& (! $doctype->isHtml5()
|| (! $doctype->isHtml5() && $item->type !== 'charset'))
) {
return false;
}

// <meta itemprop= ... /> is only supported with doctype html
if (! $this->view->plugin('doctype')->isHtml5()
if (! $doctype->isHtml5()
&& $item->type === 'itemprop'
) {
return false;
}

// <meta property= ... /> is only supported with doctype RDFa
if (! $this->view->plugin('doctype')->isRdfa()
if (! $doctype->isRdfa()
&& $item->type === 'property'
) {
return false;
Expand All @@ -361,15 +366,15 @@ protected function isValid($item)
/**
* Append
*
* @param string $value
* @return void
* @param stdClass $value
* @return View\Helper\Placeholder\Container\AbstractContainer
* @throws Exception\InvalidArgumentException
*/
public function append($value)
{
if (! $this->isValid($value)) {
throw new Exception\InvalidArgumentException(
'Invalid value passed to append; please use appendMeta()'
'Invalid value passed to append'
);
}

Expand All @@ -382,7 +387,6 @@ public function append($value)
* @param string|int $index
* @param string $value
* @throws Exception\InvalidArgumentException
* @return void
*/
public function offsetSet($index, $value)
{
Expand All @@ -400,7 +404,6 @@ public function offsetSet($index, $value)
*
* @param string|int $index
* @throws Exception\InvalidArgumentException
* @return void
*/
public function offsetUnset($index)
{
Expand All @@ -414,15 +417,15 @@ public function offsetUnset($index)
/**
* Prepend
*
* @param string $value
* @param stdClass $value
* @throws Exception\InvalidArgumentException
* @return void
* @return View\Helper\Placeholder\Container\AbstractContainer
*/
public function prepend($value)
{
if (! $this->isValid($value)) {
throw new Exception\InvalidArgumentException(
'Invalid value passed to prepend; please use prependMeta()'
'Invalid value passed to prepend'
);
}

Expand All @@ -432,14 +435,14 @@ public function prepend($value)
/**
* Set
*
* @param string $value
* @param stdClass $value
* @throws Exception\InvalidArgumentException
* @return void
* @return View\Helper\Placeholder\Container\AbstractContainer
*/
public function set($value)
{
if (! $this->isValid($value)) {
throw new Exception\InvalidArgumentException('Invalid value passed to set; please use setMeta()');
throw new Exception\InvalidArgumentException('Invalid value passed to set');
}

$container = $this->getContainer();
Expand All @@ -458,6 +461,7 @@ public function set($value)
* Not valid in a non-HTML5 doctype
*
* @param string $charset
* @param Exception\InvalidArgumentException
* @return HeadMeta Provides a fluent interface
*/
public function setCharset($charset)
Expand All @@ -467,6 +471,11 @@ public function setCharset($charset)
$item->charset = $charset;
$item->content = null;
$item->modifiers = [];

if (! $this->isValid($item)) {
throw new Exception\InvalidArgumentException('XHTML* doctype has no attribute charset; please use appendHttpEquiv()');
}

$this->set($item);

return $this;
Expand Down
5 changes: 5 additions & 0 deletions src/Helper/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

/**
* Proxy helper for retrieving navigational helpers and forwarding calls
*
* @method \Zend\View\Helper\Navigation\Breadcrumbs breadcrumbs($container = null)
* @method \Zend\View\Helper\Navigation\Links links($container = null)
* @method \Zend\View\Helper\Navigation\Menu menu($container = null)
* @method \Zend\View\Helper\Navigation\Sitemap sitemap($container = null)
*/
class Navigation extends AbstractNavigationHelper
{
Expand Down
4 changes: 4 additions & 0 deletions src/HelperPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ public function injectTranslator($first, $second)
return;
}

if (method_exists($helper, 'hasTranslator') && $helper->hasTranslator()) {
return;
}

if ($container->has('MvcTranslator')) {
$helper->setTranslator($container->get('MvcTranslator'));
return;
Expand Down
6 changes: 5 additions & 1 deletion src/Renderer/PhpRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ public function render($nameOrModel, $values = null)
extract($__vars);
unset($__vars); // remove $__vars from local scope

$this->__content = '';
while ($this->__template = array_pop($this->__templates)) {
$this->__file = $this->resolver($this->__template);
if (! $this->__file) {
Expand All @@ -504,7 +505,10 @@ public function render($nameOrModel, $values = null)
ob_start();
$includeReturn = include $this->__file;
$this->__content = ob_get_clean();
} catch (\Exception $ex) {
} catch (\Throwable $ex) {
ob_end_clean();
throw $ex;
} catch (\Exception $ex) { // @TODO clean up once PHP 7 requirement is enforced
ob_end_clean();
throw $ex;
}
Expand Down
2 changes: 1 addition & 1 deletion test/Helper/DoctypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function testIsHtml5()

public function testIsRdfa()
{
// ensure default registerd Doctype is false
// ensure default registered Doctype is false
$this->assertFalse($this->helper->isRdfa());

$this->assertTrue($this->helper->__invoke(Helper\Doctype::XHTML1_RDFA)->isRdfa());
Expand Down
12 changes: 12 additions & 0 deletions test/Helper/HeadMetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,18 @@ public function testCharsetPosition()
);
}

public function testCarsetWithXhtmlDoctypeGotException()
{
$this->expectException(Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('XHTML* doctype has no attribute charset; please use appendHttpEquiv()');

$view = new View();
$view->plugin('doctype')->__invoke('XHTML1_RDFA');

$view->plugin('headMeta')
->setCharset('utf-8');
}

/**
* @group ZF-9743
*/
Expand Down
22 changes: 22 additions & 0 deletions test/HelperPluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,28 @@ public function testInjectTranslatorWillReturnEarlyIfThePluginManagerDoesNotHave
$this->assertNull($helper->getTranslator());
}

public function testInjectTranslatorWillReturnEarlyIfTheHelperHasTranslatorAlready()
{
$translatorA = new Translator();
$translatorB = new Translator();
$config = new Config(['services' => [
'Translator' => $translatorB,
]]);
$services = new ServiceManager();
$config->configureServiceManager($services);
$helpers = new HelperPluginManager($services);
$helpers->setFactory(
'TestHelper',
function () use ($translatorA) {
$helper = new HeadTitle();
$helper->setTranslator($translatorA);
return $helper;
}
);
$helperB = $helpers->get('TestHelper');
$this->assertSame($translatorA, $helperB->getTranslator());
}

public function testCanOverrideAFactoryViaConfigurationPassedToConstructor()
{
$helper = $this->prophesize(HelperInterface::class)->reveal();
Expand Down
30 changes: 30 additions & 0 deletions test/PhpRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,34 @@ public function testDoesNotCallFilterChainIfNoFilterChainWasSet()
$this->assertContains('Empty view', $result);
$this->assertAttributeEmpty('__filterChain', $this->renderer);
}

/**
* @group zend-view-120
* @see https://github.com/zendframework/zend-view/issues/120
*/
public function testRendererDoesntUsePreviousRenderedOutputWhenInvokedWithEmptyString()
{
$this->renderer->resolver()->addPath(__DIR__ . '/_templates');

$previousOutput = $this->renderer->render('empty.phtml');

$actual = $this->renderer->render('');

$this->assertNotSame($previousOutput, $actual);
}

/**
* @group zend-view-120
* @see https://github.com/zendframework/zend-view/issues/120
*/
public function testRendererDoesntUsePreviousRenderedOutputWhenInvokedWithFalse()
{
$this->renderer->resolver()->addPath(__DIR__ . '/_templates');

$previousOutput = $this->renderer->render('empty.phtml');

$actual = $this->renderer->render(false);

$this->assertNotSame($previousOutput, $actual);
}
}