zendframework / zend-navigation

Navigation component from Zend Framework
BSD 3-Clause "New" or "Revised" License
20 stars 25 forks source link

Added zend-expressive support - fixes #56 #61

Closed froschdesign closed 6 years ago

froschdesign commented 7 years ago

This proposal does not change existing classes of the component, because I wanted an implementation for version 2 of zend-navigation.

Caution

This PR based on PHPUnit 5.7 || 6.0! See: #59

ping @weierophinney @RalfEggert @webimpress

froschdesign commented 7 years ago

Usage for a single container

dependencies.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 containers

dependencies.global.php

'dependencies' => [
    'abstract_factories' => [
        Zend\Navigation\Service\ExpressiveNavigationAbstractServiceFactory::class,
    ],
],

Notice

Do not use the ConfigProvider class, because at the moment the ConfigProvider only includes the configuration for zend-mvc-based applications!

froschdesign commented 7 years ago

@webimpress Can you look at the Middleware? Thanks!

froschdesign commented 7 years ago

ping @weierophinney

weierophinney commented 7 years ago

@froschdesign Just FYI: I rebased your branch based on current develop.

froschdesign commented 7 years ago

@weierophinney

For the first 3 comments: I will add new commits.

I'm wondering if this functionality should be in this component, or a bridge component (e.g., zend-expressive-navigation).

I had the same thoughts and I think that is the right way.

We could even eventually move the zend-mvc-specific functionality into its own package.

zend-navigation had no refactoring from ZF1 to ZF2 like zend-form. The view helper are still present in the zend-view component and all problems from version 1 were also included in version 2. The next version would be 2.9, followed by 3.0. I don't know if these extra page types really needed – as example.

RalfEggert commented 7 years ago

I really like the idea of extracting the MVC and the Expressive part from Zend\Ņavigation in separated bridge components. But that should really be done with the version 3 of Zend\Ņavigation. Currently I cannot use Zend\Ņavigation with Zend\Expressive at all, so I would prefer a 2.x version to get me and others started to use Zend\Ņavigation with Zend\Expressive.

:+1:

froschdesign commented 7 years ago

@weierophinney @RalfEggert

My suggestion for a release:

Later than:

RalfEggert commented 7 years ago

:+1:

weierophinney commented 7 years ago

We can even split out zend-mvc-navigation early, and have it include the Page\Mvc class and all zend-view helpers; if it is registered later than zend-navigation and zend-view in the list of modules, then its own configuration takes precedence.

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.

weierophinney commented 7 years ago

@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.

froschdesign commented 7 years ago

@weierophinney

We can even split out zend-mvc-navigation early, and have it include the Page\Mvc class and all zend-view helpers

The view helpers in zend-mvc-navigation?!

weierophinney commented 7 years ago

The view helpers in zend-mvc-navigation?!

Indeed! It's where they really belong. 😀

froschdesign commented 7 years ago

Indeed! It's where they really belong.

And if I will use zend-expressive, then I must also install Page\Mvc?

mano87 commented 7 years ago

How does it go on?

weierophinney commented 7 years ago

@froschdesign — sorry for the late response:

And if I will use zend-expressive, then I must also install Page\Mvc?

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.

weierophinney commented 7 years ago

@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?

froschdesign commented 7 years ago

@weierophinney Maybe I misunderstood something, but I think these statements collide:

The view helpers in zend-mvc-navigation?!

Indeed! It's where they really belong.

vs.

However, for a next major version of this component, we would not need to install the zend-mvc integration package.

froschdesign commented 7 years ago

ping @weierophinney

Can we clarify the problem / question from my last comment? Thanks!

weierophinney commented 7 years ago

@froschdesign —

My idea is this:

Make sense?

froschdesign commented 7 years ago

@weierophinney

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. Zend\Navigation\View)

weierophinney commented 7 years ago

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. Zend\Navigation\View)

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.

mano87 commented 6 years ago

How does it go on here? We would like to use this feature ...

froschdesign commented 6 years ago

@mano87

How does it go on here?

Still work in progress. (I have to solve another problem before that.)

We would like to use this feature ...

You can already use this branch: https://github.com/froschdesign/zend-navigation/tree/feature/expressive-support

@all Thanks for your patience!

throny commented 6 years ago

@froschdesign Thank you for your commitment so far! Is a new zend-navigation release with expressive (3) support planned yet?

froschdesign commented 6 years ago

@throny

Is a new zend-navigation release with expressive (3) support planned yet?

I hope, but at the moment the priority for the documentation is higher. (see: https://github.com/zendframework/zf-mkdoc-theme/pull/34 – this will help all components!)

lowtower commented 6 years ago

Hello,

a long time has gone without any (visible) progress! Is there any chance to get this working and released anytime?

Cheers

froschdesign commented 6 years ago

@lowtower

a long time has gone without any (visible) progress!

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

Is there any chance to get this working and released anytime?

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. When? At the moment I'm still on vacation.

But you can test the current version of zend-expressive-navigation and leave some comments in the issue tracker. Thanks!

RalfEggert commented 6 years ago

Added a quick-and-dirty quick start to the new component:

https://github.com/froschdesign/zend-expressive-navigation/issues/2

froschdesign commented 6 years ago

Closing in favour of froschdesign/zend-expressive-navigation (WIP)