propel-bundle/Command/BuildModelCommand.php

60 lines
1.8 KiB
PHP
Raw Normal View History

2010-10-28 14:41:03 +02:00
<?php
namespace Propel\PropelBundle\Command;
2010-10-28 14:41:03 +02:00
use Propel\PropelBundle\Command\PhingCommand;
2010-10-28 14:41:03 +02:00
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* BuildCommand.
*
* @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
*/
class BuildModelCommand extends PhingCommand
{
/**
* @see Command
*/
protected function configure()
{
$this
->setDescription('Build the Propel Object Model classes based on XML schemas')
->setHelp(<<<EOT
2011-02-02 02:05:36 +01:00
The <info>propel:build-model</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
2011-02-02 02:05:36 +01:00
<info>php app/console propel:build-model</info>
2010-10-28 14:41:03 +02:00
EOT
)
->setName('propel:build-model')
;
}
/**
* @see Command
*
* @throws \InvalidArgumentException When the target directory does not exist
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('verbose')) {
2011-06-22 16:47:19 +02:00
$this->additionalPhingArgs[] = 'verbose';
}
2010-10-28 14:41:03 +02:00
2011-08-30 11:52:50 +02:00
$this->writeSection($output, '[Propel] You are running the command: propel:build-model');
2011-06-22 16:47:19 +02:00
2011-08-30 11:52:50 +02:00
if (true === $this->callPhing('om')) {
foreach ($this->tempSchemas as $schemaFile => $schemaDetails) {
$output->writeln(sprintf(
'Built Model classes for bundle <info>%s</info> from <comment>%s</comment>.',
$schemaDetails['bundle'],
$schemaDetails['path']
));
}
} else {
$output->writeln('<error>WARNING ! An error has occured.</error>');
}
}
2010-10-28 14:41:03 +02:00
}