This repository was archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
ZendViewRendererFactory override HelperPluginManager #54
Copy link
Copy link
Open
Description
- [+] I was not able to find an open or closed issue matching what I'm seeing.
- [+] This is not a question. (Questions should be asked on slack (Signup for Slack here) or our forums.)
I have Factory which retrieves PhpRenderer from Container and injects this to my AssetMiddleware which prepare js/css files and appends them to view helpers (headLink, headStyle, inlineScript, headScript). During this time PhpRenderer initialize HelperPluginManager
public function getHelperPluginManager()
{
if (null === $this->__helpers) {
$this->setHelperPluginManager(new HelperPluginManager(new ServiceManager()));
}
return $this->__helpers;
}But when I inject \Zend\Expressive\ZendView\ZendViewRenderer to my Action \Zend\Expressive\ZendView\ZendViewRendererFactory override HelperPluginManager which was initialized before
// Inject helpers
$this->injectHelpers($renderer, $container);Factory simply check if HelperPluginManager was registered in Container. There is no check if PhpRenderer already has initialized HelperPluginManager
private function retrieveHelperManager(ContainerInterface $container) : HelperPluginManager
{
if ($container->has(HelperPluginManager::class)) {
return $container->get(HelperPluginManager::class);
}
if (! $container instanceof InteropContainerInterface) {
throw new Exception\InvalidContainerException(sprintf(
'%s expects a %s instance to its constructor; however, your service'
. ' container is an instance of %s, which does not implement that'
. ' interface. Consider switching to zend-servicemanager for your'
. ' container implementation if you wish to use the zend-view renderer.',
HelperPluginManager::class,
InteropContainerInterface::class,
get_class($container)
));
}
return new HelperPluginManager($container);
}This behavior creates two different HelperPluginManager and creates many problems.
Metadata
Metadata
Assignees
Labels
No labels