Skip to content
Snippets Groups Projects
Commit 6ccfc8f9 authored by gauthierb's avatar gauthierb
Browse files

Ajout compatibilité avec les ControllerManager et FormElementManager.

parent 1bb9d8cc
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,8 @@ namespace Application\Service;
use Zend\ServiceManager\InitializerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Mvc\Controller\ControllerManager;
use Zend\Form\FormElementManager;
/**
* Transmet à une instance le fournisseur de contexte si sa classe implémente l'interface qui va bien.
......@@ -21,6 +23,9 @@ class ContextProviderAwareInitializer implements InitializerInterface
*/
public function initialize($instance, ServiceLocatorInterface $serviceLocator)
{
if ($serviceLocator instanceof ControllerManager || $serviceLocator instanceof FormElementManager) {
$serviceLocator = $serviceLocator->getServiceLocator();
}
if ($instance instanceof ContextProviderAwareInterface && !$instance instanceof ContextProvider) {
$instance->setContextProvider($serviceLocator->get('applicationContextProvider'));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment