Loading src/UnicaenKsup/Mvc/Service/ViewKsupStrategyFactory.php +16 −4 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace UnicaenKsup\Mvc\Service; use Application\View\Renderer\PhpRenderer; use Interop\Container\ContainerInterface; use UnicaenKsup\Service\KsupService; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; Loading @@ -11,16 +12,27 @@ use UnicaenKsup\View\Strategy\KsupStrategy; class ViewKsupStrategyFactory implements FactoryInterface { public function createService(ServiceLocatorInterface $serviceLocator) /** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * @return object|KsupStrategy */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /** @var PhpRenderer $renderer */ $renderer = $serviceLocator->get('ViewRenderer'); $renderer = $container->get('ViewRenderer'); /** @var KsupService $service */ $service = $serviceLocator->get('ksup'); $service = $container->get('ksup'); $strategy = new KsupStrategy($renderer); $strategy->setServiceKsup($service); return $strategy; } public function createService(ServiceLocatorInterface $container) { return $this($container, KsupStrategy::class); } } No newline at end of file src/UnicaenKsup/Service/KsupServiceFactory.php +18 −6 Original line number Diff line number Diff line Loading @@ -2,18 +2,25 @@ namespace UnicaenKsup\Service; use Interop\Container\ContainerInterface; use UnicaenKsup\View\Strategy\KsupStrategy; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View\Helper\BasePath; class KsupServiceFactory implements FactoryInterface { public function createService(ServiceLocatorInterface $serviceLocator) /** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * @return object|KsupService */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $service = new KsupService(); $config = $serviceLocator->get('config'); $config = $container->get('config'); if (isset($config['unicaen-ksup'])) { $config = $config['unicaen-ksup']; } else { Loading @@ -22,9 +29,14 @@ class KsupServiceFactory implements FactoryInterface $service->setConfig($config); /** @var BasePath $basePath */ $basePath = $serviceLocator->get('viewHelperManager')->get('basePath'); $basePath = $container->get('ViewHelperManager')->get('basePath'); $service->setBasePath($basePath); return $service; } public function createService(ServiceLocatorInterface $container) { return $this($container, KsupService::class); } } Loading
src/UnicaenKsup/Mvc/Service/ViewKsupStrategyFactory.php +16 −4 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace UnicaenKsup\Mvc\Service; use Application\View\Renderer\PhpRenderer; use Interop\Container\ContainerInterface; use UnicaenKsup\Service\KsupService; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; Loading @@ -11,16 +12,27 @@ use UnicaenKsup\View\Strategy\KsupStrategy; class ViewKsupStrategyFactory implements FactoryInterface { public function createService(ServiceLocatorInterface $serviceLocator) /** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * @return object|KsupStrategy */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /** @var PhpRenderer $renderer */ $renderer = $serviceLocator->get('ViewRenderer'); $renderer = $container->get('ViewRenderer'); /** @var KsupService $service */ $service = $serviceLocator->get('ksup'); $service = $container->get('ksup'); $strategy = new KsupStrategy($renderer); $strategy->setServiceKsup($service); return $strategy; } public function createService(ServiceLocatorInterface $container) { return $this($container, KsupStrategy::class); } } No newline at end of file
src/UnicaenKsup/Service/KsupServiceFactory.php +18 −6 Original line number Diff line number Diff line Loading @@ -2,18 +2,25 @@ namespace UnicaenKsup\Service; use Interop\Container\ContainerInterface; use UnicaenKsup\View\Strategy\KsupStrategy; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View\Helper\BasePath; class KsupServiceFactory implements FactoryInterface { public function createService(ServiceLocatorInterface $serviceLocator) /** * @param ContainerInterface $container * @param string $requestedName * @param array|null $options * @return object|KsupService */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $service = new KsupService(); $config = $serviceLocator->get('config'); $config = $container->get('config'); if (isset($config['unicaen-ksup'])) { $config = $config['unicaen-ksup']; } else { Loading @@ -22,9 +29,14 @@ class KsupServiceFactory implements FactoryInterface $service->setConfig($config); /** @var BasePath $basePath */ $basePath = $serviceLocator->get('viewHelperManager')->get('basePath'); $basePath = $container->get('ViewHelperManager')->get('basePath'); $service->setBasePath($basePath); return $service; } public function createService(ServiceLocatorInterface $container) { return $this($container, KsupService::class); } }