Skip to content

Instantly share code, notes, and snippets.

@b-b3rn4rd
Last active December 20, 2015 19:09
Show Gist options
  • Save b-b3rn4rd/6180804 to your computer and use it in GitHub Desktop.
Save b-b3rn4rd/6180804 to your computer and use it in GitHub Desktop.
Allow 'orm:schema-tool:update' to filter entities
<?php
namespace My\Doctrine\ORM\Tools\Console\Command\SchemaTool;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand as UpdateCommand2,
Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console\Input\InputInterface,
Symfony\Component\Console\Output\OutputInterface,
Doctrine\ORM\Tools\SchemaTool,
Doctrine\ORM\Tools\Console\MetadataFilter;
class UpdateCommand extends UpdateCommand2
{
protected function configure()
{
parent::configure();
$this->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.');
}
protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
{
$metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
parent::executeSchemaCommand($input, $output, $schemaTool, $metadatas);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment