Skip to content

Instantly share code, notes, and snippets.

@jaspernbrouwer
Created April 5, 2012 19:24
Show Gist options
  • Save jaspernbrouwer/2313393 to your computer and use it in GitHub Desktop.
Save jaspernbrouwer/2313393 to your computer and use it in GitHub Desktop.
Symfony 2 console command proxy for Doctrine's ValidateSchemaCommand
<?php
// src/Nw/LibBundle/Command/ValidateSchemaCommand.php
namespace Nw\LibBundle\Command;
use Symfony\Bundle\DoctrineBundle\Command\Proxy\DoctrineCommandHelper;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;
use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand as DoctrineValidateSchemaCommand;
/**
* Command to validate that the current mapping is valid.
*
* @author Jasper N. Brouwer <jasper@nerdsweide.nl>
*/
class ValidateSchemaCommand extends DoctrineValidateSchemaCommand
{
/** {@inheritdoc} */
protected function configure()
{
parent::configure();
$this->setName( 'doctrine:schema:validate' )
->setDescription( 'Validate that the mapping files' )
->addOption( 'em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command' )
->setHelp( 'Validate that the mapping files are correct and in sync with the database.' );
}
/** {@inheritdoc} */
protected function execute( InputInterface $input, OutputInterface $output )
{
DoctrineCommandHelper::setApplicationEntityManager( $this->getApplication(), $input->getOption( 'em' ));
parent::execute( $input, $output );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment