2010-10-28 14:41:03 +02:00
|
|
|
<?php
|
|
|
|
|
2011-08-30 23:29:49 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-02-14 22:31:28 +01:00
|
|
|
namespace Propel\PropelBundle\Command;
|
2010-10-28 14:41:03 +02:00
|
|
|
|
2012-04-20 13:54:05 +02:00
|
|
|
use Propel\PropelBundle\Command\AbstractCommand;
|
2010-10-28 14:41:03 +02:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
2012-04-20 02:20:54 +02:00
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
2012-10-23 01:02:00 +02:00
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
2010-10-28 14:41:03 +02:00
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
/**
|
2012-04-07 21:58:45 +02:00
|
|
|
* ModelBuildCommand.
|
2010-10-28 14:41:03 +02:00
|
|
|
*
|
|
|
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
2011-03-25 16:24:34 +01:00
|
|
|
* @author William DURAND <william.durand1@gmail.com>
|
2010-10-28 14:41:03 +02:00
|
|
|
*/
|
2012-04-20 13:54:05 +02:00
|
|
|
class ModelBuildCommand extends AbstractCommand
|
2010-10-28 14:41:03 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @see Command
|
|
|
|
*/
|
|
|
|
protected function configure()
|
|
|
|
{
|
|
|
|
$this
|
|
|
|
->setDescription('Build the Propel Object Model classes based on XML schemas')
|
2012-04-20 02:20:54 +02:00
|
|
|
->addArgument('bundle', InputArgument::OPTIONAL, 'The bundle to generate model classes from')
|
2012-10-23 01:02:00 +02:00
|
|
|
->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use')
|
2010-10-28 14:41:03 +02:00
|
|
|
->setHelp(<<<EOT
|
2012-04-07 21:58:45 +02:00
|
|
|
The <info>%command.name%</info> command builds the Propel runtime model classes (ActiveRecord, Query, Peer, and TableMap classes) based on the XML schemas defined in all Bundles.
|
2010-10-28 14:41:03 +02:00
|
|
|
|
2012-04-07 21:58:45 +02:00
|
|
|
<info>php app/console %command.full_name%</info>
|
2010-10-28 14:41:03 +02:00
|
|
|
EOT
|
|
|
|
)
|
2012-04-07 21:58:45 +02:00
|
|
|
->setName('propel:model:build')
|
2010-10-28 14:41:03 +02:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see Command
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException When the target directory does not exist
|
|
|
|
*/
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
2011-08-30 11:52:50 +02:00
|
|
|
if (true === $this->callPhing('om')) {
|
2011-06-20 09:41:00 +02:00
|
|
|
foreach ($this->tempSchemas as $schemaFile => $schemaDetails) {
|
2011-08-31 16:12:56 +02:00
|
|
|
$output->writeln(sprintf(
|
2011-09-23 14:34:07 +02:00
|
|
|
'>> <info>%20s</info> Generated model classes from <comment>%s</comment>',
|
2011-08-31 16:12:56 +02:00
|
|
|
$schemaDetails['bundle'],
|
|
|
|
$schemaDetails['basename']
|
|
|
|
));
|
2011-06-20 09:41:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
2011-08-31 16:12:56 +02:00
|
|
|
$this->writeTaskError($output, 'om');
|
2011-04-13 17:01:55 +02:00
|
|
|
}
|
|
|
|
}
|
2010-10-28 14:41:03 +02:00
|
|
|
}
|