diff --git a/src/UnicaenOracle/Controller/Factory/IndexControllerFactory.php b/src/UnicaenOracle/Controller/Factory/IndexControllerFactory.php index a0723e01ff5bb98311facbd5547d88a5fc9a0068..cbeacb00e0e3e30983be7ff80c3767f9a735696f 100644 --- a/src/UnicaenOracle/Controller/Factory/IndexControllerFactory.php +++ b/src/UnicaenOracle/Controller/Factory/IndexControllerFactory.php @@ -2,10 +2,10 @@ namespace UnicaenOracle\Controller\Factory; +use Interop\Container\ContainerInterface; use UnicaenOracle\Controller\IndexController; use UnicaenOracle\Service\DataService; use UnicaenOracle\Service\SchemaService; -use Zend\Mvc\Controller\ControllerManager; /** * @@ -15,25 +15,21 @@ use Zend\Mvc\Controller\ControllerManager; class IndexControllerFactory { /** - * @param ControllerManager $manager + * @param ContainerInterface $container * @return IndexController */ - public function __invoke(ControllerManager $manager) + public function __invoke(ContainerInterface $container) { - $sl = $manager->getServiceLocator(); - /** @var SchemaService $schemaService */ - $schemaService = $sl->get(SchemaService::class); + $schemaService = $container->get(SchemaService::class); /** @var DataService $dataService */ - $dataService = $sl->get(DataService::class); + $dataService = $container->get(DataService::class); $controller = new IndexController(); $controller->setSchemaService($schemaService); $controller->setDataService($dataService); - - // todo: ne plus injecter le service locator, svp! - $controller->setServiceLocator($manager->getServiceLocator()); + $controller->setContainer($container); return $controller; } diff --git a/src/UnicaenOracle/Controller/IndexController.php b/src/UnicaenOracle/Controller/IndexController.php index 090ee75e2043a48e8869050caccf9ac3231c2c2b..9c1324f34bb9668a51a8db6e4949fb1ae6ac800f 100644 --- a/src/UnicaenOracle/Controller/IndexController.php +++ b/src/UnicaenOracle/Controller/IndexController.php @@ -3,20 +3,31 @@ namespace UnicaenOracle\Controller; use Doctrine\DBAL\Connection; +use Interop\Container\ContainerInterface; use UnicaenOracle\Service\Traits\DataServiceAwareTrait; use UnicaenOracle\Service\Traits\SchemaServiceAwareTrait; use Zend\Log\LoggerAwareTrait; use Zend\Mvc\Controller\AbstractActionController; -use Zend\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorAwareTrait; -class IndexController extends AbstractActionController implements ServiceLocatorAwareInterface +class IndexController extends AbstractActionController { - use ServiceLocatorAwareTrait; use SchemaServiceAwareTrait; use DataServiceAwareTrait; use LoggerAwareTrait; + /** + * @var ContainerInterface + */ + protected $container; + + /** + * @param ContainerInterface $container + */ + public function setContainer(ContainerInterface $container) + { + $this->container = $container; + } + /** * Action en mode CLI. */ @@ -26,7 +37,7 @@ class IndexController extends AbstractActionController implements ServiceLocator $connName = $this->params('connection', 'doctrine.connection.orm_default'); /** @var Connection $connection */ - $connection = $this->getServiceLocator()->get($connName); + $connection = $this->container->get($connName); $schemaName = $this->schemaService->extractSchemaNameFromConnection($connection); $this->log("====================================="); @@ -55,8 +66,8 @@ class IndexController extends AbstractActionController implements ServiceLocator /** @var Connection $srcConn */ /** @var Connection $dstConn */ - $srcConn = $this->getServiceLocator()->get($srcConnName); - $dstConn = $this->getServiceLocator()->get($dstConnName); + $srcConn = $this->container->get($srcConnName); + $dstConn = $this->container->get($dstConnName); $srcSchemaName = $this->schemaService->extractSchemaNameFromConnection($srcConn); $dstSchemaName = $this->schemaService->extractSchemaNameFromConnection($dstConn); @@ -87,8 +98,8 @@ class IndexController extends AbstractActionController implements ServiceLocator /** @var Connection $srcConn */ /** @var Connection $dstConn */ - $srcConn = $this->getServiceLocator()->get($srcConnName); - $dstConn = $this->getServiceLocator()->get($dstConnName); + $srcConn = $this->container->get($srcConnName); + $dstConn = $this->container->get($dstConnName); $srcSchemaName = $this->schemaService->extractSchemaNameFromConnection($srcConn); $dstSchemaName = $this->schemaService->extractSchemaNameFromConnection($dstConn); @@ -121,8 +132,8 @@ class IndexController extends AbstractActionController implements ServiceLocator /** @var Connection $srcConn */ /** @var Connection $dstConn */ - $srcConn = $this->getServiceLocator()->get($srcConnName); - $dstConn = $this->getServiceLocator()->get($dstConnName); + $srcConn = $this->container->get($srcConnName); + $dstConn = $this->container->get($dstConnName); $srcSchemaName = $this->schemaService->extractSchemaNameFromConnection($srcConn); $dstSchemaName = $this->schemaService->extractSchemaNameFromConnection($dstConn); diff --git a/src/UnicaenOracle/Service/SchemaService.php b/src/UnicaenOracle/Service/SchemaService.php index 5afcc0ab557c4b9bf5681eacc823a7a462b840e8..f486e5c01a9bc88dbf329832825d5b1b3a3e3491 100644 --- a/src/UnicaenOracle/Service/SchemaService.php +++ b/src/UnicaenOracle/Service/SchemaService.php @@ -239,7 +239,7 @@ WITH TMP(CATEG, NAME, SQL) AS ( -- constraints -- - -- d'abord les FK + -- les FK en premier select 'I_CONSTRAINT', constraint_name, 'ALTER TABLE ' || OWNER || '.' || table_name || ' drop CONSTRAINT ' || constraint_name || ';' || chr(10) from all_constraints where constraint_type = 'R'