-
Notifications
You must be signed in to change notification settings - Fork 61
Fatal error: Uncaught exception 'Zend\View\Exception\InvalidArgumentException' #49
Comments
I've found the issue. We removed the |
@marciodojr Can you test the patch from #50, please, and let me know if it resolves the issue for you? Thanks! |
@weierophinney I don't know if I'm applying your patch by the right way but I tested and the error keeps the same (I'm probably doing something wrong). To test your patch I did this: (1) update the zend-view component to version 2.6.2 (2) added this code to my composer.json:
With composer update I have the following output
|
@marciodojr Besides adding the repository, you also have to specify the branch within your project; this is usually best done using an alias: "require" : {
"zendframework/zend-view": "dev-hotfix/49 as 2.6.3"
} Then run |
I reverted the zend-view to 2.6.2 added the require line and ran the update command but the error keeps exactly the same
|
@marciodojr Just to confirm, after getting the updates containing my patch, you're still seeing an error? |
Yes, I'm seeing this:
|
I started a fresh zf2 skeleton application with the minimum necessary to reproduce the error (a little change in composer.json, navigation config in module.config.php, a factory and a echo of the navigation in layout), maybe this can help a little. As before the error does not occur with zend-view ~2.5.3 https://github.com/marciodojr/zf2-test-navigation-view-factory.git |
Adds code to the `getPluginManager()` implementation to ensure that if a service locator is composed, it is used to inject a lazy-instantiated navigation plugin manager. This should fix the last lingering issues as reported in zendframework#49.
@marciodojr I think I've finally isolated the issue; the lazy-instantiated |
@weierophinney Could you please reconfirm that the problem was fixed? I updated zend-view component to 2.6.3 but the error message is still appearing (just the lines changed a little)
|
@marciodojr Can you try something for me? Change this code: 'view_helpers' => array(
'factories' => array(
'navigation' => 'UMS\Factory\NavigationViewFactory',
),
), to read as follows: 'view_helpers' => array(
'factories' => array(
'Zend\View\Helper\Navigation' => 'UMS\Factory\NavigationViewFactory',
'zendviewhelpernavigation' => 'UMS\Factory\NavigationViewFactory',
),
), and let me know if that solves the issue for you? (One of the subtle issues we're noticing during the forwards-compatibility migrations is differences with how aliases work, and I think this might be the last piece of the puzzle.) |
@weierophinney the navigation finally works thank you very much. And sorry for so many posts =). |
Hi @weierophinney Or If we change navigation helper to 'zendviewhelpernavigation'
Thank's |
@nokser As this issue is marked resolved to the satisfaction of the original reporter, please open a new issue, with the following information:
|
@weierophinney well ... @nokser was right. Acl doesn't filter the navigation menu items anymore. And the reason is (I think it is) the code bellow doesn't have any effect, the factory is never called:
I tried an exit command in UMS\Factory\NavigationViewFactory and the navigation menu appears (the exit was never executed), in zend-veiw 2.5.3 the exit command blocks the navigation (as expected). Do I have to create a new issue or continue here? |
@marciodojr I'm re-opening the issue. That said, I spotted an error in your factory, one that can lead to a circular dependency. It's this line here: $navigation = $serviceLocator->get('Zend\View\Helper\Navigation'); I'd rewrite that factory as follows: namespace UMS\Factory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Session\Container;
use Zend\View\Helper\Navigation as NavigationHelper;
class NavigationViewFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$session = new Container('User');
$role = $session->activeRole;
$acl = $serviceLocator->getServiceLocator()->get('acl');
$navigation = $this->createHelper($serviceLocator);
$navigation->setAcl($acl)->setRole($role);
return $navigation;
}
private function createHelper(ServiceLocatorInterface $serviceLocator)
{
$helper = new NavigationHelper();
$helper->setServiceLocator($serviceLocator);
return $helper;
}
} Now, the trick is to get your factory to be executed in preference to the one in zend-navigation. I missed something earlier: the master branch of zend-navigation actually defines only a factory named return [
'view_helpers' => [
'aliases' => [
'navigation' => Zend\View\Helper\Navigation::class,
],
'factories' => [
Zend\View\Helper\Navigation::class => 'UMS\Factory\NavigationViewFactory',
'zendviewhelpernavigation' => 'UMS\Factory\NavigationViewFactory',
],
],
]; With the changes noted above, you should be able to get it all working again; please drop me a note to let me know what happens. |
@weierophinney thanks for the suggestion for my factory and the module.config.php. With theses changes now the navigation and acl really work as expected. |
This worked too: just added this to Module.php in the Application module:
|
Sorry if I'm posting this in the wrong component issue list but I don't know exactly if the problem is with zend-view or zend-navigation or zend-servicemanager.
With zend-view 2.6.2 I'm having an error when using navigation with a custom navigation view factory (that extends class Zend\ServiceManager\FactoryInterface). The error does not happen with zend-view ~2.5.0
more explicitly:
In my
module.config.php
I have the navigation entry:if I comment the navigation view factory part the application works but I can't set acl anymore. The
NavigationViewFactory
code is:The problem occurs even if I remove all acl parts in
NavigationViewFactory
The text was updated successfully, but these errors were encountered: