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

Commit ec5731f

Browse files
committed
Merging develop to master in preparation for 2.7.0
2 parents 2d36972 + 5ac36c4 commit ec5731f

12 files changed

+556
-142
lines changed

CHANGELOG.md

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

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

5+
## 2.7.0 - TBD
6+
7+
### Added
8+
9+
- [#1](https://github.com/zendframework/zend-view/pull/1) adds a new `loop()`
10+
method to the `partialLoop()` helper, allowing the ability to chain setters
11+
with rendering:
12+
`$this->partialLoop()->setObjectKey('foo')->loop('partial', $data)`
13+
- [#60](https://github.com/zendframework/zend-view/pull/60) adds the ability to
14+
register and consume arbitrary callables as view helpers within the
15+
`HelperPluginManager`.
16+
17+
### Deprecated
18+
19+
- Nothing.
20+
21+
### Removed
22+
23+
- Nothing.
24+
25+
### Fixed
26+
27+
- Nothing.
28+
529
## 2.6.8 - 2016-05-12
630

731
### Added

src/Helper/PartialLoop.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,20 @@ public function __invoke($name = null, $values = null)
5858
if (0 == func_num_args()) {
5959
return $this;
6060
}
61+
return $this->loop($name, $values);
62+
}
6163

64+
/**
65+
* Renders a template fragment within a variable scope distinct from the
66+
* calling View object.
67+
*
68+
* @param string $name Name of view script
69+
* @param array $values Variables to populate in the view
70+
* @throws Exception\InvalidArgumentException
71+
* @return string
72+
*/
73+
public function loop($name = null, $values = null)
74+
{
6275
// reset the counter if it's called again
6376
$this->partialCounter = 0;
6477
$content = '';

src/HelperPluginManager.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ class HelperPluginManager extends AbstractPluginManager
137137
'ViewModel' => Helper\ViewModel::class,
138138
];
139139

140-
protected $instanceOf = Helper\HelperInterface::class;
141-
142140
/**
143141
* Default factories
144142
*
@@ -289,6 +287,10 @@ public function injectRenderer($first, $second)
289287
? $second
290288
: $first;
291289

290+
if (! $helper instanceof Helper\HelperInterface) {
291+
return;
292+
}
293+
292294
$renderer = $this->getRenderer();
293295
if (null === $renderer) {
294296
return;
@@ -393,19 +395,19 @@ public function injectEventManager($first, $second)
393395
/**
394396
* Validate the plugin is of the expected type (v3).
395397
*
396-
* Validates against `$instanceOf`.
398+
* Validates against callables and HelperInterface implementations.
397399
*
398400
* @param mixed $instance
399401
* @throws InvalidServiceException
400402
*/
401403
public function validate($instance)
402404
{
403-
if (!$instance instanceof $this->instanceOf) {
405+
if (! is_callable($instance) && ! $instance instanceof Helper\HelperInterface) {
404406
throw new InvalidServiceException(
405407
sprintf(
406-
'%s can only create instances of %s; %s is invalid',
408+
'%s can only create instances of %s and/or callables; %s is invalid',
407409
get_class($this),
408-
$this->instanceOf,
410+
Helper\HelperInterface::class,
409411
(is_object($instance) ? get_class($instance) : gettype($instance))
410412
)
411413
);

0 commit comments

Comments
 (0)