2013-10-15 23:48:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of the PropelBundle package.
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*
|
|
|
|
* @license MIT License
|
|
|
|
*/
|
|
|
|
|
2016-02-11 19:14:03 +01:00
|
|
|
namespace Propel\Bundle\PropelBundle\Command;
|
2013-10-15 23:48:33 +02:00
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
2013-12-12 17:48:16 +01:00
|
|
|
use Symfony\Component\Console\Input\ArrayInput;
|
2013-10-15 23:48:33 +02:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use Symfony\Component\Filesystem\Filesystem;
|
2013-10-31 22:05:29 +01:00
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|
|
|
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
2013-10-15 23:48:33 +02:00
|
|
|
use Symfony\Component\HttpKernel\KernelInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Kévin Gomez <contact@kevingomez.fr>
|
|
|
|
*/
|
|
|
|
abstract class AbstractCommand extends ContainerAwareCommand
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $cacheDir = null;
|
|
|
|
|
2013-10-31 22:05:29 +01:00
|
|
|
/**
|
2014-11-20 10:59:40 +01:00
|
|
|
* @var \Symfony\Component\HttpKernel\Bundle\BundleInterface
|
2013-10-31 22:05:29 +01:00
|
|
|
*/
|
|
|
|
protected $bundle = null;
|
|
|
|
|
2013-11-03 23:20:01 +01:00
|
|
|
/**
|
|
|
|
* @var InputInterface
|
|
|
|
*/
|
|
|
|
protected $input;
|
|
|
|
|
2016-03-27 03:16:43 +02:00
|
|
|
/**
|
|
|
|
* @var OutputInterface
|
|
|
|
*/
|
|
|
|
protected $output;
|
|
|
|
|
2013-11-04 22:32:14 +01:00
|
|
|
use FormattingHelpers;
|
|
|
|
|
2013-10-31 22:05:29 +01:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
protected function initialize(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
2013-11-04 11:45:37 +01:00
|
|
|
$kernel = $this->getApplication()->getKernel();
|
|
|
|
|
2013-11-03 23:20:01 +01:00
|
|
|
$this->input = $input;
|
2016-03-27 03:16:43 +02:00
|
|
|
$this->output = $output;
|
2013-11-04 11:45:37 +01:00
|
|
|
$this->cacheDir = $kernel->getCacheDir().'/propel';
|
2013-11-03 23:20:01 +01:00
|
|
|
|
2013-11-14 12:02:34 +01:00
|
|
|
if ($input->hasArgument('bundle') && '@' === substr($input->getArgument('bundle'), 0, 1)) {
|
2013-10-31 22:05:29 +01:00
|
|
|
$this->bundle = $this
|
|
|
|
->getContainer()
|
|
|
|
->get('kernel')
|
2013-11-14 12:02:34 +01:00
|
|
|
->getBundle(substr($input->getArgument('bundle'), 1));
|
2013-10-31 22:05:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-31 22:25:56 +01:00
|
|
|
/**
|
|
|
|
* Create all the files needed by Propel's commands.
|
|
|
|
*/
|
2013-10-15 23:48:33 +02:00
|
|
|
protected function setupBuildTimeFiles()
|
|
|
|
{
|
|
|
|
$kernel = $this->getApplication()->getKernel();
|
|
|
|
|
|
|
|
$fs = new Filesystem();
|
|
|
|
$fs->mkdir($this->cacheDir);
|
|
|
|
|
|
|
|
// collect all schemas
|
2013-10-31 22:05:29 +01:00
|
|
|
$this->copySchemas($kernel, $this->cacheDir);
|
2013-10-15 23:48:33 +02:00
|
|
|
|
2014-09-09 22:59:13 +02:00
|
|
|
// propel.json
|
|
|
|
$this->createPropelConfigurationFile($this->cacheDir.'/propel.json');
|
2013-10-15 23:48:33 +02:00
|
|
|
}
|
|
|
|
|
2013-10-31 22:05:29 +01:00
|
|
|
/**
|
2013-12-14 15:17:10 +01:00
|
|
|
* @param KernelInterface $kernel The application kernel.
|
|
|
|
* @param string $cacheDir The directory in which the schemas will
|
|
|
|
* be copied.
|
2013-10-31 22:05:29 +01:00
|
|
|
*/
|
|
|
|
protected function copySchemas(KernelInterface $kernel, $cacheDir)
|
|
|
|
{
|
|
|
|
$filesystem = new Filesystem();
|
|
|
|
|
|
|
|
$finalSchemas = $this->getFinalSchemas($kernel, $this->bundle);
|
|
|
|
foreach ($finalSchemas as $schema) {
|
2017-08-31 12:27:56 +02:00
|
|
|
/** @var null|Bundle $bundle */
|
2013-10-31 22:05:29 +01:00
|
|
|
list($bundle, $finalSchema) = $schema;
|
|
|
|
|
2017-08-31 12:27:56 +02:00
|
|
|
if ($bundle) {
|
|
|
|
$file = $cacheDir.DIRECTORY_SEPARATOR.'bundle-'.$bundle->getName().'-'.$finalSchema->getBaseName();
|
|
|
|
} else {
|
|
|
|
$file = $cacheDir.DIRECTORY_SEPARATOR.'app-'.$finalSchema->getBaseName();
|
|
|
|
}
|
2013-10-31 22:05:29 +01:00
|
|
|
|
|
|
|
$filesystem->copy((string) $finalSchema, $file, true);
|
|
|
|
|
|
|
|
// the package needs to be set absolute
|
|
|
|
// besides, the automated namespace to package conversion has
|
|
|
|
// not taken place yet so it needs to be done manually
|
|
|
|
$database = simplexml_load_file($file);
|
|
|
|
|
|
|
|
if (isset($database['package'])) {
|
|
|
|
// Do not use the prefix!
|
|
|
|
// This is used to override the package resulting from namespace conversion.
|
|
|
|
$database['package'] = $database['package'];
|
|
|
|
} elseif (isset($database['namespace'])) {
|
2017-08-31 12:27:56 +02:00
|
|
|
if ($bundle) {
|
|
|
|
$database['package'] = $this->getPackageFromBundle($bundle, (string)$database['namespace']);
|
|
|
|
} else {
|
|
|
|
$database['package'] = $this->getPackageFromApp((string)$database['namespace']);
|
|
|
|
}
|
2013-10-31 22:05:29 +01:00
|
|
|
} else {
|
|
|
|
throw new \RuntimeException(
|
2017-08-31 12:27:56 +02:00
|
|
|
sprintf(
|
|
|
|
'%s : Please define a `package` attribute or a `namespace` attribute for schema `%s`',
|
|
|
|
$bundle ? $bundle->getName() : 'App',
|
|
|
|
$finalSchema->getBaseName()
|
|
|
|
)
|
2013-10-31 22:05:29 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-11-03 23:20:01 +01:00
|
|
|
if ($this->input->hasOption('connection')) {
|
2014-09-09 22:59:13 +02:00
|
|
|
$connections = $this->input->getOption('connection') ?: array($this->getDefaultConnection());
|
2013-11-03 23:20:01 +01:00
|
|
|
|
2013-12-12 17:48:16 +01:00
|
|
|
if (!in_array((string) $database['name'], $connections)) {
|
2013-11-03 23:20:01 +01:00
|
|
|
// we skip this schema because the connection name doesn't
|
|
|
|
// match the input values
|
|
|
|
$filesystem->remove($file);
|
2016-03-27 03:16:43 +02:00
|
|
|
$this->output->writeln(sprintf(
|
|
|
|
'<info>Skipped schema %s due to database name missmatch (%s not in [%s]).</info>',
|
|
|
|
$finalSchema->getPathname(),
|
|
|
|
$database['name'],
|
|
|
|
implode(',', $connections)
|
|
|
|
));
|
2013-11-03 23:20:01 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2013-10-31 22:05:29 +01:00
|
|
|
|
|
|
|
foreach ($database->table as $table) {
|
|
|
|
if (isset($table['package'])) {
|
|
|
|
$table['package'] = $table['package'];
|
|
|
|
} elseif (isset($table['namespace'])) {
|
2017-08-31 12:27:56 +02:00
|
|
|
if ($bundle) {
|
|
|
|
$table['package'] = $this->getPackageFromBundle($bundle, (string)$table['namespace']);
|
|
|
|
} else {
|
|
|
|
$table['package'] = $this->getPackageFromApp((string)$table['namespace']);
|
|
|
|
}
|
2013-10-31 22:05:29 +01:00
|
|
|
} else {
|
|
|
|
$table['package'] = $database['package'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
file_put_contents($file, $database->asXML());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of final schema files that will be processed.
|
|
|
|
*
|
2013-12-14 15:17:10 +01:00
|
|
|
* @param KernelInterface $kernel The application kernel.
|
|
|
|
* @param BundleInterface $bundle If given, only the bundle's schemas will
|
|
|
|
* be returned.
|
2013-10-31 22:05:29 +01:00
|
|
|
*
|
2013-12-14 15:17:10 +01:00
|
|
|
* @return array A list of schemas.
|
2013-10-31 22:05:29 +01:00
|
|
|
*/
|
|
|
|
protected function getFinalSchemas(KernelInterface $kernel, BundleInterface $bundle = null)
|
|
|
|
{
|
|
|
|
if (null !== $bundle) {
|
2013-10-31 22:19:24 +01:00
|
|
|
return $this->getSchemaLocator()->locateFromBundle($bundle);
|
2013-10-31 22:05:29 +01:00
|
|
|
}
|
|
|
|
|
2017-08-31 12:27:56 +02:00
|
|
|
return $this->getSchemaLocator()->locateFromBundlesAndConfiguration($kernel->getBundles());
|
2013-10-31 22:05:29 +01:00
|
|
|
}
|
|
|
|
|
2013-12-14 15:17:10 +01:00
|
|
|
/**
|
|
|
|
* Run a Symfony command.
|
|
|
|
*
|
|
|
|
* @param Command $command The command to run.
|
|
|
|
* @param array $parameters An array of parameters to give to the command.
|
|
|
|
* @param InputInterface $input An InputInterface instance
|
|
|
|
* @param OutputInterface $output An OutputInterface instance
|
|
|
|
*
|
|
|
|
* @return int The command return code.
|
|
|
|
*/
|
2013-12-12 17:48:16 +01:00
|
|
|
protected function runCommand(Command $command, array $parameters, InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
|
|
|
// add the command's name to the parameters
|
|
|
|
array_unshift($parameters, $this->getName());
|
|
|
|
|
|
|
|
// merge the default parameters
|
2014-11-20 10:59:40 +01:00
|
|
|
$extraParameters = [
|
|
|
|
'--verbose' => $input->getOption('verbose')
|
|
|
|
];
|
|
|
|
|
|
|
|
if ($command->getDefinition()->hasOption('schema-dir')) {
|
|
|
|
$extraParameters['--schema-dir'] = $this->cacheDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($command->getDefinition()->hasOption('config-dir')) {
|
|
|
|
$extraParameters['--config-dir'] = $this->cacheDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
$parameters = array_merge($extraParameters, $parameters);
|
2013-12-12 17:48:16 +01:00
|
|
|
|
|
|
|
if ($input->hasOption('platform')) {
|
2014-11-27 11:06:02 +01:00
|
|
|
if ($platform = $input->getOption('platform') ?: $this->getPlatform()) {
|
|
|
|
$parameters['--platform'] = $platform;
|
|
|
|
}
|
2013-12-12 17:48:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$command->setApplication($this->getApplication());
|
|
|
|
|
|
|
|
// and run the sub-command
|
|
|
|
return $command->run(new ArrayInput($parameters), $output);
|
|
|
|
}
|
|
|
|
|
2014-09-15 14:34:24 +02:00
|
|
|
/**
|
2013-10-31 22:06:36 +01:00
|
|
|
* Create an XML file which represents propel.configuration
|
|
|
|
*
|
2014-09-09 22:59:13 +02:00
|
|
|
* @param string $file Should be 'propel.json'.
|
2013-10-31 22:06:36 +01:00
|
|
|
*/
|
2014-09-09 22:59:13 +02:00
|
|
|
protected function createPropelConfigurationFile($file)
|
2013-10-31 22:06:36 +01:00
|
|
|
{
|
2014-12-01 15:20:38 +01:00
|
|
|
$propelConfig = $this->getContainer()->getParameter('propel.configuration');
|
|
|
|
|
|
|
|
//needed because because Propel2's configuration tree is a bit different
|
|
|
|
//propel.runtime.logging is PropelBundle feature only.
|
|
|
|
unset($propelConfig['runtime']['logging']);
|
|
|
|
|
2014-09-09 22:59:13 +02:00
|
|
|
$config = array(
|
2014-12-01 15:20:38 +01:00
|
|
|
'propel' => $propelConfig
|
2014-09-09 22:59:13 +02:00
|
|
|
);
|
2013-10-31 22:06:36 +01:00
|
|
|
|
2014-09-09 22:59:13 +02:00
|
|
|
file_put_contents($file, json_encode($config, JSON_PRETTY_PRINT));
|
2013-10-31 22:06:36 +01:00
|
|
|
}
|
|
|
|
|
2013-10-31 21:39:12 +01:00
|
|
|
/**
|
|
|
|
* Translates a list of connection names to their DSN equivalents.
|
|
|
|
*
|
|
|
|
* @param array $connections The names.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2013-10-15 23:48:33 +02:00
|
|
|
protected function getConnections(array $connections)
|
|
|
|
{
|
|
|
|
$dsnList = array();
|
|
|
|
foreach ($connections as $connection) {
|
2013-11-03 22:50:33 +01:00
|
|
|
$dsnList[] = sprintf('%s=%s', $connection, $this->getDsn($connection));
|
2013-10-15 23:48:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $dsnList;
|
|
|
|
}
|
|
|
|
|
2013-12-14 15:17:10 +01:00
|
|
|
/**
|
|
|
|
* Get the data (host, user, ...) for a given connection.
|
|
|
|
*
|
|
|
|
* @param string $name The connection name.
|
|
|
|
*
|
|
|
|
* @return array The connection data.
|
|
|
|
*/
|
2013-11-03 22:50:33 +01:00
|
|
|
protected function getConnectionData($name)
|
2013-10-15 23:48:33 +02:00
|
|
|
{
|
2013-11-03 22:50:33 +01:00
|
|
|
$knownConnections = $this->getContainer()->getParameter('propel.configuration');
|
2014-09-09 22:59:13 +02:00
|
|
|
if (!isset($knownConnections['database']['connections'][$name])) {
|
2013-11-03 22:50:33 +01:00
|
|
|
throw new \InvalidArgumentException(sprintf('Unknown connection "%s"', $name));
|
|
|
|
}
|
|
|
|
|
2014-09-09 22:59:13 +02:00
|
|
|
return $knownConnections['database']['connections'][$name];
|
2013-11-03 22:50:33 +01:00
|
|
|
}
|
|
|
|
|
2013-12-14 15:17:10 +01:00
|
|
|
/**
|
|
|
|
* Get the DSN for a given connection.
|
|
|
|
*
|
|
|
|
* @param string $connectionName The connection name.
|
|
|
|
*
|
|
|
|
* @return string The DSN.
|
|
|
|
*/
|
2013-11-03 22:50:33 +01:00
|
|
|
protected function getDsn($connectionName)
|
|
|
|
{
|
|
|
|
$connection = $this->getConnectionData($connectionName);
|
2015-03-11 10:38:38 +01:00
|
|
|
// Add user and password to dsn string
|
|
|
|
$dsn = explode(';', $connection['dsn']);
|
|
|
|
if (isset($connection['user'])) {
|
|
|
|
$dsn[] = 'user=' . urlencode($connection['user']);
|
|
|
|
}
|
|
|
|
if (isset($connection['password'])) {
|
|
|
|
$dsn[] = 'password=' . urlencode($connection['password']);
|
|
|
|
}
|
2013-11-03 22:50:33 +01:00
|
|
|
|
2015-10-22 11:19:59 +02:00
|
|
|
return implode(';', $dsn);
|
2013-10-15 23:48:33 +02:00
|
|
|
}
|
2013-10-31 22:05:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Symfony\Component\Config\FileLocatorInterface
|
|
|
|
*/
|
2013-10-31 22:19:24 +01:00
|
|
|
protected function getSchemaLocator()
|
2013-10-31 22:05:29 +01:00
|
|
|
{
|
2013-10-31 22:19:24 +01:00
|
|
|
return $this->getContainer()->get('propel.schema_locator');
|
2013-10-31 22:05:29 +01:00
|
|
|
}
|
|
|
|
|
2017-08-31 12:27:56 +02:00
|
|
|
/**
|
|
|
|
* @param string $namespace
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getPackageFromApp($namespace)
|
|
|
|
{
|
|
|
|
if ('\\' === $namespace[0]) {
|
|
|
|
$namespace = substr($namespace, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 === stripos($namespace, 'App\\')) {
|
|
|
|
$namespace = substr($namespace, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'src.'.str_replace('\\', '.', $namespace);
|
|
|
|
}
|
|
|
|
|
2013-10-31 22:05:29 +01:00
|
|
|
/**
|
|
|
|
* @param Bundle $bundle
|
2016-03-27 03:16:43 +02:00
|
|
|
* @param string $namespace
|
2013-10-31 22:05:29 +01:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-03-27 03:16:43 +02:00
|
|
|
protected function getPackageFromBundle(Bundle $bundle, $namespace)
|
2013-10-31 22:05:29 +01:00
|
|
|
{
|
2016-03-27 03:16:43 +02:00
|
|
|
//find relative path from namespace to bundle->getNamespace()
|
|
|
|
$baseNamespace = (new \ReflectionClass($bundle))->getNamespaceName();
|
|
|
|
if (0 === strpos($namespace, $baseNamespace)) {
|
|
|
|
//base namespace fits
|
|
|
|
//eg.
|
|
|
|
// Base: Jarves/JarvesBundle => Jarves
|
|
|
|
// Model namespace: Jarves\Model
|
|
|
|
// strpos(Jarves\Model, Jarves) === 0
|
|
|
|
// $namespaceDiff = Model
|
2013-10-31 22:05:29 +01:00
|
|
|
|
2016-03-27 03:16:43 +02:00
|
|
|
$namespaceDiff = substr($namespace, strlen($baseNamespace) + 1);
|
2013-10-31 22:05:29 +01:00
|
|
|
|
2016-03-27 03:16:43 +02:00
|
|
|
$bundlePath = realpath($bundle->getPath()) . '/' . str_replace('\\', '/', $namespaceDiff);
|
|
|
|
$appPath = realpath($this->getApplication()->getKernel()->getRootDir() . '/..');
|
|
|
|
|
|
|
|
$path = static::getRelativePath($bundlePath, $appPath);
|
|
|
|
|
|
|
|
return str_replace('/', '.', $path);
|
2013-10-31 22:05:29 +01:00
|
|
|
}
|
|
|
|
|
2016-03-27 03:16:43 +02:00
|
|
|
//does not match or its a absolute path, so return it without suffix
|
|
|
|
if ('\\' === $namespace[0]) {
|
|
|
|
$namespace = substr($namespace, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return str_replace('\\', '.', $namespace);
|
2013-10-31 22:05:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the current Propel cache directory.
|
|
|
|
*
|
|
|
|
* @return string The current Propel cache directory.
|
|
|
|
*/
|
|
|
|
protected function getCacheDir()
|
|
|
|
{
|
|
|
|
return $this->cacheDir;
|
|
|
|
}
|
2013-11-04 11:45:37 +01:00
|
|
|
|
2016-03-27 03:16:43 +02:00
|
|
|
/**
|
|
|
|
* Returns a relative path from $path to $current.
|
|
|
|
*
|
|
|
|
* @param string $from
|
|
|
|
* @param string $to relative to this
|
|
|
|
*
|
|
|
|
* @return string relative path without trailing slash
|
|
|
|
*/
|
|
|
|
public static function getRelativePath($from, $to)
|
|
|
|
{
|
|
|
|
$from = '/' . trim($from, '/');
|
|
|
|
$to = '/' . trim($to, '/');
|
|
|
|
|
|
|
|
if (0 === $pos = strpos($from, $to)) {
|
|
|
|
return substr($from, strlen($to) + ('/' === $to ? 0 : 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = '';
|
|
|
|
while ($to && false === strpos($from, $to)) {
|
|
|
|
$result .= '../';
|
|
|
|
$to = substr($to, 0, strrpos($to, '/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return !$to /*we reached root*/ ? $result . substr($from, 1) : $result. substr($from, strlen($to) + 1);
|
|
|
|
}
|
|
|
|
|
2013-11-04 22:41:59 +01:00
|
|
|
/**
|
|
|
|
* Extract the database name from a given DSN
|
|
|
|
*
|
2013-11-05 14:26:18 +01:00
|
|
|
* @param string $dsn A DSN
|
2013-11-04 22:41:59 +01:00
|
|
|
* @return string The database name extracted from the given DSN
|
|
|
|
*/
|
|
|
|
protected function parseDbName($dsn)
|
|
|
|
{
|
2017-01-09 12:30:41 +01:00
|
|
|
preg_match('#(dbname|Database)=([a-zA-Z0-9\_]+)#', $dsn, $matches);
|
2013-11-04 22:41:59 +01:00
|
|
|
|
2017-01-09 12:30:41 +01:00
|
|
|
if (isset($matches[2])) {
|
|
|
|
return $matches[2];
|
2013-11-04 22:41:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// e.g. SQLite
|
|
|
|
return null;
|
|
|
|
}
|
2014-09-09 22:59:13 +02:00
|
|
|
|
2014-09-15 14:34:41 +02:00
|
|
|
/**
|
|
|
|
* Returns the name of the migrations table.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getMigrationsTable()
|
|
|
|
{
|
|
|
|
$config = $this->getContainer()->getParameter('propel.configuration');
|
|
|
|
|
|
|
|
return $config['migrations']['tableName'];
|
|
|
|
}
|
|
|
|
|
2014-09-09 22:59:13 +02:00
|
|
|
/**
|
|
|
|
* Returns the name of the default connection.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getDefaultConnection()
|
|
|
|
{
|
|
|
|
$config = $this->getContainer()->getParameter('propel.configuration');
|
|
|
|
|
2014-11-21 14:01:36 +01:00
|
|
|
return !empty($config['generator']['defaultConnection']) ? $config['generator']['defaultConnection'] : key($config['database']['connections']);
|
2014-09-09 22:59:13 +02:00
|
|
|
}
|
2014-09-15 14:45:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reads the platform class from the configuration
|
|
|
|
*
|
2014-11-20 10:59:40 +01:00
|
|
|
* @return string The platform class name.
|
2014-09-15 14:45:18 +02:00
|
|
|
*/
|
|
|
|
protected function getPlatform()
|
|
|
|
{
|
|
|
|
$config = $this->getContainer()->getParameter('propel.configuration');
|
2014-11-20 10:59:40 +01:00
|
|
|
return $config['generator']['platformClass'];
|
2014-09-15 14:45:18 +02:00
|
|
|
}
|
2013-10-15 23:48:33 +02:00
|
|
|
}
|