Added zend-expressive support - fixes #56 #61
Added zend-expressive support - fixes #56 #61
Conversation
Usage for a single containerdependencies.global.php 'dependencies' => [
'factories' => [
Zend\Navigation\Navigation::class =>
Zend\Navigation\Service\ExpressiveNavigationFactory::class,
],
'delegators' => [
Zend\View\HelperPluginManager::class => [
Zend\Navigation\View\ViewHelperManagerDelegatorFactory::class,
],
],
'factories' => [
Zend\Navigation\Middleware\NavigationMiddleware::class =>
Zend\Navigation\Middleware\NavigationMiddlewareFactory::class,
],
], pipeline.php $app->pipeRoutingMiddleware();
// …
$app->pipe(Zend\Navigation\Middleware\NavigationMiddleware::class);
// …
$app->pipeDispatchMiddleware(); Usage for multiple containersdependencies.global.php 'dependencies' => [
'abstract_factories' => [
Zend\Navigation\Service\ExpressiveNavigationAbstractServiceFactory::class,
],
], NoticeDo not use the |
composer.json
Outdated
"zendframework/zend-log": "^2.7.1", | ||
"zendframework/zend-mvc": "^2.7.9 || ^3.0", | ||
"zendframework/zend-router": "^3.0", | ||
"zendframework/zend-config": "^3.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we have here also 2.6 version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but this is related to #59. I will this fixed there.
@webimpress |
@@ -0,0 +1,69 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
use Zend\Navigation\AbstractContainer; | ||
use Zend\Navigation\Exception; | ||
use Zend\Navigation\Page\ExpressivePage; | ||
use Zend\Expressive\Router\RouteResult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use alphabetical order of use statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if (! $container instanceof AbstractContainer) { | ||
throw new Exception\InvalidArgumentException( | ||
'Invalid argument: container must be an instance of ' | ||
. 'Zend\Navigation\AbstractContainer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use ::class
here and sprintf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -0,0 +1,83 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/** | ||
* Top-level configuration key indicating navigation configuration | ||
* | ||
* @var string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we use @const
instead of @var
for constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpDocumentor
@const
is not documented and supported.
PHP-Fig
You may use the @var tag to document the "Type" of the following "Structural Elements":
- Constants, both class and global scope
- Properties
- Variables, both global and local scope
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#722-var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok fine. Please just note it is proposed standard, not yet accepted. It's a bit odd that constant has annotation variable, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please just note it is proposed standard, not yet accepted.
Right, therefore the hint to phpDocumentor. 😉
As far as I know, APiGen does the same like phpDocumentor.
It's a bit odd that constant has annotation variable, isn't it?
I do not know where comes from. But, if it is not supported, why should we use that? And if we follow the PSR-5 proposal, than the "type" of the value should be described, not the element itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@webimpress It's been this way forever in both phpDocumentor (which predates PSR-5 by 15 years; PSR-5 is largely an attempt to codify what phpDocumentor has been doing all along) and in IDE support; it's the only supported, recognized way of annotating constants. No tools recognize @const
, unfortunately.
test/Page/ExpressivePageTest.php
Outdated
public function testGetHref() | ||
{ | ||
$page = new ExpressivePage( | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move it to line above, and then content can have one less indent and closing bracket could be with );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I can't find any documentation for this case.
- PHPStorm does the same formatting. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/Page/PageFactoryTest.php
Outdated
|
||
AbstractPage::factory([ | ||
'type' => 'ZendTest\Navigation\TestAsset\InvalidPage', | ||
'label' => 'My Invalid Page' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add trailing comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to #59
test/Page/PageFactoryTest.php
Outdated
); | ||
|
||
AbstractPage::factory([ | ||
'label' => 'My Invalid Page' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add trailing comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to #59
@@ -0,0 +1,89 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -0,0 +1,106 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-navigation for the canonical source repository | ||
* @copyright Copyright (c) 2016-2017 Zend Technologies USA Inc. (http://www.zend.com) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it it new file, we should have here just 2017 year.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
use Interop\Http\ServerMiddleware\DelegateInterface; | ||
use Interop\Http\ServerMiddleware\MiddlewareInterface; | ||
use RecursiveIteratorIterator; | ||
use Psr\Http\Message\ServerRequestInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use alphabetical order here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/** | ||
* @var AbstractContainer[] | ||
*/ | ||
private $containers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have here default value []
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* @param ServerRequestInterface $request | ||
* @param DelegateInterface $delegate | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use here @inheritDoc
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/Page/ExpressivePageTest.php
Outdated
|
||
public function testGetHrefSetsHrefCache() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove above empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
/** | ||
* @inheritdoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix camel case, it should be @inheritDoc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -0,0 +1,128 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still can't see it.
@@ -0,0 +1,65 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/Page/ExpressivePageTest.php
Outdated
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-navigation for the canonical source repository | ||
* @copyright Copyright (c) 2016-2017 Zend Technologies USA Inc. (http://www.zend.com) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is new file, please update year to 2017 only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
ping @weierophinney |
My suggestion for a release:
Later than:
|
👍 |
We can even split out zend-mvc-navigation early, and have it include the This would then also allow a 2.X version of zend-navigation to require that particular package in order to keep BC. v3 would remove it as a requirement altogether, and instead make it a suggestion. Similarly, a new 2.X version of zend-view could do the same to ensure we have the navigation helpers available, and v3 would make the package a suggestion instead of a requirement. |
@froschdesign If you want to create a new repo extracting the new functionality, I can review and fork it into the zendframework organization when it's ready, and add it to packagist at that time. |
The view helpers in zend-mvc-navigation?! |
Indeed! It's where they really belong. 😀 |
And if I will use zend-expressive, then I must also install |
How does it go on? |
@froschdesign — sorry for the late response:
For now, yes, to retain backwards compatibility. However, for a next major version of this component, we would not need to install the zend-mvc integration package. |
@froschdesign I recall you saying you had done the work of separating at least the Expressive support, but I cannot recall where; could you direct me there? |
@weierophinney
vs.
|
ping @weierophinney Can we clarify the problem / question from my last comment? Thanks! |
My idea is this:
Make sense? |
Sorry, not really. If I understand correctly and we will create all these packages, for a zend-expressive application I must install zend-expressive-navigation and zend-mvc-navigation?! (zend-mvc-navigation contains the view helpers a.k.a. |
Okay, that means three packages, then:
Expressive users would install zend-navigation and zend-expressive-navigation, and, optionally, zend-view-navigation (depending on their template renderer). zend-mvc users would install zend-navigation, zend-mvc-navigation, and zend-view-navigation. |
How does it go on here? We would like to use this feature ... |
Still work in progress. (I have to solve another problem before that.)
You can already use this branch: https://github.com/froschdesign/zend-navigation/tree/feature/expressive-support @ALL |
@froschdesign |
I hope, but at the moment the priority for the documentation is higher. (see: zendframework/zf-mkdoc-theme#34 – this will help all components!) |
Hello, a long time has gone without any (visible) progress! Cheers |
This PR will not be the solution. We will create a separate package / repository for the expressive support and another one for zend-view.
The current plan includes an alpha version of zend-navigation-zendview, which can be used with zend-expressive-navigation to output all kind of navigations. But you can test the current version of zend-expressive-navigation and leave some comments in the issue tracker. Thanks! |
Added a quick-and-dirty quick start to the new component: |
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-navigation for the canonical source repository | ||
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be 2018
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. 😉
See my comment above:
This PR will not be the solution. We will create a separate package / repository for the expressive support and another one for zend-view.
Please have a look at: https://github.com/froschdesign/zend-expressive-navigation
$containers = []; | ||
foreach ($containerNames as $containerName) { | ||
$containers[] = $container->get($containerName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May it use array_map
?
$containers = array_map([$container, 'get'], $containerNames);
Closing in favour of froschdesign/zend-expressive-navigation (WIP) |
This proposal does not change existing classes of the component, because I wanted an implementation for version 2 of zend-navigation.
ping @weierophinney @RalfEggert @webimpress