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

Commit fe669f5

Browse files
committed
Merging develop to master in preparation for 2.11.0 release.
2 parents 8c36d2a + 4b284f2 commit fe669f5

25 files changed

+444
-116
lines changed

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,50 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 2.11.0 - 2018-12-06
6+
7+
### Added
8+
9+
- [#168](https://github.com/zendframework/zend-view/pull/168) adds two new methods to `Zend\View\Helper\Placeholder` (and thus any
10+
helper extending it):
11+
12+
- `deleteContainer(string $name)` can be used to delete a placeholder container.
13+
- `clearContainers()` can be used to clear all placeholder containers.
14+
15+
These new features are particularly useful when in long-running server
16+
environments, such as Swoole, where you may need to clear the contents on each
17+
request.
18+
19+
### Changed
20+
21+
- [#155](https://github.com/zendframework/zend-view/pull/155) modifies the `Zend\View\Helper\Service\IdentifyFactory` such that it will
22+
now also look for the service `Zend\Authentication\AuthenticationServiceInterface`
23+
if the service `Zend\Authentication\AuthenticationService` is not found. This
24+
allows using a service named after the interface instead of the
25+
implementation if desired.
26+
27+
- [#158](https://github.com/zendframework/zend-view/pull/158) modifies how a `ViewModel` (and all extensions) is cloned; the `$variables`
28+
property, if it is an object, is now cloned as well to ensure changes in the
29+
new instance do not affect the current one.
30+
31+
- [#153](https://github.com/zendframework/zend-view/pull/153) updates the `ConsoleModel::setErrorLevel()` method to implement a fluent
32+
interface.
33+
34+
### Deprecated
35+
36+
- Nothing.
37+
38+
### Removed
39+
40+
- [#147](https://github.com/zendframework/zend-view/pull/147) removes the property `$regKey` from a number of helpers; these were a
41+
remnant of ZF1, and have not been used internally since the initial 2.0.0
42+
release.
43+
44+
### Fixed
45+
46+
- [#164](https://github.com/zendframework/zend-view/pull/164) fixes the various `Head*` view helpers such that they will now properly
47+
escape attributes as HTML attributes (instead of as HTML content).
48+
549
## 2.10.1 - 2018-12-06
650

751
### Added

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
},
6666
"extra": {
6767
"branch-alias": {
68-
"dev-master": "2.10.x-dev",
69-
"dev-develop": "2.11.x-dev"
68+
"dev-master": "2.11.x-dev",
69+
"dev-develop": "2.12.x-dev"
7070
}
7171
},
7272
"autoload-dev": {

doc/book/helpers/identity.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ The `Identity` helper allows retrieving the identity from the
44
`AuthenticationService`.
55

66
For the `Identity` helper to work, a `Zend\Authentication\AuthenticationService`
7-
name or alias must be defined and recognized by the `ServiceManager`.
7+
or `Zend\Authentication\AuthenticationServiceInterface` name or alias must be
8+
defined and recognized by the `ServiceManager`.
89

910
`Identity` returns the identity discovered in the `AuthenticationService`, or
1011
`null` if no identity is available.
@@ -43,3 +44,6 @@ return [
4344
],
4445
];
4546
```
47+
48+
If that service is not registered, the plugin will then look for a service named
49+
`Zend\Authentication\AuthenticationServiceInterface`, and use that if found.

doc/book/helpers/placeholder.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $this->placeholder('foo')
6363
<?= $this->placeholder('foo') ?>
6464
```
6565

66-
The above results in an unodered list with pretty indentation.
66+
The above results in an unordered list with pretty indentation.
6767

6868
Because the `Placeholder` container objects extend `ArrayObject`, you can also
6969
assign content to a specific key in the container easily, instead of simply
@@ -131,6 +131,24 @@ foreach ($this->data as $datum): ?>
131131
<?= $this->placeholder('foo')->data ?>
132132
```
133133

134+
## Clearing Content
135+
136+
In certain situations it is desirable to remove or clear containers and
137+
aggregated content. The placeholder view helper provides two methods to either
138+
delete a specific container or clear all containers at once:
139+
140+
### Delete a single container
141+
142+
```php
143+
$this->plugin('placeholder')->deleteContainer('myNamedContainer');
144+
```
145+
146+
### Clear all containers
147+
148+
```php
149+
$this->plugin('placeholder')->clearContainers();
150+
```
151+
134152
## Concrete Implementations
135153

136154
zend-view ships with a number of "concrete" placeholder implementations. These

src/Helper/AbstractHtmlElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function htmlAttribs($attribs)
7272
foreach ((array) $attribs as $key => $val) {
7373
$key = $escaper($key);
7474

75-
if (('on' == substr($key, 0, 2)) || ('constraints' == $key)) {
75+
if (0 === strpos($key, 'on') || ('constraints' == $key)) {
7676
// Don't escape event attributes; _do_ substitute double quotes with singles
7777
if (! is_scalar($val)) {
7878
// non-scalar data should be cast to JSON first
@@ -108,7 +108,7 @@ protected function htmlAttribs($attribs)
108108
*/
109109
protected function normalizeId($value)
110110
{
111-
if (strstr($value, '[')) {
111+
if (false !== strpos($value, '[')) {
112112
if ('[]' == substr($value, -2)) {
113113
$value = substr($value, 0, strlen($value) - 2);
114114
}

src/Helper/Doctype.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __invoke($doctype = null)
9595
$this->setDoctype($doctype);
9696
break;
9797
default:
98-
if (substr($doctype, 0, 9) != '<!DOCTYPE') {
98+
if (0 !== strpos($doctype, '<!DOCTYPE')) {
9999
throw new Exception\DomainException('The specified doctype is malformed');
100100
}
101101
if (stristr($doctype, 'xhtml')) {

src/Helper/HeadLink.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Zend\View\Helper;
1111

1212
use stdClass;
13-
use Zend\View;
1413
use Zend\View\Exception;
1514

1615
// @codingStandardsIgnoreStart
@@ -55,13 +54,6 @@ class HeadLink extends Placeholder\Container\AbstractStandalone
5554
'as',
5655
];
5756

58-
/**
59-
* Registry key for placeholder
60-
*
61-
* @var string
62-
*/
63-
protected $regKey = 'Zend_View_Helper_HeadLink';
64-
6557
/**
6658
* Constructor
6759
*
@@ -302,13 +294,17 @@ public function itemToString(stdClass $item)
302294
if (isset($attributes[$itemKey])) {
303295
if (is_array($attributes[$itemKey])) {
304296
foreach ($attributes[$itemKey] as $key => $value) {
305-
$link .= sprintf(' %s="%s"', $key, ($this->autoEscape) ? $this->escape($value) : $value);
297+
$link .= sprintf(
298+
' %s="%s"',
299+
$key,
300+
($this->autoEscape) ? $this->escapeAttribute($value) : $value
301+
);
306302
}
307303
} else {
308304
$link .= sprintf(
309305
' %s="%s"',
310306
$itemKey,
311-
($this->autoEscape) ? $this->escape($attributes[$itemKey]) : $attributes[$itemKey]
307+
($this->autoEscape) ? $this->escapeAttribute($attributes[$itemKey]) : $attributes[$itemKey]
312308
);
313309
}
314310
}

src/Helper/HeadMeta.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ class HeadMeta extends Placeholder\Container\AbstractStandalone
5959
*/
6060
protected $modifierKeys = ['lang', 'scheme'];
6161

62-
/**
63-
* Registry key for placeholder
64-
*
65-
* @var string
66-
*/
67-
protected $regKey = 'Zend_View_Helper_HeadMeta';
68-
6962
/**
7063
* Constructor
7164
*
@@ -250,7 +243,7 @@ public function itemToString(stdClass $item)
250243
if (! in_array($key, $this->modifierKeys)) {
251244
continue;
252245
}
253-
$modifiersString .= $key . '="' . $this->escape($value) . '" ';
246+
$modifiersString .= $key . '="' . $this->escapeAttribute($value) . '" ';
254247
}
255248

256249
$modifiersString = rtrim($modifiersString);
@@ -278,8 +271,8 @@ public function itemToString(stdClass $item)
278271
$meta = sprintf(
279272
$tpl,
280273
$type,
281-
$this->escape($item->$type),
282-
$this->escape($item->content),
274+
$this->escapeAttribute($item->$type),
275+
$this->escapeAttribute($item->content),
283276
$modifiersString
284277
);
285278

src/Helper/HeadScript.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Zend\View\Helper;
1111

1212
use stdClass;
13-
use Zend\View;
1413
use Zend\View\Exception;
1514

1615
/**
@@ -36,13 +35,6 @@ class HeadScript extends Placeholder\Container\AbstractStandalone
3635
const FILE = 'FILE';
3736
const SCRIPT = 'SCRIPT';
3837

39-
/**
40-
* Registry key for placeholder
41-
*
42-
* @var string
43-
*/
44-
protected $regKey = 'Zend_View_Helper_HeadScript';
45-
4638
/**
4739
* Are arbitrary attributes allowed?
4840
*
@@ -399,7 +391,11 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd)
399391
if ('async' == $key) {
400392
$value = 'async';
401393
}
402-
$attrString .= sprintf(' %s="%s"', $key, ($this->autoEscape) ? $this->escape($value) : $value);
394+
$attrString .= sprintf(
395+
' %s="%s"',
396+
$key,
397+
($this->autoEscape) ? $this->escapeAttribute($value) : $value
398+
);
403399
}
404400
}
405401

@@ -409,7 +405,7 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd)
409405
if (empty($item->type) && $this->view && $this->view->plugin('doctype')->isHtml5()) {
410406
$html = '<script ' . $attrString . '>';
411407
} else {
412-
$type = ($this->autoEscape) ? $this->escape($item->type) : $item->type;
408+
$type = ($this->autoEscape) ? $this->escapeAttribute($item->type) : $item->type;
413409
$html = '<script type="' . $type . '"' . $attrString . '>';
414410
}
415411
if (! empty($item->source)) {

src/Helper/HeadStyle.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424
*/
2525
class HeadStyle extends Placeholder\Container\AbstractStandalone
2626
{
27-
/**
28-
* Registry key for placeholder
29-
*
30-
* @var string
31-
*/
32-
protected $regKey = 'Zend_View_Helper_HeadStyle';
33-
3427
/**
3528
* Allowed optional attributes
3629
*

0 commit comments

Comments
 (0)