Skip to content
Snippets Groups Projects
Select Git revision
  • b10b15e6e155b5a3af7f65e015bebf63f74b4562
  • master default
  • php8.2-docker-services
  • 6.x
  • laminas
  • bertrand.gauthier-master-patch-70311
  • bertrand.gauthier-master-patch-87168
  • laminas_migration
  • sqlite
  • 4.0.0
  • 3.2.1
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 1.0.1
  • 1.0.0
16 results

unicaen-code.global.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    IndexController.php 6.07 KiB
    <?php
    
    namespace UnicaenOracle\Controller;
    
    use Doctrine\DBAL\Connection;
    use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
    use UnicaenOracle\Service\Traits\DataServiceAwareTrait;
    use UnicaenOracle\Service\Traits\SchemaServiceAwareTrait;
    use Zend\Log\LoggerAwareTrait;
    use Zend\Mvc\Controller\AbstractActionController;
    use Zend\ServiceManager\ServiceLocatorAwareTrait;
    
    class IndexController extends AbstractActionController implements ServiceLocatorAwareInterface
    {
        use ServiceLocatorAwareTrait;
        use SchemaServiceAwareTrait;
        use DataServiceAwareTrait;
        use LoggerAwareTrait;
    
        /**
         * Action en mode CLI.
         */
        public function generateScriptForSchemaClearingConsoleAction()
        {
            $destDir = $this->params('output-dir', '/tmp'); // ex: '/tmp'
            $connName = $this->params('connection', 'doctrine.connection.orm_default');
    
            /** @var Connection $connection */
            $connection = $this->getServiceLocator()->get($connName);
            $schemaName = $this->schemaService->extractSchemaNameFromConnection($connection);
    
            $this->log("=====================================");
            $this->log(" Db schema clearing script generator");
            $this->log("=====================================");
    
            $this->log("# Generating database clearing scripts...");
            $outputFilePath = $destDir . "/oracle-clear-schema-$schemaName.sql";
            $this->schemaService->createSchemaClearingScriptFile($connection, $outputFilePath);
            $this->log($outputFilePath);
    
            $this->log("Done.");
    
            exit(0);
        }
    
        /**
         * Action en mode CLI.
         */
        public function generateScriptForSchemaCreationConsoleAction()
        {
            $destDir = $this->params('output-dir', '/tmp'); // ex: '/tmp'
            $srcConnName = $this->params('src-connection', 'doctrine.connection.orm_default');
            $dstConnName = $this->params('dst-connection', 'doctrine.connection.orm_default');
            $refConstraintsIncluded = (bool) $this->params('ref-constraints-included', 1);
    
            /** @var Connection $srcConn */
            /** @var Connection $dstConn */
            $srcConn = $this->getServiceLocator()->get($srcConnName);
            $dstConn = $this->getServiceLocator()->get($dstConnName);
    
            $srcSchemaName = $this->schemaService->extractSchemaNameFromConnection($srcConn);
            $dstSchemaName = $this->schemaService->extractSchemaNameFromConnection($dstConn);
    
            $this->log("=====================================");
            $this->log(" Db schema creation script generator");
            $this->log("=====================================");
    
            $this->log("# Generating schema creation script " . ($refConstraintsIncluded ? 'with' : 'without') . ' ref constraints...');
            $outputFilePath = $destDir . "/oracle-generate-schema-$dstSchemaName-from-$srcSchemaName.sql";
            $this->schemaService->createSchemaCreationScriptFile($srcConn, $dstConn, $refConstraintsIncluded, $outputFilePath);