Skip to content
Snippets Groups Projects
Commit e60f3ba0 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Passage à ZF3

parent c233f0a0
No related branches found
No related tags found
No related merge requests found
Pipeline #5241 failed
<?php <?php
namespace UnicaenTbl\Controller\Factory; namespace UnicaenTbl\Controller\Factory;
use Interop\Container\ContainerInterface;
use UnicaenTbl\Controller\AdminController; use UnicaenTbl\Controller\AdminController;
use UnicaenTbl\Form\ActualisationForm; use UnicaenTbl\Form\ActualisationForm;
use UnicaenTbl\Service\QueryGeneratorService; use UnicaenTbl\Service\QueryGeneratorService;
use UnicaenTbl\Service\SchemaService; use UnicaenTbl\Service\SchemaService;
use UnicaenTbl\Service\TableauBordService; use UnicaenTbl\Service\TableauBordService;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class AdminControllerFactory implements FactoryInterface class AdminControllerFactory
{ {
/** public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
*
* @return AdminController
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{ {
$controller = new AdminController(); $controller = new AdminController();
$sl = $serviceLocator->getServiceLocator();
$controller->setServiceSchema( $controller->setServiceSchema(
$sl->get(SchemaService::class) $container->get(SchemaService::class)
); );
$controller->setServiceQueryGenerator( $controller->setServiceQueryGenerator(
$sl->get(QueryGeneratorService::class) $container->get(QueryGeneratorService::class)
); );
$controller->setServiceTableauBord( $controller->setServiceTableauBord(
$sl->get(TableauBordService::class) $container->get(TableauBordService::class)
); );
$controller->setFormActualisation( $controller->setFormActualisation(
$sl->get('FormElementManager')->get(ActualisationForm::class) $container->get('FormElementManager')->get(ActualisationForm::class)
); );
return $controller; return $controller;
} }
} }
\ No newline at end of file
?>
\ No newline at end of file
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
namespace UnicaenTbl\Form\Factory; namespace UnicaenTbl\Form\Factory;
use Interop\Container\ContainerInterface;
use UnicaenTbl\Form\ActualisationForm; use UnicaenTbl\Form\ActualisationForm;
use Zend\Form\FormElementManager;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/** /**
...@@ -13,18 +11,10 @@ use Zend\ServiceManager\ServiceLocatorInterface; ...@@ -13,18 +11,10 @@ use Zend\ServiceManager\ServiceLocatorInterface;
* *
* @author LECLUSE Laurent <laurent.lecluse at unicaen.fr> * @author LECLUSE Laurent <laurent.lecluse at unicaen.fr>
*/ */
class ActualisationFormFactory implements FactoryInterface { class ActualisationFormFactory
/** {
* Create service public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
*
* @param ServiceLocatorInterface $serviceLocator
*
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{ {
$sl = $serviceLocator->getServiceLocator();
$form = new ActualisationForm(); $form = new ActualisationForm();
return $form; return $form;
......
...@@ -2,27 +2,21 @@ ...@@ -2,27 +2,21 @@
namespace UnicaenTbl\Options\Factory; namespace UnicaenTbl\Options\Factory;
use Interop\Container\ContainerInterface;
use UnicaenTbl\Options\ModuleOptions; use UnicaenTbl\Options\ModuleOptions;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/** /**
* Description of ModuleOptionsFactory * Description of ModuleOptionsFactory
* *
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/ */
class ModuleOptionsFactory implements FactoryInterface class ModuleOptionsFactory
{ {
/** public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{ {
$config = $serviceLocator->get('Configuration'); $config = $container->get('Configuration');
return new ModuleOptions(isset($config['unicaen-tbl']) ? $config['unicaen-tbl'] : []); return new ModuleOptions(isset($config['unicaen-tbl']) ? $config['unicaen-tbl'] : []);
} }
} }
\ No newline at end of file
<?php <?php
namespace UnicaenTbl\Service\Factory; namespace UnicaenTbl\Service\Factory;
use Interop\Container\ContainerInterface;
use UnicaenTbl\Options\ModuleOptions; use UnicaenTbl\Options\ModuleOptions;
use UnicaenTbl\Service\QueryGeneratorService; use UnicaenTbl\Service\QueryGeneratorService;
use UnicaenTbl\Service\SchemaService; use UnicaenTbl\Service\SchemaService;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/** /**
...@@ -13,20 +13,21 @@ use Zend\ServiceManager\ServiceLocatorInterface; ...@@ -13,20 +13,21 @@ use Zend\ServiceManager\ServiceLocatorInterface;
* *
* @author LECLUSE Laurent <laurent.lecluse at unicaen.fr> * @author LECLUSE Laurent <laurent.lecluse at unicaen.fr>
*/ */
class QueryGeneratorServiceFactory implements FactoryInterface { class QueryGeneratorServiceFactory
{
public function createService(ServiceLocatorInterface $serviceLocator) public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{ {
$queryGenerator = new QueryGeneratorService(); $queryGenerator = new QueryGeneratorService();
/** @var ModuleOptions $options */ /** @var ModuleOptions $options */
$options = $serviceLocator->get(ModuleOptions::class); $options = $container->get(ModuleOptions::class);
$em = $serviceLocator->get($options->getEntityManagerName()); /* @var $em \Doctrine\ORM\EntityManager */ $em = $container->get($options->getEntityManagerName());
/* @var $em \Doctrine\ORM\EntityManager */
$queryGenerator->setOptionsModule($options); $queryGenerator->setOptionsModule($options);
$queryGenerator->setEntityManager($em); $queryGenerator->setEntityManager($em);
$queryGenerator->setServiceSchema( $serviceLocator->get(SchemaService::class) ); $queryGenerator->setServiceSchema($container->get(SchemaService::class));
return $queryGenerator; return $queryGenerator;
} }
......
<?php <?php
namespace UnicaenTbl\Service\Factory; namespace UnicaenTbl\Service\Factory;
use Interop\Container\ContainerInterface;
use UnicaenTbl\Options\ModuleOptions; use UnicaenTbl\Options\ModuleOptions;
use UnicaenTbl\Service\SchemaService; use UnicaenTbl\Service\SchemaService;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/** /**
...@@ -12,19 +12,21 @@ use Zend\ServiceManager\ServiceLocatorInterface; ...@@ -12,19 +12,21 @@ use Zend\ServiceManager\ServiceLocatorInterface;
* *
* @author LECLUSE Laurent <laurent.lecluse at unicaen.fr> * @author LECLUSE Laurent <laurent.lecluse at unicaen.fr>
*/ */
class SchemaServiceFactory implements FactoryInterface { class SchemaServiceFactory
{
public function createService(ServiceLocatorInterface $serviceLocator) public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{ {
$schema = new SchemaService(); $schema = new SchemaService();
/** @var ModuleOptions $options */ /** @var ModuleOptions $options */
$options = $serviceLocator->get(ModuleOptions::class); $options = $container->get(ModuleOptions::class);
$em = $serviceLocator->get($options->getEntityManagerName()); /* @var $em \Doctrine\ORM\EntityManager */ $em = $container->get($options->getEntityManagerName());
/* @var $em \Doctrine\ORM\EntityManager */
$schema->setEntityManager($em); $schema->setEntityManager($em);
return $schema; return $schema;
} }
} }
\ No newline at end of file
<?php <?php
namespace UnicaenTbl\Service\Factory; namespace UnicaenTbl\Service\Factory;
use Interop\Container\ContainerInterface;
use UnicaenTbl\Options\ModuleOptions; use UnicaenTbl\Options\ModuleOptions;
use UnicaenTbl\Service\TableauBordService; use UnicaenTbl\Service\TableauBordService;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/** /**
...@@ -12,16 +12,17 @@ use Zend\ServiceManager\ServiceLocatorInterface; ...@@ -12,16 +12,17 @@ use Zend\ServiceManager\ServiceLocatorInterface;
* *
* @author LECLUSE Laurent <laurent.lecluse at unicaen.fr> * @author LECLUSE Laurent <laurent.lecluse at unicaen.fr>
*/ */
class TableauBordServiceFactory implements FactoryInterface { class TableauBordServiceFactory
{
public function createService(ServiceLocatorInterface $serviceLocator) public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{ {
$tbl = new TableauBordService(); $tbl = new TableauBordService();
/** @var ModuleOptions $options */ /** @var ModuleOptions $options */
$options = $serviceLocator->get(ModuleOptions::class); $options = $container->get(ModuleOptions::class);
$em = $serviceLocator->get($options->getEntityManagerName()); /* @var $em \Doctrine\ORM\EntityManager */ $em = $container->get($options->getEntityManagerName());
/* @var $em \Doctrine\ORM\EntityManager */
$tbl->setEntityManager($em); $tbl->setEntityManager($em);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment