-
Notifications
You must be signed in to change notification settings - Fork 61
Bug: Navigation Helper - isAllowed function - ACLlistener is Attached Several Times #129
Comments
Here is my workaround that I absolutely hate In one of my module I am adding a delegator at the "navigation" view helper level
Here is the delegator:
Because it is a delegator this code is executed before any initializers. Get the navigation helper and tell him to reuse Acl - so that the event is actually triggered in the "accept" function Now the ugly part is I add another delegator on all the Navigation Plugin Manager level for each Navigation Helpers
This delegator does the same thing than above It has to be delegators and cannot be initializers because the issue comes from the Initializer added by the Navigation View Helper Plugin Manager (in the __construct function) So I hate this workaround - but I don't think we can do it another way. |
Also it would be nice if the the isAllowed function had some kind of caching mechanism at the navigation container level - so it does not have to trigger events over and over if a page has already been accepted before By the way - I would be more than happy to do the work if needed - |
Another improvement: Zend\View\Helper\Navigation\AbstractHelper
|
@aft-christophe
This will be addressed for version 3 of
Why does |
Thank you
That s great.
Ok so because it is related to navigation you want that in the navigation repo - that s fine by me. We could ask the question the other way around though - why would zend-navigation need to Thanks |
@aft-christophe
I never said that! 😃 Btw. I think, before version 3 we can add some small improvements like stopping the propagation. |
This repository has been closed and moved to laminas/laminas-view; a new issue has been opened at laminas/laminas-view#12. |
Here is a fun bug for you all.
Everytime you instantiate a new Navigation Helper the the same Listener is attached to the shared Manager once again.
file: https://github.com/zendframework/zend-view/blob/master/src/Helper/Navigation/AbstractHelper.php
so if you do
Then the same AclListener function will be attached 3 times
It means that everytime the "isAllowed" function is called (it is called a LOT) then the AclListener function is called X times (3 times in my example).........
To fix this issue I believe that Zend View should not be in charge of registering any event
So my fix would be to get rid of this function altogether.
The Acl Listener should be moved the the zend-acl repository
And it should be the user responsibility to register any event on the isAllowed function.
The text was updated successfully, but these errors were encountered: