Infer the platform class name from the configuration

This commit is contained in:
Kévin Gomez 2014-09-15 13:45:18 +01:00
parent 23c05811d7
commit a9977bbcc4

View file

@ -186,7 +186,7 @@ abstract class AbstractCommand extends ContainerAwareCommand
), $parameters);
if ($input->hasOption('platform')) {
$parameters['--platform'] = $input->getOption('platform');
$parameters['--platform'] = $input->getOption('platform') ?: $this->getPlatform();
}
$command->setApplication($this->getApplication());
@ -339,4 +339,17 @@ abstract class AbstractCommand extends ContainerAwareCommand
return $config['generator']['defaultConnection'];
}
/**
* Reads the platform class from the configuration
*
* @return The platform class name.
*/
protected function getPlatform()
{
$config = $this->getContainer()->getParameter('propel.configuration');
$className = $config['generator']['platformClass'];
return ($pos = strrpos($className, '\\')) === false ? $className : substr($className, $pos + 1);
}
}