Skip to content
Snippets Groups Projects
Select Git revision
  • 30e7b6e3dc57ec5417ecd7cba810f707ff1f527b
  • master default protected
  • release-1.3.10
  • popover-bootstrap-3.4
  • zf-3.x
  • 3.0.9
  • 3.0.8
  • 1.3.10
  • 3.0.7
  • 3.0.6
  • 3.0.5
  • 3.0.4
  • 3.0.3
  • 3.0.2
  • 3.0.1
  • 3.0.0
  • 1.3.9
  • 1.3.8
  • 1.3.7
  • 1.3.6
  • 1.3.5
  • 1.3.4
  • 1.3.3
  • 1.3.2
  • 1.3.1
25 results

Module.php

Blame
  • Forked from lib / unicaen / auth
    Source project has a limited visibility.
    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);