diff --git a/Module.php b/Module.php index 513539169d2bbd975d1b4766479bb5db61f30adf..c9410a695cc435d934e0c82254005eac9096c6ec 100644 --- a/Module.php +++ b/Module.php @@ -1,28 +1,29 @@ <?php + namespace UnicaenApp; -use UnicaenApp\Mouchard\MouchardService; -use UnicaenApp\Mouchard\MouchardServiceFactory; +use Locale; +use UnicaenApp\Controller\Plugin\MessengerPluginFactory; +use UnicaenApp\Controller\Plugin\Upload\UploaderPluginFactory; use UnicaenApp\Mvc\Listener\MaintenanceListener; +use UnicaenApp\Mvc\Listener\ModalListener; +use UnicaenApp\Mvc\View\Http\ExceptionStrategy; use UnicaenApp\Options\ModuleOptions; +use Zend\Console\Request as ConsoleRequest; use Zend\EventManager\EventInterface; use Zend\Http\Request as HttpRequest; -use Zend\ServiceManager\ServiceManager; +use Zend\Mvc\I18n\Translator; use Zend\ModuleManager\Feature\AutoloaderProviderInterface; use Zend\ModuleManager\Feature\BootstrapListenerInterface; use Zend\ModuleManager\Feature\ConfigProviderInterface; use Zend\ModuleManager\Feature\ControllerPluginProviderInterface; use Zend\ModuleManager\Feature\ServiceProviderInterface; -use Zend\Console\Request as ConsoleRequest; +use Zend\Mvc\Console\View\ExceptionStrategy as ConsoleExceptionStrategy; +use Zend\Mvc\View\Http\ExceptionStrategy as HttpExceptionStrategy; +use Zend\ServiceManager\ServiceManager; use Zend\Validator\AbstractValidator; -use Zend\Mvc\I18n\Translator; -use Locale; -use UnicaenApp\Mvc\View\Http\ExceptionStrategy; -use UnicaenApp\Mvc\Listener\ModalListener; use Zend\View\Helper\Navigation; use Zend\View\HelperPluginManager; -use Zend\Mvc\View\Http\ExceptionStrategy as HttpExceptionStrategy; -use Zend\Mvc\View\Console\ExceptionStrategy as ConsoleExceptionStrategy; define('__VENDOR_DIR__', dirname(dirname(__DIR__))); @@ -85,6 +86,7 @@ class Module implements $this->bootstrapSession($e); // la locale par défaut est celle du service de traduction + /** @var \Zend\I18n\Translator\Translator $translator */ $translator = $services->get('translator'); Locale::setDefault($translator->getLocale()); @@ -106,10 +108,11 @@ class Module implements $services->get('MouchardService')->createMouchardsFromConfig(); /* @var $vhm HelperPluginManager */ - $vhm = $services->get('view_helper_manager'); + $vhm = $services->get('ViewHelperManager'); /* @var $nvh Navigation */ - $nvh = $vhm->get('navigation'); + $nvh = $vhm->get('Zend\View\Helper\Navigation'); + $nvh->setServiceLocator($services); // Déclaration des plugins maison pour l'aide de vue de navigation $invokables = array( 'menuPrincipal' => 'UnicaenApp\View\Helper\Navigation\MenuPrincipal', @@ -123,7 +126,7 @@ class Module implements $nvh->getPluginManager()->setInvokableClass($key, $value); } - $eventManager->attach(new ModalListener()); + (new ModalListener())->attach($eventManager); /** @var ModuleOptions $moduleOptions */ $moduleOptions = $services->get('unicaen-app_module_options'); @@ -200,14 +203,14 @@ class Module implements 'ldapGroupService' => 'UnicaenApp\Controller\Plugin\LdapGroupServiceFactory', 'mail' => 'UnicaenApp\Controller\Plugin\MailFactory', 'appInfos' => 'UnicaenApp\Controller\Plugin\AppInfosFactory', + 'uploader' => UploaderPluginFactory::class, + 'messenger' => MessengerPluginFactory::class, ), 'invokables' => array( 'multipageForm' => 'UnicaenApp\Controller\Plugin\MultipageForm', 'modalInnerViewModel' => 'UnicaenApp\Controller\Plugin\ModalInnerViewModel', 'popoverInnerViewModel' => 'UnicaenApp\Controller\Plugin\PopoverInnerViewModel', - 'uploader' => 'UnicaenApp\Controller\Plugin\Upload\UploaderPlugin', 'confirm' => 'UnicaenApp\Controller\Plugin\ConfirmPlugin', - 'messenger' => 'UnicaenApp\Controller\Plugin\MessengerPlugin', ), ); } diff --git a/composer.json b/composer.json index 00096280d47c1f71ca95bdf6f2e63b2763d1be97..55d69df8ab015cc98aaf04f3baf1f68ded9eb8d3 100644 --- a/composer.json +++ b/composer.json @@ -4,15 +4,18 @@ "require": { "php": ">=5.6 || >=7.0", "ext-bcmath": "*", + "ext-intl": "*", "ext-ldap": "*", "zendframework/zend-http": "^2.4 || ^3.0", "zendframework/zend-mvc": "^2.4 || ^3.0", + "zendframework/zend-mvc-i18n": "^1.1", "zendframework/zend-eventmanager": "^2.4 || ^3.0", "zendframework/zend-servicemanager": "^2.4 || ^3.0", "zendframework/zend-view": "^2.4 || ^3.0", "zendframework/zend-mail": "^2.4 || ^3.0", "zendframework/zend-session": "^2.4 || ^3.0", "zendframework/zend-i18n": "^2.4 || ^3.0", + "zendframework/zend-i18n-resources": "^2.6", "zendframework/zend-navigation": "^2.4 || ^3.0", "zendframework/zend-version": "^2.4 || ^3.0", "zendframework/zend-ldap": "^2.4 || ^3.0", @@ -21,10 +24,12 @@ "zendframework/zend-config": "^2.4 || ^3.0", "zendframework/zend-serializer": "^2.4 || ^3.0", "zendframework/zend-json": "^2.4 || ^3.0", + "zendframework/zend-mvc-console": "^1.2", "doctrine/doctrine-orm-module": "*", "mpdf/mpdf": "v6.1.3" }, "require-dev": { + "zfcampus/zf-asset-manager": "^1.2", "zendframework/zend-test": "^2.4 || ^3.0", "phpunit/phpunit": "^5.6" }, diff --git a/config/module.config.php b/config/module.config.php index 444ec1002f7bb6d2a2fefa7a147c8b61185ad525..af4a297fc378cb0ed16b29a81c900581f8dd5a76 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -3,9 +3,18 @@ namespace UnicaenApp; use UnicaenApp\Controller\CacheControllerFactory; +use UnicaenApp\Controller\InstadiaControllerFactory; +use UnicaenApp\Mouchard\HistoriqueListenerFactory; +use UnicaenApp\Service\InstadiaServiceFactory; use UnicaenApp\Service\Mailer\MailerService; use UnicaenApp\Service\Mailer\MailerServiceFactory; use UnicaenApp\ServiceManager\ServiceLocatorAwareInitializer; +use UnicaenApp\View\Helper\HeadLinkFactory; +use UnicaenApp\View\Helper\HeadScriptFactory; +use UnicaenApp\View\Helper\InlineScriptFactory; +use UnicaenApp\View\Helper\InstadiaViewHelperFactory; +use UnicaenApp\View\Helper\MessageCollectorHelperFactory; +use UnicaenApp\View\Helper\Upload\UploaderHelperFactory; return [ 'asset_manager' => [ @@ -20,7 +29,7 @@ return [ // Base “route”, which describes the base match needed, the root of the tree 'home' => [ // The Literal route is for doing exact matching of the URI path - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/', 'defaults' => [ @@ -31,7 +40,7 @@ return [ ], // A propos 'apropos' => [ - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/apropos', 'defaults' => [ @@ -43,7 +52,7 @@ return [ ], // Contact 'contact' => [ - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/contact', 'defaults' => [ @@ -55,7 +64,7 @@ return [ ], // Plan de navigation 'plan' => [ - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/plan', 'defaults' => [ @@ -67,7 +76,7 @@ return [ ], // Mentions légales 'mentions-legales' => [ - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/mentions-legales', 'defaults' => [ @@ -79,7 +88,7 @@ return [ ], // Informatique et libertés 'il' => [ - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/informatique-et-libertes', 'defaults' => [ @@ -91,7 +100,7 @@ return [ ], // Rafraîchissement de la session 'refresh-session' => [ - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/refresh-session', 'defaults' => [ @@ -133,7 +142,7 @@ return [ ], ], 'cache' => [ - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => [ 'route' => '/cache', 'defaults' => [ @@ -143,7 +152,7 @@ return [ 'may_terminate' => false, 'child_routes' => [ 'js' => [ - 'type' => 'Zend\Mvc\Router\Http\Segment', + 'type' => 'Segment', 'options' => [ 'route' => '/js[/:version]', 'defaults' => [ @@ -153,7 +162,7 @@ return [ 'may_terminate' => true, ], 'css' => [ - 'type' => 'Zend\Mvc\Router\Http\Segment', + 'type' => 'Segment', 'options' => [ 'route' => '/css[/:version]', 'defaults' => [ @@ -259,6 +268,9 @@ return [ 'MouchardCompleterMvc' => 'UnicaenApp\Mouchard\MouchardCompleterMvcFactory', MailerService::class => MailerServiceFactory::class, + + 'UnicaenApp\HistoriqueListener' => HistoriqueListenerFactory::class, + 'instadia' => InstadiaServiceFactory::class, ], 'shared' => [ 'MouchardListenerErrorHandler' => false, @@ -271,8 +283,6 @@ return [ 'MouchardCompleterMvc' => false, ], 'invokables' => [ - 'UnicaenApp\HistoriqueListener' => 'UnicaenApp\ORM\Event\Listeners\HistoriqueListener', - 'instadia' => 'UnicaenApp\Service\InstadiaService', ], 'abstract_factories' => [ // 'UnicaenApp\Service\Doctrine\MultipleDbAbstractFactory', @@ -307,6 +317,12 @@ return [ 'messenger' => 'UnicaenApp\View\Helper\MessengerFactory', 'queryParams' => View\Helper\QueryParamsHelperFactory::class, 'formControlGroup' => Form\View\Helper\FormControlGroupFactory::class, + 'headLink' => HeadLinkFactory::class, + 'headScript' => HeadScriptFactory::class, + 'inlineScript' => InlineScriptFactory::class, + 'instadia' => InstadiaViewHelperFactory::class, + 'messageCollector' => MessageCollectorHelperFactory::class, + 'Uploader' => UploaderHelperFactory::class, ], 'invokables' => [ 'appConnection' => 'UnicaenApp\View\Helper\AppConnection', @@ -325,17 +341,10 @@ return [ 'formLdapPeople' => 'UnicaenApp\Form\View\Helper\FormLdapPeople', 'formErrors' => 'UnicaenApp\Form\View\Helper\FormErrors', 'form' => 'UnicaenApp\Form\View\Helper\Form', - 'messageCollector' => 'UnicaenApp\View\Helper\MessageCollectorHelper', - /* Nouvelles aides de vue qui surchargent les anciennent pour exploiter des directives de configuration */ - 'headScript' => 'UnicaenApp\View\Helper\HeadScript', - 'inlineScript' => 'UnicaenApp\View\Helper\InlineScript', - 'headLink' => 'UnicaenApp\View\Helper\HeadLink', - 'Uploader' => 'UnicaenApp\View\Helper\Upload\UploaderHelper', 'formAdvancedMultiCheckbox' => 'UnicaenApp\Form\View\Helper\FormAdvancedMultiCheckbox', 'historique' => 'UnicaenApp\View\Helper\HistoriqueViewHelper', 'tabajax' => 'UnicaenApp\View\Helper\TabAjax\TabAjaxViewHelper', 'tag' => 'UnicaenApp\View\Helper\TagViewHelper', - 'instadia' => 'UnicaenApp\View\Helper\InstadiaViewHelper', ], 'initializers' => [ 'UnicaenApp\Service\EntityManagerAwareInitializer', @@ -364,13 +373,13 @@ return [ 'controllers' => [ 'invokables' => [ 'UnicaenApp\Controller\Application' => 'UnicaenApp\Controller\ApplicationController', - 'UnicaenApp\Controller\Instadia' => 'UnicaenApp\Controller\InstadiaController', ], 'initializers' => [ 'UnicaenApp\Service\EntityManagerAwareInitializer', ], 'factories' => [ 'UnicaenApp\Controller\Cache' => CacheControllerFactory::class, + 'UnicaenApp\Controller\Instadia' => InstadiaControllerFactory::class, ] ], 'doctrine' => [ diff --git a/src/UnicaenApp/Controller/ApplicationController.php b/src/UnicaenApp/Controller/ApplicationController.php index ce69de6d7488101e31e00a119cf93773eed983f6..718501af313c65b0bae9278f18fe31deb5c7f9bc 100644 --- a/src/UnicaenApp/Controller/ApplicationController.php +++ b/src/UnicaenApp/Controller/ApplicationController.php @@ -40,35 +40,6 @@ class ApplicationController extends AbstractActionController exit; } -// public function menuSecondaireAction() -// { -// $pagesConfig = $this->getServiceLocator()->get('config')['navigation']['default']; -// $container = new Navigation($pagesConfig); -// -// $json = $this->params()->fromQuery('route-match'); -// $routeMatchElements = Json::decode($json, Json::TYPE_ARRAY); -// $routeMatchElements = [ -// '__NAMESPACE__' => 'Application\Controller', -// 'controller' => 'Application\Controller\These', -// 'action' => 'identite', -// 'these' => '28498', -// '__CONTROLLER__' => 'These', -// 'matchedRouteName' => 'these/identite' -// ]; -// -// $matchedRouteName = $routeMatchElements['matchedRouteName']; -// unset($routeMatchElements['matchedRouteName']); -// $routeMatch = new RouteMatch($routeMatchElements); -// $routeMatch->setMatchedRouteName($matchedRouteName); -// -// var_dump($routeMatchElements, $routeMatch); -// -// return [ -// 'routeMatch' => $routeMatch, -// 'container' => $container, -// ]; -// } - public function testEnvoiMailAction() { $app = $this->appInfos()->getNom(); diff --git a/src/UnicaenApp/Controller/CacheController.php b/src/UnicaenApp/Controller/CacheController.php index 8ab408e632432f67248590c7b668adc057bad809..7cf5b367ce4f43dade733c2d10d1005bd5f1660e 100644 --- a/src/UnicaenApp/Controller/CacheController.php +++ b/src/UnicaenApp/Controller/CacheController.php @@ -1,13 +1,11 @@ <?php namespace UnicaenApp\Controller; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; use Zend\Http\Header\CacheControl; use Zend\Http\Header\ContentType; use Zend\Http\Header\Expires; use Zend\Http\Header\Pragma; use Zend\Mvc\Controller\AbstractActionController; -use Zend\ServiceManager\ServiceLocatorAwareTrait; use Zend\Stdlib\ResponseInterface as Response; @@ -15,9 +13,17 @@ use Zend\Stdlib\ResponseInterface as Response; * * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> */ -class CacheController extends AbstractActionController implements ServiceLocatorAwareInterface +class CacheController extends AbstractActionController { - use ServiceLocatorAwareTrait; + private $config = []; + + /** + * @param array $config + */ + public function setConfig(array $config) + { + $this->config = $config; + } public function jsAction() { @@ -88,7 +94,7 @@ class CacheController extends AbstractActionController implements ServiceLocator { $files = []; - $config = $this->getServiceLocator()->get('config'); + $config = $this->config; $publicFiles = isset($config['public_files']) ? $config['public_files'] : []; $jsFiles = isset($publicFiles['inline_scripts']) ? $publicFiles['inline_scripts'] : []; @@ -108,7 +114,7 @@ class CacheController extends AbstractActionController implements ServiceLocator { $files = []; - $config = $this->getServiceLocator()->get('config'); + $config = $this->config; $publicFiles = isset($config['public_files']) ? $config['public_files'] : []; $cssFiles = isset($publicFiles['stylesheets']) ? $publicFiles['stylesheets'] : []; diff --git a/src/UnicaenApp/Controller/CacheControllerFactory.php b/src/UnicaenApp/Controller/CacheControllerFactory.php index 59b3d8ffac915473a0a56c94672c4089ade8a4a8..3a6defc4f4d26fdad9d936d0eefa921dd94b8e36 100644 --- a/src/UnicaenApp/Controller/CacheControllerFactory.php +++ b/src/UnicaenApp/Controller/CacheControllerFactory.php @@ -14,8 +14,7 @@ class CacheControllerFactory { $controller = new CacheController(); - // todo: abandonner l'injection du service locator, svp! - $controller->setServiceLocator($cm->getServiceLocator()); + $controller->setConfig($cm->get('config')); return $controller; } diff --git a/src/UnicaenApp/Controller/InstadiaControllerFactory.php b/src/UnicaenApp/Controller/InstadiaControllerFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..c43090a2f885679bf0ea9f3a23cfb899ff6ee998 --- /dev/null +++ b/src/UnicaenApp/Controller/InstadiaControllerFactory.php @@ -0,0 +1,25 @@ +<?php + +namespace UnicaenApp\Controller; + +use UnicaenApp\Service\InstadiaService; +use Zend\Mvc\Controller\ControllerManager; + +class InstadiaControllerFactory +{ + /** + * @param ControllerManager $cm + * @return InstadiaController + */ + public function __invoke(ControllerManager $cm) + { + $controller = new InstadiaController(); + + /** @var InstadiaService $instadiaService */ + $instadiaService = $cm->get('instadia'); + + $controller->setServiceInstadia($instadiaService); + + return $controller; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/Controller/Plugin/AppInfosFactory.php b/src/UnicaenApp/Controller/Plugin/AppInfosFactory.php index 2ec339013d2d64611d614fede4c291d570adccc7..6cf14c7b39fbc29986611aa7177fcd41320c8308 100644 --- a/src/UnicaenApp/Controller/Plugin/AppInfosFactory.php +++ b/src/UnicaenApp/Controller/Plugin/AppInfosFactory.php @@ -2,6 +2,8 @@ namespace UnicaenApp\Controller\Plugin; +use Interop\Container\ContainerInterface; +use UnicaenApp\Options\ModuleOptions; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,16 +14,15 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class AppInfosFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $helperPluginManager - * @return AppInfos - */ public function createService(ServiceLocatorInterface $helperPluginManager) { - $options = $helperPluginManager->getServiceLocator()->get('unicaen-app_module_options'); /* @var $options ModuleOptions */ - + return $this->__invoke($helperPluginManager); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $options = $container->get('unicaen-app_module_options'); /* @var $options ModuleOptions */ + return new AppInfos($options->getAppInfos()); } } \ No newline at end of file diff --git a/src/UnicaenApp/Controller/Plugin/ConfirmPlugin.php b/src/UnicaenApp/Controller/Plugin/ConfirmPlugin.php index 7b1f87f9d71d6575c8953cabedc97205ae18d2a6..c5e2e1983982c3316a1af7d41f07844a280033e8 100644 --- a/src/UnicaenApp/Controller/Plugin/ConfirmPlugin.php +++ b/src/UnicaenApp/Controller/Plugin/ConfirmPlugin.php @@ -4,8 +4,6 @@ namespace UnicaenApp\Controller\Plugin; use UnicaenApp\Form\Confirmer; use Zend\Mvc\Controller\Plugin\AbstractPlugin; -use Zend\Mvc\Controller\Plugin\Params; -use Zend\Mvc\Controller\Plugin\Url; use Zend\View\Model\ViewModel; /** diff --git a/src/UnicaenApp/Controller/Plugin/LdapGroupServiceFactory.php b/src/UnicaenApp/Controller/Plugin/LdapGroupServiceFactory.php index 0e450b2ba4a507da3dac8303ac205be8c4abbbfe..db7c8f7a86dd9ad59f6f301dbe9c3aacdf03f5b9 100644 --- a/src/UnicaenApp/Controller/Plugin/LdapGroupServiceFactory.php +++ b/src/UnicaenApp/Controller/Plugin/LdapGroupServiceFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Controller\Plugin; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,14 +13,13 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class LdapGroupServiceFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $pluginManager - * @return LdapGroupService - */ public function createService(ServiceLocatorInterface $pluginManager) { - return new LdapGroupService($pluginManager->getServiceLocator()->get('ldap_group_service')); + return $this->__invoke($pluginManager, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + return new LdapGroupService($container->get('ldap_group_service')); } } \ No newline at end of file diff --git a/src/UnicaenApp/Controller/Plugin/LdapPeopleServiceFactory.php b/src/UnicaenApp/Controller/Plugin/LdapPeopleServiceFactory.php index 9ff303306480eca2220232417f94fb2875f8a5d7..13d35c950f4081251b7a993d8501f998d3617e1a 100644 --- a/src/UnicaenApp/Controller/Plugin/LdapPeopleServiceFactory.php +++ b/src/UnicaenApp/Controller/Plugin/LdapPeopleServiceFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Controller\Plugin; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,14 +13,13 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class LdapPeopleServiceFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $pluginManager - * @return LdapPeopleService - */ public function createService(ServiceLocatorInterface $pluginManager) { - return new LdapPeopleService($pluginManager->getServiceLocator()->get('ldap_people_service')); + return $this->__invoke($pluginManager, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + return new LdapPeopleService($container->get('ldap_people_service')); } } \ No newline at end of file diff --git a/src/UnicaenApp/Controller/Plugin/LdapStructureServiceFactory.php b/src/UnicaenApp/Controller/Plugin/LdapStructureServiceFactory.php index 7b1a73542650b6c3824fe4977afc325dbb6af3de..549cb11315b3091168c920d8e0014eefc85f5432 100644 --- a/src/UnicaenApp/Controller/Plugin/LdapStructureServiceFactory.php +++ b/src/UnicaenApp/Controller/Plugin/LdapStructureServiceFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Controller\Plugin; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,14 +13,13 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class LdapStructureServiceFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $pluginManager - * @return LdapStructureService - */ public function createService(ServiceLocatorInterface $pluginManager) { - return new LdapStructureService($pluginManager->getServiceLocator()->get('ldap_structure_service')); + return $this->__invoke($pluginManager, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + return new LdapStructureService($container->get('ldap_structure_service')); } } \ No newline at end of file diff --git a/src/UnicaenApp/Controller/Plugin/MailFactory.php b/src/UnicaenApp/Controller/Plugin/MailFactory.php index 9729f73f20640b1d7d6253140b9631f321a3453f..dc7a000b82cfb75534fd8992e6219277f987c11e 100644 --- a/src/UnicaenApp/Controller/Plugin/MailFactory.php +++ b/src/UnicaenApp/Controller/Plugin/MailFactory.php @@ -19,7 +19,7 @@ class MailFactory public function __invoke(PluginManager $pluginManager) { /** @var MailerService $mailerService */ - $mailerService = $pluginManager->getServiceLocator()->get(MailerService::class); + $mailerService = $pluginManager->get(MailerService::class); $plugin = new Mail(); $plugin->setMailerService($mailerService); diff --git a/src/UnicaenApp/Controller/Plugin/MessengerPlugin.php b/src/UnicaenApp/Controller/Plugin/MessengerPlugin.php index cb4842fa2653300709c95f13137915466e8ac7a0..b8c507bc744dbab14aaf380cca28d9e462ff8ab4 100644 --- a/src/UnicaenApp/Controller/Plugin/MessengerPlugin.php +++ b/src/UnicaenApp/Controller/Plugin/MessengerPlugin.php @@ -4,8 +4,6 @@ namespace UnicaenApp\Controller\Plugin; use UnicaenApp\Traits\MessageAwareInterface; use UnicaenApp\Traits\MessageAwareTrait; use UnicaenApp\View\Helper\Messenger as MessengerViewHelper; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; use Zend\Mvc\Controller\Plugin\AbstractPlugin; /** @@ -16,9 +14,8 @@ use Zend\Mvc\Controller\Plugin\AbstractPlugin; * * @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr> */ -class MessengerPlugin extends AbstractPlugin implements ServiceLocatorAwareInterface, MessageAwareInterface +class MessengerPlugin extends AbstractPlugin implements MessageAwareInterface { - use ServiceLocatorAwareTrait; use MessageAwareTrait; /** @@ -27,27 +24,20 @@ class MessengerPlugin extends AbstractPlugin implements ServiceLocatorAwareInter protected $messengerViewHelper; /** - * Helper entry point. - * - * @return MessengerViewHelper + * @param MessengerViewHelper $messengerViewHelper */ - public function __invoke() + public function setMessengerViewHelper(MessengerViewHelper $messengerViewHelper) { - return $this->getMessengerViewHelper(); + $this->messengerViewHelper = $messengerViewHelper; } - + /** + * Helper entry point. + * * @return MessengerViewHelper */ - private function getMessengerViewHelper() + public function __invoke() { - if (null === $this->messengerViewHelper) { - $sl = $this->getServiceLocator()->getServiceLocator(); - $this->messengerViewHelper = $sl->get('viewhelpermanager')->get('messenger'); - } - return $this->messengerViewHelper; } - - } \ No newline at end of file diff --git a/src/UnicaenApp/Controller/Plugin/MessengerPluginFactory.php b/src/UnicaenApp/Controller/Plugin/MessengerPluginFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..27280d55da188d1e5a30b3953fa21a6169e20338 --- /dev/null +++ b/src/UnicaenApp/Controller/Plugin/MessengerPluginFactory.php @@ -0,0 +1,31 @@ +<?php + +namespace UnicaenApp\Controller\Plugin; + +use Interop\Container\ContainerInterface; +use UnicaenApp\View\Helper\Messenger; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +/** + * + * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> + */ +class MessengerPluginFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $helperPluginManager) + { + return $this->__invoke($helperPluginManager, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + /** @var Messenger $messengerViewHelper */ + $messengerViewHelper = $container->get('viewhelpermanager')->get('messenger'); + + $plugin = new MessengerPlugin(); + $plugin->setMessengerViewHelper($messengerViewHelper); + + return $plugin; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/Controller/Plugin/MultipageForm.php b/src/UnicaenApp/Controller/Plugin/MultipageForm.php index 4d6e3801a1ea94d34946a080f1af83840ae1f5af..d9c4bcc63d77a267174f47706d3bca6151be2c59 100644 --- a/src/UnicaenApp/Controller/Plugin/MultipageForm.php +++ b/src/UnicaenApp/Controller/Plugin/MultipageForm.php @@ -8,7 +8,8 @@ use Zend\Http\Response; use Zend\InputFilter\InputFilter; use Zend\InputFilter\InputFilterProviderInterface; use Zend\Mvc\Controller\Plugin\AbstractPlugin; -use Zend\Mvc\Router\Http\RouteMatch; +use Zend\Mvc\Plugin\Prg\PostRedirectGet; +use Zend\Router\Http\RouteMatch; use Zend\Session\Container; /** @@ -213,7 +214,7 @@ class MultipageForm extends AbstractPlugin { // post redirect get pattern if required if ($this->getUsePostRedirectGet()) { - $prg = $this->getController()->plugin('prg'); /* @var $prg \Zend\Mvc\Controller\Plugin\PostRedirectGet */ + $prg = $this->getController()->plugin('prg'); /* @var $prg PostRedirectGet */ $this->prgResult = $prg(); if ($this->prgResult instanceof Response) { // returned a response to redirect us diff --git a/src/UnicaenApp/Controller/Plugin/Upload/UploaderPlugin.php b/src/UnicaenApp/Controller/Plugin/Upload/UploaderPlugin.php index e47fb2ef12da1a324bb690b32bc849be15dc798a..f38a3566635c74d770b251e7e6a03db429a50fe1 100644 --- a/src/UnicaenApp/Controller/Plugin/Upload/UploaderPlugin.php +++ b/src/UnicaenApp/Controller/Plugin/Upload/UploaderPlugin.php @@ -3,10 +3,8 @@ namespace UnicaenApp\Controller\Plugin\Upload; use UnicaenApp\Util; -use Zend\Form\FormElementManager; +use Zend\Form\FormElementManager\FormElementManagerV3Polyfill; use Zend\Mvc\Controller\Plugin\AbstractPlugin; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; use Zend\View\Model\JsonModel; /** @@ -14,10 +12,8 @@ use Zend\View\Model\JsonModel; * * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> */ -class UploaderPlugin extends AbstractPlugin implements ServiceLocatorAwareInterface +class UploaderPlugin extends AbstractPlugin { - use ServiceLocatorAwareTrait; - /** * Magic method. * @@ -102,11 +98,22 @@ class UploaderPlugin extends AbstractPlugin implements ServiceLocatorAwareInterf public function getForm() { if (null === $this->form) { - /** @var FormElementManager $pluginManager */ - $pluginManager = $this->getServiceLocator(); - $this->form = $pluginManager->getServiceLocator()->get('form_element_manager')->get('UploadForm'); + $this->form = $this->formElementManager->get('UploadForm'); } return $this->form; } + + /** + * @var FormElementManagerV3Polyfill + */ + private $formElementManager; + + /** + * @param FormElementManagerV3Polyfill $formElementManager + */ + public function setFormElementManager(FormElementManagerV3Polyfill $formElementManager) + { + $this->formElementManager = $formElementManager; + } } \ No newline at end of file diff --git a/src/UnicaenApp/Controller/Plugin/Upload/UploaderPluginFactory.php b/src/UnicaenApp/Controller/Plugin/Upload/UploaderPluginFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..557197765fdf4de10073bf59e564025c4bd8b173 --- /dev/null +++ b/src/UnicaenApp/Controller/Plugin/Upload/UploaderPluginFactory.php @@ -0,0 +1,31 @@ +<?php + +namespace UnicaenApp\Controller\Plugin\Upload; + +use Interop\Container\ContainerInterface; +use Zend\Form\FormElementManager\FormElementManagerV3Polyfill; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +/** + * + * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> + */ +class UploaderPluginFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $helperPluginManager) + { + return $this->__invoke($helperPluginManager, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + /** @var FormElementManagerV3Polyfill $fem */ + $fem = $container->get('form_element_manager'); + + $plugin = new UploaderPlugin(); + $plugin->setFormElementManager($fem); + + return $plugin; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/Form/AbstractForm.php b/src/UnicaenApp/Form/AbstractForm.php index 398eeee08b31677fbf560bd5ab4495a77b18563d..d054d2dd60b77147bceea750aac639850dc7dd9f 100644 --- a/src/UnicaenApp/Form/AbstractForm.php +++ b/src/UnicaenApp/Form/AbstractForm.php @@ -2,12 +2,12 @@ namespace UnicaenApp\Form; +use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; +use UnicaenApp\ServiceManager\ServiceLocatorAwareTrait; use Zend\Form\Form; use Zend\Http\Request; use Zend\InputFilter\InputFilterProviderInterface; -use Zend\Mvc\Controller\Plugin\FlashMessenger; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; +use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger; abstract class AbstractForm extends Form implements ServiceLocatorAwareInterface, InputFilterProviderInterface @@ -25,22 +25,12 @@ abstract class AbstractForm extends Form implements ServiceLocatorAwareInterface private $exception; - /** - * Generates a url given the name of a route. - * - * @see Zend\Mvc\Router\RouteInterface::assemble() - * - * @param string $name Name of the route - * @param array $params Parameters for the link - * @param array|Traversable $options Options for the route - * @param bool $reuseMatchedParams Whether to reuse matched parameters - * - * @return string Url For the link href attribute + * {@inheritdoc} */ protected function getUrl($name = null, $params = [], $options = [], $reuseMatchedParams = false) { - $url = $this->getServiceLocator()->getServiceLocator()->get('viewhelpermanager')->get('url'); + $url = $this->serviceLocator->get('viewhelpermanager')->get('url'); /* @var $url \Zend\View\Helper\Url */ return $url->__invoke($name, $params, $options, $reuseMatchedParams); @@ -146,7 +136,7 @@ abstract class AbstractForm extends Form implements ServiceLocatorAwareInterface private function getControllerPluginFlashMessenger() { if (!$this->controllerPluginFlashMessenger) { - $this->controllerPluginFlashMessenger = $this->getServiceLocator()->getServiceLocator()->get('ControllerPluginManager')->get('flashMessenger'); + $this->controllerPluginFlashMessenger = $this->serviceLocator->get('ControllerPluginManager')->get('flashMessenger'); } return $this->controllerPluginFlashMessenger; diff --git a/src/UnicaenApp/Hydrator/Strategy/DateStrategy.php b/src/UnicaenApp/Hydrator/Strategy/DateStrategy.php index 60cfaa9c4eb40522d3873169cd9870e435286c40..ed3c1b993863df9b991a35fa4ae26500416d4126 100644 --- a/src/UnicaenApp/Hydrator/Strategy/DateStrategy.php +++ b/src/UnicaenApp/Hydrator/Strategy/DateStrategy.php @@ -2,7 +2,7 @@ namespace UnicaenApp\Hydrator\Strategy; -use Zend\Stdlib\Hydrator\Strategy\StrategyInterface; +use Zend\Hydrator\Strategy\StrategyInterface; use UnicaenApp\Form\Element\Date as DateElement; /** diff --git a/src/UnicaenApp/Mapper/Ldap/AbstractMapperFactory.php b/src/UnicaenApp/Mapper/Ldap/AbstractMapperFactory.php index 73d95374e0ed7233b0c2bd91a66a6add9efcc3b9..bfee24d2f02e970090c4ca77a91fbce052c2a7af 100644 --- a/src/UnicaenApp/Mapper/Ldap/AbstractMapperFactory.php +++ b/src/UnicaenApp/Mapper/Ldap/AbstractMapperFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mapper\Ldap; +use Interop\Container\ContainerInterface; use UnicaenApp\Options\ModuleOptions; use Zend\Ldap\Ldap; use Zend\ServiceManager\FactoryInterface; @@ -19,16 +20,10 @@ abstract class AbstractMapperFactory implements FactoryInterface */ protected $mapperClass; - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return static - */ - public function createService(ServiceLocatorInterface $serviceLocator) + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /** @var ModuleOptions $ldapParams */ - $ldapParams = $serviceLocator->get('unicaen-app_module_options'); + $ldapParams = $container->get('unicaen-app_module_options'); $ldapConfig = $ldapParams->getLdap(); $className = $this->mapperClass; @@ -36,9 +31,15 @@ abstract class AbstractMapperFactory implements FactoryInterface return new $className($this->createLdap($ldapConfig), $ldapConfig); } + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + /** * @param array $ldapConfig * @return Ldap + * @throws \Zend\Ldap\Exception\LdapException */ protected function createLdap(array $ldapConfig) { diff --git a/src/UnicaenApp/Message/MessageConfigFactory.php b/src/UnicaenApp/Message/MessageConfigFactory.php index 9f9df46ee5ef2273b06efa9d9fa0003ccf43aa41..3f08c9db4b537571c433c0eaf6b7fb9ee2d7e8b0 100644 --- a/src/UnicaenApp/Message/MessageConfigFactory.php +++ b/src/UnicaenApp/Message/MessageConfigFactory.php @@ -8,6 +8,7 @@ namespace UnicaenApp\Message; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -16,17 +17,16 @@ class MessageConfigFactory implements FactoryInterface private $serviceLocator; private $messageConfigNormalizer; - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MessageConfig - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $this->serviceLocator = $serviceLocator; + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $this->serviceLocator = $container; - $appConfig = $serviceLocator->get('Config'); + $appConfig = $container->get('Config'); $config = isset($appConfig['message']) ? $appConfig['message'] : []; $normalizer = $this->getMessageConfigNormalizer()->setConfig($config); diff --git a/src/UnicaenApp/Message/MessageRepositoryFactory.php b/src/UnicaenApp/Message/MessageRepositoryFactory.php index f95253520f67a4203923723a03228d4bf5805266..e9bc8b78da995de4456141a269f83d677a1e6685 100644 --- a/src/UnicaenApp/Message/MessageRepositoryFactory.php +++ b/src/UnicaenApp/Message/MessageRepositoryFactory.php @@ -8,20 +8,20 @@ namespace UnicaenApp\Message; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; class MessageRepositoryFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MessageRepository - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $messageConfig = $serviceLocator->get('MessageConfig'); /** @var MessageConfig $messageConfig */ + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $messageConfig = $container->get('MessageConfig'); /** @var MessageConfig $messageConfig */ $messages = Message::createInstancesFromConfig($messageConfig->getMessagesConfig()); $service = new MessageRepository($messages); diff --git a/src/UnicaenApp/Message/MessageServiceFactory.php b/src/UnicaenApp/Message/MessageServiceFactory.php index aae1ee2bd593647c98901fe426041d0e16acb6cc..25cacc5e78d3083cd0047885f753272c7a0d3b22 100644 --- a/src/UnicaenApp/Message/MessageServiceFactory.php +++ b/src/UnicaenApp/Message/MessageServiceFactory.php @@ -8,20 +8,20 @@ namespace UnicaenApp\Message; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; class MessageServiceFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MessageService - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $messageRepository = $serviceLocator->get('MessageRepository'); /** @var MessageRepository $messageRepository */ + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $messageRepository = $container->get('MessageRepository'); /** @var MessageRepository $messageRepository */ $service = new MessageService($messageRepository); diff --git a/src/UnicaenApp/Message/View/Helper/MessageHelperFactory.php b/src/UnicaenApp/Message/View/Helper/MessageHelperFactory.php index 40954835d0d44d65f93b8c62fd6a7f850d3ada41..e4c6f18dd5f2af55ecde144cfa5e35412158788c 100644 --- a/src/UnicaenApp/Message/View/Helper/MessageHelperFactory.php +++ b/src/UnicaenApp/Message/View/Helper/MessageHelperFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Message\View\Helper; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,15 +13,14 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MessageHelperFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $helperPluginManager - * @return AppInfos - */ - public function createService(ServiceLocatorInterface $helperPluginManager) + public function createService(ServiceLocatorInterface $serviceLocator) { - $messageService = $helperPluginManager->getServiceLocator()->get('MessageService'); + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $messageService = $container->get('MessageService'); return new MessageHelper($messageService); } diff --git a/src/UnicaenApp/Mouchard/MouchardCompleterHttpFactory.php b/src/UnicaenApp/Mouchard/MouchardCompleterHttpFactory.php index f67dce6521e45bd68c4d7514d2c3ba2477a17197..f53650d11f0bd79900621c12920b8ed2fb4c09c6 100644 --- a/src/UnicaenApp/Mouchard/MouchardCompleterHttpFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardCompleterHttpFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,16 +13,13 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardCompleterHttpFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MouchardCompleterHttp - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $mouchardCompleterHttp = new MouchardCompleterHttp(); + return $this->__invoke($serviceLocator, '?'); + } - return $mouchardCompleterHttp; + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + return new MouchardCompleterHttp(); } } \ No newline at end of file diff --git a/src/UnicaenApp/Mouchard/MouchardCompleterMvcFactory.php b/src/UnicaenApp/Mouchard/MouchardCompleterMvcFactory.php index 9b75b03a7d86d4ccde9851031fc7baa2879ef701..1677d365e0c736a46e9f45e15a8eb3c303903372 100644 --- a/src/UnicaenApp/Mouchard/MouchardCompleterMvcFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardCompleterMvcFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\Mvc\Application; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -13,18 +14,17 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardCompleterMvcFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MouchardCompleterMvc - */ public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $mouchardCompleterMvc = new MouchardCompleterMvc(); /* @var $application Application */ - $application = $serviceLocator->get('application'); + $application = $container->get('application'); $mouchardCompleterMvc->setApplication($application); return $mouchardCompleterMvc; diff --git a/src/UnicaenApp/Mouchard/MouchardFormaterHtmlFactory.php b/src/UnicaenApp/Mouchard/MouchardFormaterHtmlFactory.php index a3a9d7528363d1cfe4dd9e26f2348e1ba398687b..33f843016527a0a621ae836a1f7833b5788c2c0d 100644 --- a/src/UnicaenApp/Mouchard/MouchardFormaterHtmlFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardFormaterHtmlFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,16 +13,13 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardFormaterHtmlFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MouchardFormaterHtml - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $mouchardFormaterHtml = new MouchardFormaterHtml(); + return $this->__invoke($serviceLocator, '?'); + } - return $mouchardFormaterHtml; + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + return new MouchardFormaterHtml(); } } \ No newline at end of file diff --git a/src/UnicaenApp/Mouchard/MouchardListenerErrorHandlerFactory.php b/src/UnicaenApp/Mouchard/MouchardListenerErrorHandlerFactory.php index 439ea6c932398ee5e33be69dd13d7e1b3b93badc..d8260cee969c35b70bfa256984b067ccbd231552 100644 --- a/src/UnicaenApp/Mouchard/MouchardListenerErrorHandlerFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardListenerErrorHandlerFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,16 +13,13 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardListenerErrorHandlerFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MouchardListenerErrorHandler - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $mouchardListenerErrorHandler = new MouchardListenerErrorHandler(); + return $this->__invoke($serviceLocator, '?'); + } - return $mouchardListenerErrorHandler; + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + return new MouchardListenerErrorHandler(); } } \ No newline at end of file diff --git a/src/UnicaenApp/Mouchard/MouchardListenerExceptionFactory.php b/src/UnicaenApp/Mouchard/MouchardListenerExceptionFactory.php index 3d3c9c23bfa43aae70a3ab1161bfff646b46ed65..9b55004a5849d18cd9662ecb8ba6803f2d80ac64 100644 --- a/src/UnicaenApp/Mouchard/MouchardListenerExceptionFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardListenerExceptionFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\Mvc\Application; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -13,18 +14,17 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardListenerExceptionFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MouchardListenerException - */ public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $mouchardListenerException = new MouchardListenerException(); /* @var $application Application */ - $application = $serviceLocator->get('application'); + $application = $container->get('application'); if ($application){ $mouchardListenerException->setEventManager($application->getEventManager()); } diff --git a/src/UnicaenApp/Mouchard/MouchardListenerMessengerFactory.php b/src/UnicaenApp/Mouchard/MouchardListenerMessengerFactory.php index 10f54336dee30522f47eb6bb3708344009f8b002..e0f9c9f16201190ad8ed968b81dc928941dacd3c 100644 --- a/src/UnicaenApp/Mouchard/MouchardListenerMessengerFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardListenerMessengerFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\Mvc\Application; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -13,18 +14,17 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardListenerMessengerFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MouchardListenerMessenger - */ public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $mouchardListenerMessenger = new MouchardListenerMessenger(); /* @var $application Application */ - $application = $serviceLocator->get('application'); + $application = $container->get('application'); if ($application){ $mouchardListenerMessenger->setEventManager($application->getEventManager()); } diff --git a/src/UnicaenApp/Mouchard/MouchardSenderExceptionFactory.php b/src/UnicaenApp/Mouchard/MouchardSenderExceptionFactory.php index eb543af0dcbe41424bd68e6659640dabb6a8a526..6ebbbbd638e52b6e0987349abdf6cec231b1b7f2 100644 --- a/src/UnicaenApp/Mouchard/MouchardSenderExceptionFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardSenderExceptionFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,16 +13,13 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardSenderExceptionFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return $mouchardSenderException - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $mouchardSenderException = new MouchardSenderException(); + return $this->__invoke($serviceLocator, '?'); + } - return $mouchardSenderException; + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + return new MouchardSenderException(); } } \ No newline at end of file diff --git a/src/UnicaenApp/Mouchard/MouchardSenderMail.php b/src/UnicaenApp/Mouchard/MouchardSenderMail.php index 7bb58dc41ecec6878580d1ceae1d7aff0c940a30..0246e02816c58f10179fb2354bf41fdf244c5764 100644 --- a/src/UnicaenApp/Mouchard/MouchardSenderMail.php +++ b/src/UnicaenApp/Mouchard/MouchardSenderMail.php @@ -3,14 +3,13 @@ namespace UnicaenApp\Mouchard; use UnicaenApp\Controller\Plugin\Mail; -use UnicaenApp\Options\ModuleOptions; use UnicaenApp\Options\Traits\ModuleOptionsAwareTrait; use Zend\Mail\Message; -use Zend\Mime\Mime; +use Zend\Mail\Transport\Smtp; +use Zend\Mail\Transport\SmtpOptions; use Zend\Mime\Message as MimeMessage; +use Zend\Mime\Mime; use Zend\Mime\Part as MimePart; -use Zend\Mail\Transport\SmtpOptions; -use Zend\Mail\Transport\Smtp; use Zend\ServiceManager\Exception\InvalidArgumentException; /** diff --git a/src/UnicaenApp/Mouchard/MouchardSenderMailFactory.php b/src/UnicaenApp/Mouchard/MouchardSenderMailFactory.php index ed5b26fddb41b0c7c070dafa829138738e9e66b3..8cfbbffb9ce39bdf767c26e9f2373c1b0c69f0cb 100644 --- a/src/UnicaenApp/Mouchard/MouchardSenderMailFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardSenderMailFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,17 +13,16 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardSenderMailFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return MouchardSenderMail - */ public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $mouchardSenderMail = new MouchardSenderMail(); - if ($unicaenAppOptions = $serviceLocator->get('unicaen-app_module_options')){ + if ($unicaenAppOptions = $container->get('unicaen-app_module_options')){ $mouchardSenderMail->setModuleOptions($unicaenAppOptions); } diff --git a/src/UnicaenApp/Mouchard/MouchardService.php b/src/UnicaenApp/Mouchard/MouchardService.php index d6f2382565b1eea39aed58680e58186cb8aef544..84b09b3544f596ce3c2195ba0ecd3e0a68d1f833 100644 --- a/src/UnicaenApp/Mouchard/MouchardService.php +++ b/src/UnicaenApp/Mouchard/MouchardService.php @@ -2,8 +2,8 @@ namespace UnicaenApp\Mouchard; -use Zend\ServiceManager\ServiceLocatorAwareTrait; -use Zend\Stdlib\Hydrator\ClassMethods; +use UnicaenApp\ServiceManager\ServiceLocatorAwareTrait; +use Zend\Hydrator\ClassMethods; /** * Class MouchardService diff --git a/src/UnicaenApp/Mouchard/MouchardServiceFactory.php b/src/UnicaenApp/Mouchard/MouchardServiceFactory.php index 5fe0a834e160056fda6e3a8492d827bfc6f33c70..053c46555d5121c8ad72cfb8cebc8d04d1ba135c 100644 --- a/src/UnicaenApp/Mouchard/MouchardServiceFactory.php +++ b/src/UnicaenApp/Mouchard/MouchardServiceFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mouchard; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,17 +13,15 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MouchardServiceFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * - * @return MouchardService - */ public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $serviceMouchard = new MouchardService(); - $serviceMouchard->setServiceLocator($serviceLocator); + $serviceMouchard->setServiceLocator($container); return $serviceMouchard; diff --git a/src/UnicaenApp/Mvc/Listener/MaintenanceListener.php b/src/UnicaenApp/Mvc/Listener/MaintenanceListener.php index bf79deb780def9b68867ce3543f016d69bc0d151..967e31c6ed5a82478ce41a87277300c8d11464cc 100644 --- a/src/UnicaenApp/Mvc/Listener/MaintenanceListener.php +++ b/src/UnicaenApp/Mvc/Listener/MaintenanceListener.php @@ -6,7 +6,7 @@ use Zend\EventManager\EventManagerInterface; use Zend\EventManager\ListenerAggregateInterface; use Zend\EventManager\ListenerAggregateTrait; use Zend\Mvc\MvcEvent; -use Zend\Mvc\Router\Http\RouteMatch; +use Zend\Router\Http\RouteMatch; use Zend\Stdlib\ArrayUtils; class MaintenanceListener implements ListenerAggregateInterface @@ -49,14 +49,9 @@ class MaintenanceListener implements ListenerAggregateInterface } /** - * Attach one or more listeners - * - * Implementors may add an optional $priority argument; the EventManager - * implementation will pass this to the aggregate. - * - * @param EventManagerInterface $events + * {@inheritdoc} */ - public function attach(EventManagerInterface $events) + public function attach(EventManagerInterface $events, $priority = 1) { $events->attach(MvcEvent::EVENT_ROUTE, [$this, 'beforeRoute']); $events->attach(MvcEvent::EVENT_RENDER, [$this, 'beforeRendering']); diff --git a/src/UnicaenApp/Mvc/Listener/ModalListener.php b/src/UnicaenApp/Mvc/Listener/ModalListener.php index b00fe380b8c6936bf2222a7bd5160eafb2ec0073..5b336e68fe3c7beb701d8e02f7ef61edb0ba543b 100644 --- a/src/UnicaenApp/Mvc/Listener/ModalListener.php +++ b/src/UnicaenApp/Mvc/Listener/ModalListener.php @@ -60,16 +60,9 @@ class ModalListener implements ListenerAggregateInterface } /** - * Attach one or more listeners - * - * Implementors may add an optional $priority argument; the EventManager - * implementation will pass this to the aggregate. - * - * @param EventManagerInterface $events - * - * @return void + * {@inheritdoc} */ - public function attach(EventManagerInterface $events) + public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach(MvcEvent::EVENT_RENDER, array($this, 'injectModalViewModel')); } diff --git a/src/UnicaenApp/Mvc/Service/ViewCsvRendererFactory.php b/src/UnicaenApp/Mvc/Service/ViewCsvRendererFactory.php index 1c6a4cb998450ec164b659496637796ae89590a5..bbaf4601bacaad8e2d6a4e8d6328306f377d3e2b 100644 --- a/src/UnicaenApp/Mvc/Service/ViewCsvRendererFactory.php +++ b/src/UnicaenApp/Mvc/Service/ViewCsvRendererFactory.php @@ -2,24 +2,23 @@ namespace UnicaenApp\Mvc\Service; +use Interop\Container\ContainerInterface; +use UnicaenApp\View\Renderer\CsvRenderer; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -use UnicaenApp\View\Renderer\CsvRenderer; /** * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> */ class ViewCsvRendererFactory implements FactoryInterface { - /** - * Create and return the Csv view renderer - * - * @param ServiceLocatorInterface $serviceLocator - * @return CsvRenderer - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $csvRenderer = new CsvRenderer(); - return $csvRenderer; + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + return new CsvRenderer(); } } diff --git a/src/UnicaenApp/Mvc/Service/ViewCsvStrategyFactory.php b/src/UnicaenApp/Mvc/Service/ViewCsvStrategyFactory.php index a1e76315b771933a35e25bde4ad8761e9843920c..91b0aae22284f420418664367eabbf74b80ff773 100644 --- a/src/UnicaenApp/Mvc/Service/ViewCsvStrategyFactory.php +++ b/src/UnicaenApp/Mvc/Service/ViewCsvStrategyFactory.php @@ -2,27 +2,23 @@ namespace UnicaenApp\Mvc\Service; +use Interop\Container\ContainerInterface; +use UnicaenApp\View\Strategy\CsvStrategy; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -use UnicaenApp\View\Strategy\CsvStrategy; class ViewCsvStrategyFactory implements FactoryInterface { - /** - * Create and return the CSV view strategy - * - * Retrieves the ViewCsvRenderer service from the service locator, and - * injects it into the constructor for the CSV strategy. - * - * It then attaches the strategy to the View service, at a priority of 100. - * - * @param ServiceLocatorInterface $serviceLocator - * @return CsvStrategy - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $csvRenderer = $serviceLocator->get('ViewCsvRenderer'); + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $csvRenderer = $container->get('ViewCsvRenderer'); $csvStrategy = new CsvStrategy($csvRenderer); + return $csvStrategy; } } diff --git a/src/UnicaenApp/Mvc/Service/ViewXmlRendererFactory.php b/src/UnicaenApp/Mvc/Service/ViewXmlRendererFactory.php index affe616183d5bbb9076fa3682d8aae7027c4fa64..d74820890005ef09d4d8421a6a87b1a70fc87e49 100644 --- a/src/UnicaenApp/Mvc/Service/ViewXmlRendererFactory.php +++ b/src/UnicaenApp/Mvc/Service/ViewXmlRendererFactory.php @@ -2,24 +2,25 @@ namespace UnicaenApp\Mvc\Service; +use Interop\Container\ContainerInterface; +use UnicaenApp\View\Renderer\XmlRenderer; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -use UnicaenApp\View\Renderer\XmlRenderer; /** * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> */ class ViewXmlRendererFactory implements FactoryInterface { - /** - * Create and return the Xml view renderer - * - * @param ServiceLocatorInterface $serviceLocator - * @return XmlRenderer - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $xmlRenderer = $serviceLocator->get('view_manager')->getRenderer(); + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $xmlRenderer = $container->get('view_manager')->getRenderer(); + return $xmlRenderer; } } diff --git a/src/UnicaenApp/Mvc/Service/ViewXmlStrategyFactory.php b/src/UnicaenApp/Mvc/Service/ViewXmlStrategyFactory.php index 046044afe80a0162308217e4baec34d6ad6ef394..58aee143b2ca97ea817b1156154442a1a73a2a3a 100644 --- a/src/UnicaenApp/Mvc/Service/ViewXmlStrategyFactory.php +++ b/src/UnicaenApp/Mvc/Service/ViewXmlStrategyFactory.php @@ -2,29 +2,25 @@ namespace UnicaenApp\Mvc\Service; +use Interop\Container\ContainerInterface; use UnicaenApp\View\Renderer\XmlRenderer; +use UnicaenApp\View\Strategy\XmlStrategy; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -use UnicaenApp\View\Strategy\XmlStrategy; class ViewXmlStrategyFactory implements FactoryInterface { - /** - * Create and return the XML view strategy - * - * Retrieves the ViewXmlRenderer service from the service locator, and - * injects it into the constructor for the XML strategy. - * - * It then attaches the strategy to the View service, at a priority of 100. - * - * @param ServiceLocatorInterface $serviceLocator - * @return XmlStrategy - */ public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /** @var XmlRenderer $xmlRenderer */ - $xmlRenderer = $serviceLocator->get('ViewXmlRenderer'); + $xmlRenderer = $container->get('ViewXmlRenderer'); $xmlStrategy = new XmlStrategy($xmlRenderer); + return $xmlStrategy; } } diff --git a/src/UnicaenApp/ORM/Event/Listeners/HistoriqueListener.php b/src/UnicaenApp/ORM/Event/Listeners/HistoriqueListener.php index 4dd0d7276c39fe80fbe3c29d505bb5a43aed8a3d..b26a6dccc26f681f5b19ac0e404398b745fc0c8e 100644 --- a/src/UnicaenApp/ORM/Event/Listeners/HistoriqueListener.php +++ b/src/UnicaenApp/ORM/Event/Listeners/HistoriqueListener.php @@ -9,8 +9,7 @@ use Doctrine\ORM\Events; use RuntimeException; use UnicaenApp\Entity\HistoriqueAwareInterface; use UnicaenAuth\Entity\Db\AbstractUser; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; +use Zend\Authentication\AuthenticationService; /** * Listener Doctrine. @@ -23,15 +22,26 @@ use Zend\ServiceManager\ServiceLocatorAwareTrait; * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> * @see HistoriqueAwareInterface */ -class HistoriqueListener implements EventSubscriber, ServiceLocatorAwareInterface +class HistoriqueListener implements EventSubscriber { - use ServiceLocatorAwareTrait; + /** + * @var AuthenticationService + */ + private $authenticationService; /** * @var mixed */ protected $identity; + /** + * @param AuthenticationService $authenticationService + */ + public function setAuthenticationService(AuthenticationService $authenticationService) + { + $this->authenticationService = $authenticationService; + } + /** * @param LifecycleEventArgs $args * @throws RuntimeException Aucun utilisateur disponible pour en faire l'auteur de la création/modification @@ -137,7 +147,7 @@ class HistoriqueListener implements EventSubscriber, ServiceLocatorAwareInterfac public function getIdentity() { if (null === $this->identity) { - $authenticationService = $this->getServiceLocator()->get('Zend\Authentication\AuthenticationService'); + $authenticationService = $this->authenticationService; if ($authenticationService->hasIdentity()) { $this->identity = $authenticationService->getIdentity(); } diff --git a/src/UnicaenApp/ORM/Event/Listeners/HistoriqueListenerFactory.php b/src/UnicaenApp/ORM/Event/Listeners/HistoriqueListenerFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..7dd4577e96d773352bfa69f14b519919dc75e13f --- /dev/null +++ b/src/UnicaenApp/ORM/Event/Listeners/HistoriqueListenerFactory.php @@ -0,0 +1,33 @@ +<?php + +namespace UnicaenApp\Mouchard; + +use Interop\Container\ContainerInterface; +use UnicaenApp\ORM\Event\Listeners\HistoriqueListener; +use Zend\Authentication\AuthenticationService; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +/** + * Description of MouchardServiceFactory + * + * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> + */ +class HistoriqueListenerFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + /** @var AuthenticationService $authenticationService */ + $authenticationService = $container->get('Zend\Authentication\AuthenticationService'); + + $listener = new HistoriqueListener(); + $listener->setAuthenticationService($authenticationService); + + return $listener; + } +} diff --git a/src/UnicaenApp/Options/ModuleOptionsFactory.php b/src/UnicaenApp/Options/ModuleOptionsFactory.php index 60698d789ee633e15746321da58eae2f6ed33deb..0bc8105f4b5eb496af414402eb3f791513e89508 100644 --- a/src/UnicaenApp/Options/ModuleOptionsFactory.php +++ b/src/UnicaenApp/Options/ModuleOptionsFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Options; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,16 +13,15 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class ModuleOptionsFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return mixed - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $config = $serviceLocator->get('Configuration'); - + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $config = $container->get('Configuration'); + return new ModuleOptions(isset($config['unicaen-app']) ? $config['unicaen-app'] : array()); } } \ No newline at end of file diff --git a/src/UnicaenApp/Options/Traits/ModuleOptionsAwareTrait.php b/src/UnicaenApp/Options/Traits/ModuleOptionsAwareTrait.php index d14ae03fb9df209770788c690c76d8acfe0341f9..406a39d9d848f4417417f543cb28d1a1dfa5410e 100644 --- a/src/UnicaenApp/Options/Traits/ModuleOptionsAwareTrait.php +++ b/src/UnicaenApp/Options/Traits/ModuleOptionsAwareTrait.php @@ -39,18 +39,6 @@ trait ModuleOptionsAwareTrait */ public function getModuleOptions() { - if (empty($this->moduleOptions)) { - if (!method_exists($this, 'getServiceLocator')) { - throw new RuntimeException('La classe ' . get_class($this) . ' n\'a pas accès au ServiceLocator.'); - } - - $serviceLocator = $this->getServiceLocator(); - if (method_exists($serviceLocator, 'getServiceLocator')) { - $serviceLocator = $serviceLocator->getServiceLocator(); - } - $this->moduleOptions = $serviceLocator->get('unicaen-app_module_options'); - } - return $this->moduleOptions; } } \ No newline at end of file diff --git a/src/UnicaenApp/Service/Doctrine/MultipleDbAbstractFactory.php b/src/UnicaenApp/Service/Doctrine/MultipleDbAbstractFactory.php index 8bc2ea02c8eac76a0dfc086dcb4bacf66f15dec1..5a332b836f9f81d31ac83160932d0819d02fe17c 100644 --- a/src/UnicaenApp/Service/Doctrine/MultipleDbAbstractFactory.php +++ b/src/UnicaenApp/Service/Doctrine/MultipleDbAbstractFactory.php @@ -2,17 +2,17 @@ namespace UnicaenApp\Service\Doctrine; use DoctrineModule\Service\AbstractFactory; -use DoctrineModule\Service\DriverFactory; -use DoctrineModule\Service\EventManagerFactory; use DoctrineModule\Service\Authentication\AdapterFactory; -use DoctrineModule\Service\Authentication\StorageFactory; use DoctrineModule\Service\Authentication\AuthenticationServiceFactory; +use DoctrineModule\Service\Authentication\StorageFactory; +use DoctrineModule\Service\DriverFactory; +use DoctrineModule\Service\EventManagerFactory; use DoctrineORMModule\Service\ConfigurationFactory; use DoctrineORMModule\Service\DBALConnectionFactory; use DoctrineORMModule\Service\EntityManagerFactory; use DoctrineORMModule\Service\EntityResolverFactory; use DoctrineORMModule\Service\SQLLoggerCollectorFactory; -use DoctrineORMModule\Collector\MappingCollector; +use Interop\Container\ContainerInterface; use UnicaenApp\Exception\LogicException; use Zend\ServiceManager\AbstractFactoryInterface; use Zend\ServiceManager\FactoryInterface; @@ -42,15 +42,24 @@ class MultipleDbAbstractFactory implements AbstractFactoryInterface protected $serviceFactories = array(); /** - * Determine if we can create a service with name - * - * @param ServiceLocatorInterface $serviceLocator - * @param $name - * @param $requestedName - * @return bool + * {@inheritdoc} + * @deprecated */ - public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) + { + return $this->canCreate($serviceLocator, $requestedName); + } + + /** + * {@inheritdoc} + * @deprecated + */ + public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) + { + return $this->__invoke($serviceLocator, $requestedName); + } + + public function canCreate(ContainerInterface $container, $requestedName) { $requestedName = trim($requestedName); $types = array( @@ -69,26 +78,20 @@ class MultipleDbAbstractFactory implements AbstractFactoryInterface if (!$serviceType) { return false; } + return in_array($serviceType, $types); } - /** - * Create service with name - * - * @param ServiceLocatorInterface $serviceLocator - * @param $name - * @param $requestedName - * @return mixed - */ - public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $requestedName = trim($requestedName); $serviceType = $this->extractServiceType($requestedName); $serviceName = $this->extractServiceName($requestedName); - $factory = $this->getServiceFactory($serviceLocator, $serviceType, $serviceName); - return $factory->createService($serviceLocator); + $factory = $this->getServiceFactory($container, $serviceType, $serviceName); + + return $factory->createService($container); } - + /** * Extrait le type de service. * diff --git a/src/UnicaenApp/Service/EntityManagerAwareInitializer.php b/src/UnicaenApp/Service/EntityManagerAwareInitializer.php index b0353d457aa8aa383c285652cab459cf3cc06c12..d83bc4c72c375a05f8948ce0e39524cf1f516a60 100644 --- a/src/UnicaenApp/Service/EntityManagerAwareInitializer.php +++ b/src/UnicaenApp/Service/EntityManagerAwareInitializer.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Service; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\InitializerInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -13,20 +14,15 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class EntityManagerAwareInitializer implements InitializerInterface { - /** - * Initialize - * - * @param mixed $instance - * @param ServiceLocatorInterface $serviceLocator - * @return void - */ public function initialize($instance, ServiceLocatorInterface $serviceLocator) { - if (method_exists($serviceLocator, 'getServiceLocator')) { - $serviceLocator = $serviceLocator->getServiceLocator(); - } + $this->__invoke($serviceLocator, $instance); + } + + public function __invoke(ContainerInterface $container, $instance) + { if ($instance instanceof EntityManagerAwareInterface) { - $instance->setEntityManager($serviceLocator->get('doctrine.entitymanager.orm_default')); + $instance->setEntityManager($container->get('doctrine.entitymanager.orm_default')); } } } diff --git a/src/UnicaenApp/Service/InstadiaService.php b/src/UnicaenApp/Service/InstadiaService.php index dc20a3d593e1d271ed8792a9f3a0da26dcae6393..ac28a6fc10e6a44fb36977dfc83426ca2ce8ac5a 100755 --- a/src/UnicaenApp/Service/InstadiaService.php +++ b/src/UnicaenApp/Service/InstadiaService.php @@ -4,24 +4,34 @@ namespace UnicaenApp\Service; use UnicaenApp\Entity\Db\Instadia; use UnicaenAuth\Entity\Db\AbstractUser; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; +use UnicaenAuth\Service\UserContext; /** * Description of InstadiaService * * @author LECLUSE Laurent <laurent.lecluse at unicaen.fr> */ -class InstadiaService implements ServiceLocatorAwareInterface, EntityManagerAwareInterface +class InstadiaService implements EntityManagerAwareInterface { - use ServiceLocatorAwareTrait; use EntityManagerAwareTrait; + /** + * @var UserContext + */ + private $userContextService; + /** * @var array */ private $callbacks; + /** + * @param UserContext $userContextService + */ + public function setUserContextService(UserContext $userContextService) + { + $this->userContextService = $userContextService; + } /** * @param string $rubrique @@ -142,11 +152,8 @@ class InstadiaService implements ServiceLocatorAwareInterface, EntityManagerAwar public function getUser() { - if ($this->getServiceLocator()->has('UnicaenAuth\Service\UserContext')) { - $ucs = $this->getServiceLocator()->get('UnicaenAuth\Service\UserContext'); - /* @var $ucs \UnicaenAuth\Service\UserContext */ - - $user = $ucs->getDbUser(); + if ($this->userContextService) { + $user = $this->userContextService->getDbUser(); } else { $user = null; } diff --git a/src/UnicaenApp/Service/InstadiaServiceFactory.php b/src/UnicaenApp/Service/InstadiaServiceFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..2eb0f668af5229ac5f729048538f55c55ef5ee0e --- /dev/null +++ b/src/UnicaenApp/Service/InstadiaServiceFactory.php @@ -0,0 +1,34 @@ +<?php + +namespace UnicaenApp\Service; + +use Interop\Container\ContainerInterface; +use UnicaenAuth\Service\UserContext; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +/** + * + * + * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> + */ +class InstadiaServiceFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $service = new InstadiaService(); + + if ($container->has('UnicaenAuth\Service\UserContext')) { + /** @var UserContext $ucs */ + $ucs = $container->get('UnicaenAuth\Service\UserContext'); + $service->setUserContextService($ucs); + } + + return $service; + } +} diff --git a/src/UnicaenApp/Service/Ldap/GroupFactory.php b/src/UnicaenApp/Service/Ldap/GroupFactory.php index 23bc34db6e14516397d47517f9a48a846ad2dd14..23aa8f2f6ae14d0d5606630b237d5202e97377f3 100644 --- a/src/UnicaenApp/Service/Ldap/GroupFactory.php +++ b/src/UnicaenApp/Service/Ldap/GroupFactory.php @@ -1,6 +1,7 @@ <?php namespace UnicaenApp\Service\Ldap; +use Interop\Container\ContainerInterface; use Zend\Ldap\Ldap; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,21 +13,21 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class GroupFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return Group - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $config = $serviceLocator->get('unicaen-app_module_options')->getLdap(); + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $config = $container->get('unicaen-app_module_options')->getLdap(); // if (!$config) { // throw new \UnicaenApp\Exception( -// "Impossible de créer le service d'accès aux structures " . +// "Impossible de créer le service d'accès aux structures " . // "car aucune info de connexion à l'annuaire LDAP n'a été fournie (option 'ldap_connection_infos')."); // } $options = isset($config['connection']['default']['params']) ? $config['connection']['default']['params'] : array(); + return new Group(new Ldap($options)); } } diff --git a/src/UnicaenApp/Service/Ldap/PeopleFactory.php b/src/UnicaenApp/Service/Ldap/PeopleFactory.php index cc50fda3baf8adfc826ac6d4dc50d21c233a295d..88b404fe8bb76cd7fbae1b164bc2de1919308c25 100644 --- a/src/UnicaenApp/Service/Ldap/PeopleFactory.php +++ b/src/UnicaenApp/Service/Ldap/PeopleFactory.php @@ -1,6 +1,7 @@ <?php namespace UnicaenApp\Service\Ldap; +use Interop\Container\ContainerInterface; use Zend\Ldap\Ldap; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,15 +13,14 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class PeopleFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return People - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $config = $serviceLocator->get('unicaen-app_module_options')->getLdap(); + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $config = $container->get('unicaen-app_module_options')->getLdap(); // if (!isset($config['connection']['default']['params'])) { // throw new \UnicaenApp\Exception( // "Config LDAP incorrecte."); @@ -31,7 +31,7 @@ class PeopleFactory implements FactoryInterface // "car aucune info de connexion à l'annuaire LDAP n'a été fournie (option 'ldap_connection_infos')."); // } $options = isset($config['connection']['default']['params']) ? $config['connection']['default']['params'] : array(); + return new People(new Ldap($options)); } - } diff --git a/src/UnicaenApp/Service/Ldap/StructureFactory.php b/src/UnicaenApp/Service/Ldap/StructureFactory.php index 6254ff9c66bd462866410ffb909b90675b2d36f4..c953218101503de2dcc467adddd1cd9eded8cd56 100644 --- a/src/UnicaenApp/Service/Ldap/StructureFactory.php +++ b/src/UnicaenApp/Service/Ldap/StructureFactory.php @@ -1,6 +1,7 @@ <?php namespace UnicaenApp\Service\Ldap; +use Interop\Container\ContainerInterface; use Zend\Ldap\Ldap; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,21 +13,21 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class StructureFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return Structure - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $config = $serviceLocator->get('unicaen-app_module_options')->getLdap(); + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $config = $container->get('unicaen-app_module_options')->getLdap(); // if (!$config) { // throw new \UnicaenApp\Exception( -// "Impossible de créer le service d'accès aux structures " . +// "Impossible de créer le service d'accès aux structures " . // "car aucune info de connexion à l'annuaire LDAP n'a été fournie (option 'ldap_connection_infos')."); // } $options = isset($config['connection']['default']['params']) ? $config['connection']['default']['params'] : array(); + return new Structure(new Ldap($options)); } } diff --git a/src/UnicaenApp/Service/MessageCollector.php b/src/UnicaenApp/Service/MessageCollector.php index a6e563f476a71eb7037f07ce669102359a036619..9057512265db9c621986cf884cfbe4997a65333c 100644 --- a/src/UnicaenApp/Service/MessageCollector.php +++ b/src/UnicaenApp/Service/MessageCollector.php @@ -3,6 +3,7 @@ namespace UnicaenApp\Service; use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; +use UnicaenApp\ServiceManager\ServiceLocatorAwareTrait; /** * Description of MessageCollector @@ -11,6 +12,6 @@ use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; */ class MessageCollector implements ServiceLocatorAwareInterface { - use \Zend\ServiceManager\ServiceLocatorAwareTrait; + use ServiceLocatorAwareTrait; use \UnicaenApp\Traits\MessageAwareTrait; } \ No newline at end of file diff --git a/src/UnicaenApp/Service/MessageCollectorAwareTrait.php b/src/UnicaenApp/Service/MessageCollectorAwareTrait.php index eb493274014b44dd8a0c50d4b793a56d78ffbafc..258f36cf8a31c8a773a999ce93a8f1f5beaf7b63 100644 --- a/src/UnicaenApp/Service/MessageCollectorAwareTrait.php +++ b/src/UnicaenApp/Service/MessageCollectorAwareTrait.php @@ -3,7 +3,6 @@ namespace UnicaenApp\Service; use UnicaenApp\Exception\RuntimeException; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; /** * Trait facilitant l'accès au service MessageCollector. @@ -38,20 +37,6 @@ trait MessageCollectorAwareTrait */ public function getServiceMessageCollector() { - if (null === $this->messageCollector) { - if (! $this instanceof ServiceLocatorAwareInterface) { - throw new RuntimeException("La classe " . get_class($this) . " n'a pas accès au ServiceLocator."); - } - - $serviceLocator = $this->getServiceLocator(); - - if ($serviceLocator instanceof ServiceLocatorAwareInterface) { - $serviceLocator = $serviceLocator->getServiceLocator(); - } - - $this->messageCollector = $serviceLocator->get('MessageCollector'); - } - return $this->messageCollector; } } \ No newline at end of file diff --git a/src/UnicaenApp/Service/MessageCollectorFactory.php b/src/UnicaenApp/Service/MessageCollectorFactory.php index f6ad6eb5f959400cc68b6ba6152182a14cd7dce4..79043ce1c85111abc5832f31581b8dc0c12b8485 100644 --- a/src/UnicaenApp/Service/MessageCollectorFactory.php +++ b/src/UnicaenApp/Service/MessageCollectorFactory.php @@ -1,6 +1,7 @@ <?php namespace UnicaenApp\Service; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -11,13 +12,12 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MessageCollectorFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return Group - */ public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return new MessageCollector(); } diff --git a/src/UnicaenApp/Service/Traits/InstadiaServiceAwareTrait.php b/src/UnicaenApp/Service/Traits/InstadiaServiceAwareTrait.php index d8073543a1057f08e9946f25b8da33c3f935917e..66469c6b0d871ffa9ecaaa22206f9eb613a60f73 100755 --- a/src/UnicaenApp/Service/Traits/InstadiaServiceAwareTrait.php +++ b/src/UnicaenApp/Service/Traits/InstadiaServiceAwareTrait.php @@ -2,8 +2,8 @@ namespace UnicaenApp\Service\Traits; -use UnicaenApp\Service\InstadiaService; use RuntimeException; +use UnicaenApp\Service\InstadiaService; /** * Description of InstadiaServiceAwareTrait @@ -39,17 +39,6 @@ trait InstadiaServiceAwareTrait */ public function getServiceInstadia() { - if (empty($this->serviceInstadia)){ - if (! method_exists($this, 'getServiceLocator')) { - throw new RuntimeException( 'La classe '.get_class($this).' n\'a pas accès au ServiceLocator.'); - } - - $serviceLocator = $this->getServiceLocator(); - if (method_exists($serviceLocator, 'getServiceLocator')) { - $serviceLocator = $serviceLocator->getServiceLocator(); - } - $this->serviceInstadia = $serviceLocator->get('instadia'); - } return $this->serviceInstadia; } } \ No newline at end of file diff --git a/src/UnicaenApp/ServiceManager/ServiceLocatorAwareInitializer.php b/src/UnicaenApp/ServiceManager/ServiceLocatorAwareInitializer.php index b63ad16b3043fb41a4048a1b2097fe1f5868ae8b..a98bdf6d9ffacc83eedd2413c9efce38bb3200c3 100644 --- a/src/UnicaenApp/ServiceManager/ServiceLocatorAwareInitializer.php +++ b/src/UnicaenApp/ServiceManager/ServiceLocatorAwareInitializer.php @@ -2,6 +2,7 @@ namespace UnicaenApp\ServiceManager; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\InitializerInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -23,11 +24,13 @@ class ServiceLocatorAwareInitializer implements InitializerInterface */ public function initialize($instance, ServiceLocatorInterface $serviceLocator) { - if (method_exists($serviceLocator, 'getServiceLocator')) { - $serviceLocator = $serviceLocator->getServiceLocator(); - } + $this->__invoke($serviceLocator, $instance); + } + + public function __invoke(ContainerInterface $container, $instance) + { if ($instance instanceof ServiceLocatorAwareInterface) { - $instance->setServiceLocator($serviceLocator); + $instance->setServiceLocator($container); } } } diff --git a/src/UnicaenApp/ServiceManager/ServiceLocatorAwareInterface.php b/src/UnicaenApp/ServiceManager/ServiceLocatorAwareInterface.php index a970af3103205a131538a5403a264a67f42195d8..eda364e3b18e220059732f51554791302eab08ea 100644 --- a/src/UnicaenApp/ServiceManager/ServiceLocatorAwareInterface.php +++ b/src/UnicaenApp/ServiceManager/ServiceLocatorAwareInterface.php @@ -2,7 +2,7 @@ namespace UnicaenApp\ServiceManager; -use Zend\ServiceManager\ServiceLocatorInterface; +use Interop\Container\ContainerInterface; /** * Interface remplaçant provisoirement Zend\ServiceManager\ServiceLocatorAwareInterface qui @@ -16,15 +16,15 @@ interface ServiceLocatorAwareInterface /** * Set service locator * - * @param ServiceLocatorInterface $serviceLocator + * @param ContainerInterface $serviceLocator * @deprecated À abandonner, svp */ - public function setServiceLocator(ServiceLocatorInterface $serviceLocator); + public function setServiceLocator(ContainerInterface $serviceLocator); /** * Get service locator * - * @return ServiceLocatorInterface + * @return ContainerInterface * @deprecated À abandonner, svp */ public function getServiceLocator(); diff --git a/src/UnicaenApp/ServiceManager/ServiceLocatorAwareTrait.php b/src/UnicaenApp/ServiceManager/ServiceLocatorAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..c5b3d56e3473b47761a75e730a9c5f1a92f61419 --- /dev/null +++ b/src/UnicaenApp/ServiceManager/ServiceLocatorAwareTrait.php @@ -0,0 +1,42 @@ +<?php + +namespace UnicaenApp\ServiceManager; + +use Interop\Container\ContainerInterface; + +/** + * Trait remplaçant provisoirement Zend\ServiceManager\ServiceLocatorAwareTrait + * qui a disparu dans ZF3. + * + * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> + * @deprecated À abandonner, svp + */ +trait ServiceLocatorAwareTrait +{ + /** + * @var ContainerInterface + */ + protected $serviceLocator; + + /** + * Set service locator + * + * @param ContainerInterface $serviceLocator + * @deprecated À abandonner, svp + */ + public function setServiceLocator(ContainerInterface $serviceLocator) + { + $this->serviceLocator = $serviceLocator; + } + + /** + * Get service locator + * + * @return ContainerInterface + * @deprecated À abandonner, svp + */ + public function getServiceLocator() + { + return $this->serviceLocator; + } +} diff --git a/src/UnicaenApp/Session/SessionManagerFactory.php b/src/UnicaenApp/Session/SessionManagerFactory.php index 16ccf01aa468776ce6a776b71dd3ab6dd5b09055..6470b269dc3a62ba6d180535805d0eb78f895cfb 100644 --- a/src/UnicaenApp/Session/SessionManagerFactory.php +++ b/src/UnicaenApp/Session/SessionManagerFactory.php @@ -2,13 +2,14 @@ namespace UnicaenApp\Session; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\Session\Config\SessionConfig; +use Zend\Session\Container; use Zend\Session\SessionManager; -use Zend\Session\Validator\RemoteAddr; use Zend\Session\Validator\HttpUserAgent; -use Zend\Session\Container; +use Zend\Session\Validator\RemoteAddr; /** * Description of SessionManager @@ -17,16 +18,15 @@ use Zend\Session\Container; */ class SessionManagerFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $serviceLocator - * @return SessionManager - */ public function createService(ServiceLocatorInterface $serviceLocator) { - $appInfos = $serviceLocator->get('unicaen-app_module_options')->getAppInfos(); - + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $appInfos = $container->get('unicaen-app_module_options')->getAppInfos(); + $sessionConfig = new SessionConfig(); $sessionConfig->setOptions(array( 'name' => md5($appInfos['nom']), @@ -39,7 +39,7 @@ class SessionManagerFactory implements FactoryInterface $chain->attach('session.validate', array(new HttpUserAgent(), 'isValid')); Container::setDefaultManager($sessionManager); - + return $sessionManager; } } \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/AppInfosFactory.php b/src/UnicaenApp/View/Helper/AppInfosFactory.php index b736b94767310523335a4bacd20f64fb1a019e34..4849a52df2a5bbc8f36c852bfd41d6f6605f8b26 100644 --- a/src/UnicaenApp/View/Helper/AppInfosFactory.php +++ b/src/UnicaenApp/View/Helper/AppInfosFactory.php @@ -2,6 +2,8 @@ namespace UnicaenApp\View\Helper; +use Interop\Container\ContainerInterface; +use UnicaenApp\Options\ModuleOptions; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,16 +14,15 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class AppInfosFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $helperPluginManager - * @return AppInfos - */ - public function createService(ServiceLocatorInterface $helperPluginManager) + public function createService(ServiceLocatorInterface $serviceLocator) { - $options = $helperPluginManager->getServiceLocator()->get('unicaen-app_module_options'); /* @var $options ModuleOptions */ - + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $options = $container->get('unicaen-app_module_options'); /* @var $options ModuleOptions */ + return new AppInfos($options->getAppInfos()); } } \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/AppLink.php b/src/UnicaenApp/View/Helper/AppLink.php index 3cc7881eacf37e730406482515182ffb47d02197..a50a7b3e90d5647bc0c48f67f2f45a8413052ea6 100644 --- a/src/UnicaenApp/View/Helper/AppLink.php +++ b/src/UnicaenApp/View/Helper/AppLink.php @@ -2,8 +2,8 @@ namespace UnicaenApp\View\Helper; use Zend\I18n\View\Helper\AbstractTranslatorHelper; -use Zend\Mvc\Router\RouteMatch; -use Zend\Mvc\Router\RouteStackInterface; +use Zend\Router\RouteMatch; +use Zend\Router\RouteStackInterface; use UnicaenApp\Exception\LogicException; /** diff --git a/src/UnicaenApp/View/Helper/AppLinkFactory.php b/src/UnicaenApp/View/Helper/AppLinkFactory.php index 5bb2e55de0a689d8ba3960cf43cd7a3722f1103c..bb5393ca8287360cf9d82338453096f92d98b021 100644 --- a/src/UnicaenApp/View/Helper/AppLinkFactory.php +++ b/src/UnicaenApp/View/Helper/AppLinkFactory.php @@ -2,10 +2,10 @@ namespace UnicaenApp\View\Helper; +use Interop\Container\ContainerInterface; +use Zend\Console\Console; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; -use Zend\Console\Console; -use Zend\Mvc\Router\RouteMatch; /** * Description of AppLinkFactory @@ -14,25 +14,24 @@ use Zend\Mvc\Router\RouteMatch; */ class AppLinkFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $helperPluginManager - * @return AppInfos - */ - public function createService(ServiceLocatorInterface $helperPluginManager) + public function createService(ServiceLocatorInterface $serviceLocator) { - $sl = $helperPluginManager->getServiceLocator(); + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $sl = $container; $router = Console::isConsole() ? 'HttpRouter' : 'Router'; $match = $sl->get('application')->getMvcEvent()->getRouteMatch(); $helper = new AppLink(); $helper->setRouter($sl->get($router)); - - if ($match instanceof RouteMatch) { + + if ($match instanceof \Zend\Router\RouteMatch) { $helper->setRouteMatch($match); } - + return $helper; } } \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/HeadLink.php b/src/UnicaenApp/View/Helper/HeadLink.php index 53b2f2538740c41e0ab41c87e75e2589b6161332..a40bd91c86b6bb556a10dcefff10dc51f2ab1354 100644 --- a/src/UnicaenApp/View/Helper/HeadLink.php +++ b/src/UnicaenApp/View/Helper/HeadLink.php @@ -2,14 +2,22 @@ namespace UnicaenApp\View\Helper; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; use Zend\View\Helper\Placeholder\Container\AbstractContainer; -class HeadLink extends \Zend\View\Helper\HeadLink implements ServiceLocatorAwareInterface { - use ServiceLocatorAwareTrait; - +class HeadLink extends \Zend\View\Helper\HeadLink +{ + /** + * @var array + */ + private $config = []; + /** + * @param array $config + */ + public function setConfig(array $config) + { + $this->config = $config; + } /** * {@inheritdoc} @@ -29,7 +37,7 @@ class HeadLink extends \Zend\View\Helper\HeadLink implements ServiceLocatorAware */ protected function appendConfigStyles() { - $config = $this->getServiceLocator()->get('config'); + $config = $this->config; $cacheEnabled = isset($config['public_files']['cache_enabled']) ? (boolean)$config['public_files']['cache_enabled'] : false; $version = isset($config['unicaen-app']['app_infos']['version']) ? $config['unicaen-app']['app_infos']['version'] : ''; diff --git a/src/UnicaenApp/View/Helper/HeadLinkFactory.php b/src/UnicaenApp/View/Helper/HeadLinkFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..6386575b7033895454c68607565cdce3a95f8dea --- /dev/null +++ b/src/UnicaenApp/View/Helper/HeadLinkFactory.php @@ -0,0 +1,24 @@ +<?php + +namespace UnicaenApp\View\Helper; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class HeadLinkFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $helper = new HeadLink(); + + $helper->setConfig($container->get('config')); + + return $helper; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/HeadScript.php b/src/UnicaenApp/View/Helper/HeadScript.php index 10ab90e52ebb9d844980e9c68f6e216a20b63d72..0dc6893e324574d1d3dee03a6d9afb8a32beacf7 100644 --- a/src/UnicaenApp/View/Helper/HeadScript.php +++ b/src/UnicaenApp/View/Helper/HeadScript.php @@ -2,11 +2,20 @@ namespace UnicaenApp\View\Helper; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; +class HeadScript extends \Zend\View\Helper\InlineScript +{ + /** + * @var array + */ + private $config = []; -class HeadScript extends \Zend\View\Helper\InlineScript implements ServiceLocatorAwareInterface { - use ServiceLocatorAwareTrait; + /** + * @param array $config + */ + public function setConfig(array $config) + { + $this->config = $config; + } /** * Return InlineScript object @@ -36,7 +45,7 @@ class HeadScript extends \Zend\View\Helper\InlineScript implements ServiceLocato protected function appendConfigScripts() { - $config = $this->getServiceLocator()->get('config'); + $config = $this->config; $version = isset($config['unicaen-app']['app_infos']['version']) ? '?v='.$config['unicaen-app']['app_infos']['version'] : ''; diff --git a/src/UnicaenApp/View/Helper/HeadScriptFactory.php b/src/UnicaenApp/View/Helper/HeadScriptFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..ba3850399cdc299cb91d0f2eb17d87153b2c883f --- /dev/null +++ b/src/UnicaenApp/View/Helper/HeadScriptFactory.php @@ -0,0 +1,24 @@ +<?php + +namespace UnicaenApp\View\Helper; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class HeadScriptFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $helper = new HeadScript(); + + $helper->setConfig($container->get('config')); + + return $helper; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/InlineScript.php b/src/UnicaenApp/View/Helper/InlineScript.php index 754d60b774dee8da901ce1f89ba6de15917a0b34..eedd9dc0c3f49742fc430e86fc1a51d0e4740498 100644 --- a/src/UnicaenApp/View/Helper/InlineScript.php +++ b/src/UnicaenApp/View/Helper/InlineScript.php @@ -2,11 +2,20 @@ namespace UnicaenApp\View\Helper; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; +class InlineScript extends \Zend\View\Helper\InlineScript +{ + /** + * @var array + */ + private $config = []; -class InlineScript extends \Zend\View\Helper\InlineScript implements ServiceLocatorAwareInterface { - use ServiceLocatorAwareTrait; + /** + * @param array $config + */ + public function setConfig(array $config) + { + $this->config = $config; + } /** * Return InlineScript object @@ -36,7 +45,7 @@ class InlineScript extends \Zend\View\Helper\InlineScript implements ServiceLoca protected function appendConfigScripts() { - $config = $this->getServiceLocator()->get('config'); + $config = $this->config; $cacheEnabled = isset($config['public_files']['cache_enabled']) ? (boolean)$config['public_files']['cache_enabled'] : false; $version = isset($config['unicaen-app']['app_infos']['version']) ? $config['unicaen-app']['app_infos']['version'] : ''; diff --git a/src/UnicaenApp/View/Helper/InlineScriptFactory.php b/src/UnicaenApp/View/Helper/InlineScriptFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..70e31eceaf24ee7bca018c661f9ee1299be983f2 --- /dev/null +++ b/src/UnicaenApp/View/Helper/InlineScriptFactory.php @@ -0,0 +1,24 @@ +<?php + +namespace UnicaenApp\View\Helper; + +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class InlineScriptFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $helper = new InlineScript(); + + $helper->setConfig($container->get('config')); + + return $helper; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/InstadiaViewHelper.php b/src/UnicaenApp/View/Helper/InstadiaViewHelper.php index e2f50a33d914eac7e95ecf7b80d0938b568e3093..5e93ac578a8169d4d4b2611cb4a4079eb2184dad 100755 --- a/src/UnicaenApp/View/Helper/InstadiaViewHelper.php +++ b/src/UnicaenApp/View/Helper/InstadiaViewHelper.php @@ -4,17 +4,14 @@ namespace UnicaenApp\View\Helper; use UnicaenApp\Service\Traits\InstadiaServiceAwareTrait; use Zend\View\Helper\AbstractHtmlElement; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; /** * Description of InstadiaViewHelper * * @author LECLUSE Laurent <laurent.lecluse at unicaen.fr> */ -class InstadiaViewHelper extends AbstractHtmlElement implements ServiceLocatorAwareInterface +class InstadiaViewHelper extends AbstractHtmlElement { - use ServiceLocatorAwareTrait; use InstadiaServiceAwareTrait; /** diff --git a/src/UnicaenApp/View/Helper/InstadiaViewHelperFactory.php b/src/UnicaenApp/View/Helper/InstadiaViewHelperFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..39d2096f526648edc0e76e0786188d628d21ed3e --- /dev/null +++ b/src/UnicaenApp/View/Helper/InstadiaViewHelperFactory.php @@ -0,0 +1,28 @@ +<?php + +namespace UnicaenApp\View\Helper; + +use Interop\Container\ContainerInterface; +use UnicaenApp\Service\InstadiaService; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class InstadiaViewHelperFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $helper = new InstadiaViewHelper(); + + /** @var InstadiaService $instadiaService */ + $instadiaService = $container->get('instadia'); + + $helper->setServiceInstadia($instadiaService); + + return $helper; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/MessageCollectorHelper.php b/src/UnicaenApp/View/Helper/MessageCollectorHelper.php index bd86a51e469ea0d13efc455fcaf022c7cf0a7321..5afc8ab2fc6cb11f90db64f4b3f7f95019d5cb22 100644 --- a/src/UnicaenApp/View/Helper/MessageCollectorHelper.php +++ b/src/UnicaenApp/View/Helper/MessageCollectorHelper.php @@ -3,8 +3,6 @@ namespace UnicaenApp\View\Helper; use UnicaenApp\Service\MessageCollector; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; use Zend\View\Helper\AbstractHelper; use Zend\View\Renderer\PhpRenderer; @@ -14,10 +12,8 @@ use Zend\View\Renderer\PhpRenderer; * @see \UnicaenApp\Service\MessageCollector * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> */ -class MessageCollectorHelper extends AbstractHelper implements ServiceLocatorAwareInterface +class MessageCollectorHelper extends AbstractHelper { - use ServiceLocatorAwareTrait; - /** * @var string */ @@ -33,6 +29,14 @@ class MessageCollectorHelper extends AbstractHelper implements ServiceLocatorAwa */ protected $messengerHelper; + /** + * @param MessageCollector $messageCollectorService + */ + public function setMessageCollectorService(MessageCollector $messageCollectorService) + { + $this->messageCollectorService = $messageCollectorService; + } + /** * Point d'entrée. * @@ -52,11 +56,11 @@ class MessageCollectorHelper extends AbstractHelper implements ServiceLocatorAwa { $severity = $severity ?: $this->severity; - if (! $this->getMessageCollectorService()->hasMessages($severity)) { + if (! $this->messageCollectorService->hasMessages($severity)) { return ''; } - $messages = $this->getMessageCollectorService()->getMessages($severity); + $messages = $this->messageCollectorService->getMessages($severity); $keys = array_fill(0, count($messages), $severity); $messenger = $this->getMessengerHelper(); @@ -94,18 +98,4 @@ class MessageCollectorHelper extends AbstractHelper implements ServiceLocatorAwa { return $this->render($this->severity); } - - /** - * Retourne le service collecteur de messages. - * - * @return MessageCollector - */ - private function getMessageCollectorService() - { - if ($this->messageCollectorService == null) { - $this->messageCollectorService = $this->getServiceLocator()->get('MessageCollector'); - } - - return $this->messageCollectorService; - } } \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/MessageCollectorHelperFactory.php b/src/UnicaenApp/View/Helper/MessageCollectorHelperFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..7fcec24b528bdafe60b56ae5d163b99af1803ef2 --- /dev/null +++ b/src/UnicaenApp/View/Helper/MessageCollectorHelperFactory.php @@ -0,0 +1,28 @@ +<?php + +namespace UnicaenApp\View\Helper; + +use Interop\Container\ContainerInterface; +use UnicaenApp\Service\MessageCollector; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class MessageCollectorHelperFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $helper = new MessageCollectorHelper(); + + /** @var MessageCollector $messageCollectorService */ + $messageCollectorService = $container->get('MessageCollector'); + + $helper->setMessageCollectorService($messageCollectorService); + + return $helper; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/MessengerFactory.php b/src/UnicaenApp/View/Helper/MessengerFactory.php index 4f728f8f3fb687e69b560245cd1a492342304428..28705b2cc86bd2139567a6d0841ef67a8d8a08e8 100644 --- a/src/UnicaenApp/View/Helper/MessengerFactory.php +++ b/src/UnicaenApp/View/Helper/MessengerFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\View\Helper; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,18 +13,17 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class MessengerFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $helperPluginManager - * @return Messenger - */ - public function createService(ServiceLocatorInterface $helperPluginManager) + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $messenger = new Messenger(); /* @var $application Application */ - $application = $helperPluginManager->getServiceLocator()->get('application'); + $application = $container->get('application'); if ($application){ $messenger->setEventManager($application->getEventManager()); } diff --git a/src/UnicaenApp/View/Helper/QueryParams.php b/src/UnicaenApp/View/Helper/QueryParams.php index 7deae7434f6520edd3dd34e776054a069385e622..9f99bd30b54ec919e22b1eb1b2737509cb032877 100644 --- a/src/UnicaenApp/View/Helper/QueryParams.php +++ b/src/UnicaenApp/View/Helper/QueryParams.php @@ -3,14 +3,10 @@ namespace UnicaenApp\View\Helper; use Zend\Http\Request; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; use Zend\View\Helper\AbstractHelper; -class QueryParams extends AbstractHelper implements ServiceLocatorAwareInterface +class QueryParams extends AbstractHelper { - use ServiceLocatorAwareTrait; - /** * @var Request */ diff --git a/src/UnicaenApp/View/Helper/QueryParamsHelperFactory.php b/src/UnicaenApp/View/Helper/QueryParamsHelperFactory.php index b2ca32cdb294159d3535f95237dc6f3d88fb76c0..6cc16853350cf064f788991bc897007f07645425 100644 --- a/src/UnicaenApp/View/Helper/QueryParamsHelperFactory.php +++ b/src/UnicaenApp/View/Helper/QueryParamsHelperFactory.php @@ -14,7 +14,7 @@ class QueryParamsHelperFactory public function __invoke(HelperPluginManager $hpm) { /** @var Request $request */ - $request = $hpm->getServiceLocator()->get('request'); + $request = $hpm->get('request'); $helper = new QueryParams(); $helper->setRequest($request); diff --git a/src/UnicaenApp/View/Helper/TabAjax/Tab.php b/src/UnicaenApp/View/Helper/TabAjax/Tab.php index ebe4deef7cf6b97e4eeb7d62e8158a40d61399fe..af2cc23a9f931260d28bd2d7cd87304b2690652d 100644 --- a/src/UnicaenApp/View/Helper/TabAjax/Tab.php +++ b/src/UnicaenApp/View/Helper/TabAjax/Tab.php @@ -2,7 +2,7 @@ namespace UnicaenApp\View\Helper\TabAjax; -use Zend\Stdlib\Hydrator\ClassMethods; +use Zend\Hydrator\ClassMethods; class Tab { diff --git a/src/UnicaenApp/View/Helper/ToggleDetails.php b/src/UnicaenApp/View/Helper/ToggleDetails.php index 10cef0d43165246322dbebc3de31626d1edf7847..072e1143f7b040f1e6f5e015e93cf30a2bbebf37 100644 --- a/src/UnicaenApp/View/Helper/ToggleDetails.php +++ b/src/UnicaenApp/View/Helper/ToggleDetails.php @@ -258,7 +258,7 @@ $(function() { }); EOS; - $request = $this->getView()->getHelperPluginManager()->getServiceLocator()->get('request'); + $request = $this->getView()->getHelperPluginManager()->get('request'); $isXmlHttpRequest = $request->isXmlHttpRequest(); if ($isXmlHttpRequest) { diff --git a/src/UnicaenApp/View/Helper/Upload/UploaderHelper.php b/src/UnicaenApp/View/Helper/Upload/UploaderHelper.php index 9e8dbb3e0eff4ffdda09b05469ef78127b84e93b..b21e9d99aca7c3c19b4c6b9338da1c5434a5642d 100644 --- a/src/UnicaenApp/View/Helper/Upload/UploaderHelper.php +++ b/src/UnicaenApp/View/Helper/Upload/UploaderHelper.php @@ -5,10 +5,8 @@ namespace UnicaenApp\View\Helper\Upload; use UnicaenApp\Controller\Plugin\Upload\UploadedFileInterface; use UnicaenApp\Controller\Plugin\Upload\UploaderPlugin; use UnicaenApp\Controller\Plugin\Upload\UploadForm; -use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; +use Zend\Mvc\Controller\PluginManager; use Zend\View\Helper\AbstractHelper; -use Zend\View\HelperPluginManager; use Zend\View\Resolver\TemplatePathStack; /** @@ -17,10 +15,8 @@ use Zend\View\Resolver\TemplatePathStack; * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> * @see \UnicaenApp\Controller\Plugin\Upload\Upload */ -class UploaderHelper extends AbstractHelper implements ServiceLocatorAwareInterface +class UploaderHelper extends AbstractHelper { - use ServiceLocatorAwareTrait; - /** * URL de l'action permettant de déposer un nouveau fichier. * C'est l'URL à laquelle est POSTé le formulaire d'upload. @@ -31,6 +27,19 @@ class UploaderHelper extends AbstractHelper implements ServiceLocatorAwareInterf */ protected $url; + /** + * @var PluginManager + */ + private $controllerPluginManager; + + /** + * @param PluginManager $controllerPluginManager + */ + public function setControllerPluginManager(PluginManager $controllerPluginManager) + { + $this->controllerPluginManager = $controllerPluginManager; + } + /** * * @return UploaderHelper @@ -160,11 +169,8 @@ class UploaderHelper extends AbstractHelper implements ServiceLocatorAwareInterf public function getForm() { if (null === $this->form) { - /** @var HelperPluginManager $pluginManager */ - $pluginManager = $this->getServiceLocator(); /** @var UploaderPlugin $uploaderPlugin */ - $uploaderPlugin = $pluginManager->getServiceLocator()->get('controller_plugin_manager')->get('Uploader'); - + $uploaderPlugin = $this->controllerPluginManager->get('Uploader'); $this->form = $uploaderPlugin->getForm(); } diff --git a/src/UnicaenApp/View/Helper/Upload/UploaderHelperFactory.php b/src/UnicaenApp/View/Helper/Upload/UploaderHelperFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..4094b8a280faee23fd99ae92023d73767af95bee --- /dev/null +++ b/src/UnicaenApp/View/Helper/Upload/UploaderHelperFactory.php @@ -0,0 +1,28 @@ +<?php + +namespace UnicaenApp\View\Helper\Upload; + +use Interop\Container\ContainerInterface; +use Zend\Mvc\Controller\PluginManager; +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; + +class UploaderHelperFactory implements FactoryInterface +{ + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + { + $helper = new UploaderHelper(); + + /** @var PluginManager $cpm */ + $cpm = $container->get('controller_plugin_manager'); + + $helper->setControllerPluginManager($cpm); + + return $helper; + } +} \ No newline at end of file diff --git a/src/UnicaenApp/View/Helper/UserProfileSelectFactory.php b/src/UnicaenApp/View/Helper/UserProfileSelectFactory.php index 8bbf17d7ca74ed1ef67d816b49b1763a65488a95..e38a75196712c5b026dd1fde9bcd45fdce9717d0 100644 --- a/src/UnicaenApp/View/Helper/UserProfileSelectFactory.php +++ b/src/UnicaenApp/View/Helper/UserProfileSelectFactory.php @@ -2,6 +2,7 @@ namespace UnicaenApp\View\Helper; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -12,13 +13,12 @@ use Zend\ServiceManager\ServiceLocatorInterface; */ class UserProfileSelectFactory implements FactoryInterface { - /** - * Create service - * - * @param ServiceLocatorInterface $helperPluginManager - * @return UserProfile - */ - public function createService(ServiceLocatorInterface $helperPluginManager) + public function createService(ServiceLocatorInterface $serviceLocator) + { + return $this->__invoke($serviceLocator, '?'); + } + + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return new UserProfileSelect(); } diff --git a/tests/UnicaenAppTest/Controller/Plugin/MailTest.php b/tests/UnicaenAppTest/Controller/Plugin/MailTest.php index e8faf7084ef0caf1c6c6bcf21c0a7eb26607d323..523d72350c29f4eecbe7dea9efaf6feb4dba5fc7 100644 --- a/tests/UnicaenAppTest/Controller/Plugin/MailTest.php +++ b/tests/UnicaenAppTest/Controller/Plugin/MailTest.php @@ -3,9 +3,9 @@ namespace UnicaenAppTest\Controller\Plugin; use Zend\Http\Response; use Zend\Mvc\MvcEvent; -use Zend\Mvc\Router\Http\Literal as LiteralRoute; -use Zend\Mvc\Router\RouteMatch; -use Zend\Mvc\Router\SimpleRouteStack; +use Zend\Router\Http\Literal as LiteralRoute; +use Zend\Router\RouteMatch; +use Zend\Router\SimpleRouteStack; use UnicaenAppTest\Controller\Plugin\TestAsset\ContactController; use UnicaenAppTest\Entity\Ldap\TestAsset\People as PeopleTestAsset; diff --git a/tests/UnicaenAppTest/Controller/Plugin/MultipageForm/AbstractTest.php b/tests/UnicaenAppTest/Controller/Plugin/MultipageForm/AbstractTest.php index e1aec66294f3490c4946be9dbaabc2164ccf8617..22496301086c4caf9156f0eec242d5e6aabc140e 100644 --- a/tests/UnicaenAppTest/Controller/Plugin/MultipageForm/AbstractTest.php +++ b/tests/UnicaenAppTest/Controller/Plugin/MultipageForm/AbstractTest.php @@ -9,8 +9,8 @@ use UnicaenAppTest\Form\TestAsset\ContactMultipageForm; use Zend\Http\Request; use Zend\Http\Response; use Zend\Mvc\MvcEvent; -use Zend\Mvc\Router\RouteMatch; -use Zend\Mvc\Router\SimpleRouteStack; +use Zend\Router\RouteMatch; +use Zend\Router\SimpleRouteStack; use Zend\ServiceManager\Config; use Zend\Stdlib\Parameters; use Zend\Mvc\Controller\PluginManager; @@ -59,7 +59,7 @@ abstract class AbstractTest extends PHPUnit_Framework_TestCase ), ); $this->router = new SimpleRouteStack(); - $this->router->addRoute('contact', \Zend\Mvc\Router\Http\Segment::factory($options)); + $this->router->addRoute('contact', \Zend\Router\Http\Segment::factory($options)); $this->controller = new ContactController(); $this->routeMatch = new RouteMatch(array('controller' => 'contact', 'action' => 'index')); diff --git a/tests/UnicaenAppTest/Service/Doctrine/MultipleDbAbstractFactoryTest.php b/tests/UnicaenAppTest/Service/Doctrine/MultipleDbAbstractFactoryTest.php index 6121cf84b728391c3578a3da06eb6a0ddbc0a41c..126c1719be303367b9b54716306c897ab71942fd 100644 --- a/tests/UnicaenAppTest/Service/Doctrine/MultipleDbAbstractFactoryTest.php +++ b/tests/UnicaenAppTest/Service/Doctrine/MultipleDbAbstractFactoryTest.php @@ -166,66 +166,82 @@ class MultipleDbAbstractFactoryTest extends PHPUnit_Framework_TestCase */ namespace DoctrineModule\Service; +use Interop\Container\ContainerInterface; + class DriverFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } class EventManagerFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } namespace DoctrineORMModule\Service; +use Interop\Container\ContainerInterface; + class ConfigurationFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } class DBALConnectionFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } class EntityManagerFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } class EntityResolverFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } class SQLLoggerCollectorFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } -namespace DoctrineModule\Service\Authentication; +namespace DoctrineModule\Service\Authentication; + +use Interop\Container\ContainerInterface; class AdapterFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } class StorageFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } class AuthenticationServiceFactory implements \Zend\ServiceManager\FactoryInterface { public function __construct($serviceName) { } - public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return __CLASS__; } + public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sl) { return $this->__invoke($sl); } + public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return __CLASS__; } } \ No newline at end of file diff --git a/tests/UnicaenAppTest/View/Helper/AppLinkFactoryTest.php b/tests/UnicaenAppTest/View/Helper/AppLinkFactoryTest.php index 9df99dbc3bc3040c7b8fbc60aae5e0e5b33ce8c8..188e20bc1dbb0fc7ff5b45a7dac029f7096f87b6 100644 --- a/tests/UnicaenAppTest/View/Helper/AppLinkFactoryTest.php +++ b/tests/UnicaenAppTest/View/Helper/AppLinkFactoryTest.php @@ -16,7 +16,7 @@ class AppLinkFactoryTest extends BaseServiceFactoryTest { return array( array(null), - array($this->createMock('Zend\Mvc\Router\RouteMatch', array(), array(), '', false)), + array($this->createMock('Zend\Router\RouteMatch', array(), array(), '', false)), ); } @@ -36,7 +36,7 @@ class AppLinkFactoryTest extends BaseServiceFactoryTest ->method('getMvcEvent') ->will($this->returnValue($event)); - $router = $this->createMock('Zend\Mvc\Router\SimpleRouteStack', array()); + $router = $this->createMock('Zend\Router\SimpleRouteStack', array()); $map = array( array('application', $application), array('HttpRouter', $router), diff --git a/tests/UnicaenAppTest/View/Helper/AppLinkTest.php b/tests/UnicaenAppTest/View/Helper/AppLinkTest.php index 005ff49799d521eee6b92be14f33ad3a56dae7e7..b149814cac2e08f0a27e9b3592d8564b06c9809e 100644 --- a/tests/UnicaenAppTest/View/Helper/AppLinkTest.php +++ b/tests/UnicaenAppTest/View/Helper/AppLinkTest.php @@ -22,9 +22,9 @@ class AppLinkText extends AbstractTest { parent::setUp(); - $this->router = $this->createMock('\Zend\Mvc\Router\SimpleRouteStack', array('assemble')); + $this->router = $this->createMock('\Zend\Router\SimpleRouteStack', array('assemble')); - $this->routeMatch = new \Zend\Mvc\Router\RouteMatch(array()); + $this->routeMatch = new \Zend\Router\RouteMatch(array()); $this->helper->setTranslator(new Translator()) ->setRouter($this->router) diff --git a/tests/UnicaenAppTest/View/Helper/MessengerTest.php b/tests/UnicaenAppTest/View/Helper/MessengerTest.php index ee77896f8b94b96d1151379e2c5e78ebea8bf68f..b1d34bb7471c67ecf121aac4fd45e45d4a59ee7c 100644 --- a/tests/UnicaenAppTest/View/Helper/MessengerTest.php +++ b/tests/UnicaenAppTest/View/Helper/MessengerTest.php @@ -3,7 +3,7 @@ namespace UnicaenAppTest\View\Helper; use UnicaenApp\View\Helper\Messenger; use Zend\View\Helper\FlashMessenger as FlashMessengerViewHelper; -use Zend\Mvc\Controller\Plugin\FlashMessenger as FlashMessengerPlugin; +use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger as FlashMessengerPlugin; use Zend\View\Renderer\PhpRenderer; /** diff --git a/tests/UnicaenAppTest/View/Helper/Navigation/AbstractTest.php b/tests/UnicaenAppTest/View/Helper/Navigation/AbstractTest.php index b499ee145675ceaaa28e30518f5185432ecda45a..f4b455a8801fbf4e260cc0d43b11e16a5f1c2eca 100644 --- a/tests/UnicaenAppTest/View/Helper/Navigation/AbstractTest.php +++ b/tests/UnicaenAppTest/View/Helper/Navigation/AbstractTest.php @@ -2,8 +2,8 @@ namespace UnicaenAppTest\View\Helper\Navigation; use PHPUnit_Framework_TestCase; -use Zend\Mvc\Router\Http\TreeRouteStack; -use Zend\Mvc\Router\RouteMatch; +use Zend\Router\Http\TreeRouteStack; +use Zend\Router\RouteMatch; use Zend\Mvc\Service\ServiceManagerConfig; use Zend\Navigation\AbstractContainer; use Zend\ServiceManager\ServiceLocatorInterface; diff --git a/tests/UnicaenAppTest/View/Helper/Navigation/_files/routes/menu-principal/routes.php b/tests/UnicaenAppTest/View/Helper/Navigation/_files/routes/menu-principal/routes.php index bb05ece391bcf1a41eea1c7a780068fa6e6343c9..cdafd987d874664b7498473eec8d0160aec02f4c 100644 --- a/tests/UnicaenAppTest/View/Helper/Navigation/_files/routes/menu-principal/routes.php +++ b/tests/UnicaenAppTest/View/Helper/Navigation/_files/routes/menu-principal/routes.php @@ -1,45 +1,45 @@ <?php return array( 'home' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/', ), ), 'apropos' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/apropos', ), ), 'contact' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/contact', ), 'may_terminate' => true, 'child_routes' => array( 'ajouter' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/ajouter', ), 'may_terminate' => true, 'child_routes' => array( 'identite' => array( - 'type' => 'Zend\Mvc\Router\Http\Segment', + 'type' => 'Zend\Router\Http\Segment', 'options' => array( 'route' => '/identite[/:source[/:branch]]', ), ), 'adresse' => array( - 'type' => 'Zend\Mvc\Router\Http\Segment', + 'type' => 'Zend\Router\Http\Segment', 'options' => array( 'route' => '/adresse[/:type]', ), ), 'message' => array( - 'type' => 'Zend\Mvc\Router\Http\Segment', + 'type' => 'Zend\Router\Http\Segment', 'options' => array( 'route' => '/message[/:id]', ), @@ -47,19 +47,19 @@ return array( ), ), 'supprimer' => array( - 'type' => 'Zend\Mvc\Router\Http\Segment', + 'type' => 'Zend\Router\Http\Segment', 'options' => array( 'route' => '/supprimer/:id', ), ), 'modifier' => array( - 'type' => 'Zend\Mvc\Router\Http\Segment', + 'type' => 'Zend\Router\Http\Segment', 'options' => array( 'route' => '/modifier/:id', ), ), 'envoyer' => array( - 'type' => 'Zend\Mvc\Router\Http\Segment', + 'type' => 'Zend\Router\Http\Segment', 'options' => array( 'route' => '/envoyer/:id', ), diff --git a/tests/UnicaenAppTest/View/Helper/Navigation/_files/routes/menu-secondaire/routes.php b/tests/UnicaenAppTest/View/Helper/Navigation/_files/routes/menu-secondaire/routes.php index b928133d4c36c3940c88f50ee88a1890eb750f47..09d8069e91cff9e6456bc8833b61cf1668e6dbb4 100644 --- a/tests/UnicaenAppTest/View/Helper/Navigation/_files/routes/menu-secondaire/routes.php +++ b/tests/UnicaenAppTest/View/Helper/Navigation/_files/routes/menu-secondaire/routes.php @@ -1,52 +1,52 @@ <?php return array( 'home' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/', ), ), 'apropos' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/apropos', ), ), 'contact' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/contact', ), 'may_terminate' => true, 'child_routes' => array( 'ajouter' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/ajouter', ), 'may_terminate' => true, 'child_routes' => array( 'identite' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/identite', ), ), 'adresse' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/adresse', ), 'may_terminate' => true, 'child_routes' => array( 'postale' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/adresse-postale', ), ), 'mail' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/adresse-mail', ), @@ -54,7 +54,7 @@ return array( ), ), 'message' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/message', ), @@ -62,14 +62,14 @@ return array( ), ), 'modifier' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/modifier', ), 'may_terminate' => true, 'child_routes' => array( 'identite' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/identite', ),