-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Laminas\Navigation does not work with Mezzio #2
Comments
I also found out, that
Originally posted by @RalfEggert at zendframework/zend-navigation#56 (comment) |
Right. At the moment, the navigation component supports the old router of the mvc component and the new router component: use Zend\Mvc\Router as MvcRouter;
use Zend\Router\RouteMatch;
use Zend\Router\RouteStackInterface; But I think this is not the problem. Please have a look at $application = $container->get('Application');
$routeMatch = $application->getMvcEvent()->getRouteMatch();
$router = $application->getMvcEvent()->getRouter();
$request = $application->getMvcEvent()->getRequest(); This matches the error message you posted. And this is the problem!
Sure! 😃
Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
Yep. Currently To split this up we might need some integration components for Originally posted by @RalfEggert at zendframework/zend-navigation#56 (comment) |
Right, but only in the current factories!
Yes and no! 😉 Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
Nope :) I really tried to find a better way but for now thats what works for me. At least with the Page\Mvc. /**
* @param ContainerInterface $container
* @param array|\Zend\Config\Config $pages
* @return null|array
* @throws \Zend\Navigation\Exception\InvalidArgumentException
*/
protected function preparePages(ContainerInterface $container, $pages)
{
/** @var RouterInterface $router */
$router = $container->get(RouterInterface::class);
// mah... it's ugly, i know
$request = ServerRequestFactory::fromGlobals();
$routeMatch = $router->match($request);
// HTTP request is the only one that may be injected
if (! $request instanceof Request) {
$request = null;
}
return $this->injectComponents($pages, $routeMatch, $router, $request);
} Originally posted by @tobias-trozowski at zendframework/zend-navigation#56 (comment) |
Please read carefully, because the content of Ralf's message was different:
The same here: the mvc component is not needed.
Right, but that was not the content of Ralf's message. $routeMatch = $router->match($request); This creates a Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
And yep, the match method will create a Didn't expect that zend-expressive have own implementation for the routing. I supposed zend-expressive uses zend-router. Originally posted by @tobias-trozowski at zendframework/zend-navigation#56 (comment) |
We developed an abstraction around routing, to allow usage of any routing library, and provide three implementations: Aura.Route, FastRoute, and zend-router; FastRoute is the recommended router! Thanks for opening this issue; clearly, we need to see if we can make it a bit more generic going forward! Originally posted by @weierophinney at zendframework/zend-navigation#56 (comment) |
When you plan to fix the bug? I need to understand whether or not to wait for the decision or to use something else for menu. Originally posted by @Sohorev at zendframework/zend-navigation#56 (comment) |
This is not a bug, because When? I will look into over the weekend. Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
@froschdesign that will be really great! Originally posted by @RalfEggert at zendframework/zend-navigation#56 (comment) |
@RalfEggert and @weierophinney I wanted an implementation for version 2 of (Notice: at the moment there is no support for multiple navigations) Usagedependencies.global.php 'dependencies' => [
'factories' => [
Zend\Navigation\Navigation::class => Zend\Navigation\Service\ExpressiveNavigationFactory::class,
],
'delegators' => [
Zend\View\HelperPluginManager::class => [
Zend\Navigation\View\ViewHelperManagerDelegatorFactory::class,
],
],
], middleware-pipeline.global.php 'dependencies' => [
'factories' => [
Zend\Navigation\Middleware\NavigationMiddleware::class => Zend\Navigation\Middleware\NavigationMiddlewareFactory::class,
],
],
'middleware_pipeline' => [
'routing' => [
'middleware' => [
ApplicationFactory::ROUTING_MIDDLEWARE,
Zend\Navigation\Middleware\NavigationMiddleware::class,
ApplicationFactory::DISPATCH_MIDDLEWARE,
],
],
], Add a configuration for the navigation itself: navigation.global.php return [
'navigation' => [
'default' => [
[
'label' => 'Home',
'route' => 'home',
],
[
'label' => 'Add album',
'route' => 'album',
'params' => [
'action' => 'add',
],
],
[
'label' => 'Edit album',
'route' => 'album',
'params' => [
'action' => 'edit',
],
],
],
],
]; Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
This looks great. Having an additional In the long run we should make 👍 👍 👍 Originally posted by @RalfEggert at zendframework/zend-navigation#56 (comment) |
Maybe this move can one time address performance issues that are turning people away from it (or at least I have seen in IRC complain, not sure exactly why, I suspect it deals with redundant router match). If navigation is told what is active, instead of the other way around, have opportunity to do better tree traversing, instead of brute-force recursive check of all nodes. If Z\Navigation stores its page node references not purely based on navigation hierarchy, but is "indexed" but route property of the pages, that index can be taken advantage of to quickly mark what page is active with $navigation->setActive($routerPath). Originally posted by @alextech at zendframework/zend-navigation#56 (comment) |
Any news? I am really looking forward for this patch to let Originally posted by @RalfEggert at zendframework/zend-navigation#56 (comment) |
@RalfEggert The support for multiple navigations is still missing. Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
@froschdesign thankyou for you patch Originally posted by @Sohorev at zendframework/zend-navigation#56 (comment) |
@froschdesign Originally posted by @mano87 at zendframework/zend-navigation#56 (comment) |
NewsCode updates
(not yet online - sorry!) Next steps
WhenI hope tomorrow! Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
Nice one! 👍 Originally posted by @RalfEggert at zendframework/zend-navigation#56 (comment) |
It just comes in time with Originally posted by @RalfEggert at zendframework/zend-navigation#56 (comment) |
@unnamed666 Please open a new issue with your question, instead of commenting on an unrelated one. Alternately, use our new forums: https://discourse.zendframework.com. Originally posted by @weierophinney at zendframework/zend-navigation#56 (comment) |
I wanted to create a new project based on Expressive and had the same errors as Ralf and saw that there is a pull request, which is still open. Could you tell us, when it will be possible to use zend-navigation in Expressive or what I could do to use it with the current version (if possible)? In the documentation of Expressive the navigation isn't mentioned. Originally posted by @av3 at zendframework/zend-navigation#56 (comment) |
Right, because this feature is still work in progress. You can use this branch for testing: https://github.com/froschdesign/zend-navigation/tree/feature/expressive-support After testing, please come back and give us a feedback. Thanks! Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
@froschdesign Thank you for your fast reply. I configured the files described. When using a single navigation, the output is working fine and the active menu item is getting his "active" class. But I wasn't able to use a second navigation, even after adding the abstract_factory to the dependencies. I'm getting the error message
Is there something wrong with my config or is the support of multiple containers missing in that branch? Originally posted by @av3 at zendframework/zend-navigation#56 (comment) |
I see nothing! 😉
No. ( Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
First I used the config for the single container and with the 'default' block in my navigation config. In the second step I extended my dependencies.global.php and added a second block in my navigation config.
My (complete) dependencies.global.php return [
'dependencies' => [
'abstract_factories' => [
Zend\Navigation\Service\ExpressiveNavigationAbstractServiceFactory::class,
],
'aliases' => [
'Zend\Expressive\Delegate\DefaultDelegate' => Zend\Expressive\Delegate\NotFoundDelegate::class,
],
'delegators' => [
Zend\View\HelperPluginManager::class => [
Zend\Navigation\View\ViewHelperManagerDelegatorFactory::class,
],
],
'invokables' => [
Zend\Expressive\Helper\ServerUrlHelper::class => Zend\Expressive\Helper\ServerUrlHelper::class,
Zend\Expressive\Router\RouterInterface::class => Zend\Expressive\Router\ZendRouter::class,
],
'factories' => [
'doctrine.entity_manager.orm_default' =>
ContainerInteropDoctrine\EntityManagerFactory::class,
Zend\Navigation\Navigation::class =>
Zend\Navigation\Service\ExpressiveNavigationFactory::class,
Zend\Expressive\Application::class =>
Zend\Expressive\Container\ApplicationFactory::class,
Zend\View\HelperPluginManager::class =>
Zend\Expressive\ZendView\HelperPluginManagerFactory::class,
Zend\Expressive\Template\TemplateRendererInterface::class =>
Zend\Expressive\ZendView\ZendViewRendererFactory::class,
Zend\Expressive\Delegate\NotFoundDelegate::class =>
Zend\Expressive\Container\NotFoundDelegateFactory::class,
Zend\Expressive\Helper\ServerUrlMiddleware::class =>
Zend\Expressive\Helper\ServerUrlMiddlewareFactory::class,
Zend\Expressive\Helper\UrlHelper::class =>
Zend\Expressive\Helper\UrlHelperFactory::class,
Zend\Stratigility\Middleware\ErrorHandler::class =>
Zend\Expressive\Container\ErrorHandlerFactory::class,
Zend\Expressive\Middleware\ErrorResponseGenerator::class =>
Zend\Expressive\Container\ErrorResponseGeneratorFactory::class,
Zend\Expressive\Middleware\NotFoundHandler::class =>
Zend\Expressive\Container\NotFoundHandlerFactory::class,
],
],
]; My complete middleware-pipeline.global.php return [
'dependencies' => [
'factories' => [
Zend\Navigation\Middleware\NavigationMiddleware::class =>
Zend\Navigation\Middleware\NavigationMiddlewareFactory::class,
Zend\Expressive\Helper\UrlHelperMiddleware::class =>
Zend\Expressive\Helper\UrlHelperMiddlewareFactory::class,
],
],
'middleware_pipeline' => [
'always' => [
'middleware' => [
Zend\Expressive\Helper\ServerUrlMiddleware::class,
],
'priority' => 10000,
],
'routing' => [
'middleware' => [
Zend\Expressive\Container\ApplicationFactory::ROUTING_MIDDLEWARE,
Zend\Navigation\Middleware\NavigationMiddleware::class,
Zend\Expressive\Helper\UrlHelperMiddleware::class,
Zend\Expressive\Container\ApplicationFactory::DISPATCH_MIDDLEWARE,
],
'priority' => 1,
],
'error' => [
'middleware' => [
// Add error middleware here.
],
'error' => true,
'priority' => -10000,
],
], My navigation block inside the config of my module: 'navigation' => [
'default' => [
[
'label' => 'Startseite',
'route' => 'home',
],
],
'footer' => [
[
'label' => 'Impressum',
'route' => 'imprint',
],
],
], Originally posted by @av3 at zendframework/zend-navigation#56 (comment) |
@av3 Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
@froschdesign
Originally posted by @av3 at zendframework/zend-navigation#56 (comment) |
Why? Don't do this! Originally posted by @froschdesign at zendframework/zend-navigation#56 (comment) |
More than four years later I wanted to switch from Expressive to Mezzio, but there is still not Mezzio Navigation and I'm not able to use the Laminas Navigation in my Mezzio application. Is there a way to get the Laminas Navigation working again (also with multiple navigations) or are there plans for Mezzio support in the near future? |
@av3
Unfortunately, my time is very limited and no one else seems to be interested in helping, so it's done when it's done.
Some modifications and extensions have to be made on this component before the support for Mezzio and multiple navigations can be added:
These extensions are planned for the next minor version. |
I want to use
Zend\Navigation
in aZend\Expressive
application. First of all, I installed it:Composer installed it and added the
ConfigProvider
to my/config/config.php
file:When I try to use the navigation view helper in a template, I get this error:
So, I added the
Zend\Navigation\View\ViewHelperManagerDelegatorFactory
to my configuration:No I get this error:
After some investigation the problem is located here:
https://github.com/zendframework/zend-navigation/blob/master/src/Service/AbstractNavigationFactory.php#L102
The
AbstractNavigationFactory
seems to have a hard dependency on the MVC application which makes it impossible to useZend\Navigation
withZend\Expressive
currently.Are there any plans to solve this? What should be done to break up this hard dependency? I guess it would be quite complicated to run
Zend\Navigation
both withZend\Mvc
andZend\Expressive
, wouldn't it?Originally posted by @RalfEggert at zendframework/zend-navigation#56
The text was updated successfully, but these errors were encountered: