Select Git revision
IndexController.php
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
IndexController.php 6.21 KiB
<?php
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;
class IndexController extends AbstractActionController
{
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.
*/
public function generateScriptForSchemaClearingConsoleAction()
{
$destDir = $this->params('output-dir', '/tmp'); // ex: '/tmp'
$connName = $this->params('connection', 'doctrine.connection.orm_default');
/** @var Connection $connection */
$connection = $this->container->get($connName);
$schemaName = $this->schemaService->extractSchemaNameFromConnection($connection);
$this->log("=====================================");
$this->log(" Db schema clearing script generator");
$this->log("=====================================");
$this->log("# Generating database clearing scripts from schema $schemaName...");
$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->container->get($srcConnName);
$dstConn = $this->container->get($dstConnName);