Initial commit with Symfony 2.1+Vendors
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
|
||||
/**
|
||||
* Database tool allows you to easily drop and create your configured databases.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class CreateDatabaseDoctrineCommand extends DoctrineCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('doctrine:database:create')
|
||||
->setDescription('Creates the configured databases')
|
||||
->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:database:create</info> command creates the default
|
||||
connections database:
|
||||
|
||||
<info>php app/console doctrine:database:create</info>
|
||||
|
||||
You can also optionally specify the name of a connection to create the
|
||||
database for:
|
||||
|
||||
<info>php app/console doctrine:database:create --connection=default</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$connection = $this->getDoctrineConnection($input->getOption('connection'));
|
||||
|
||||
$params = $connection->getParams();
|
||||
$name = isset($params['path']) ? $params['path'] : $params['dbname'];
|
||||
|
||||
unset($params['dbname']);
|
||||
|
||||
$tmpConnection = DriverManager::getConnection($params);
|
||||
|
||||
// Only quote if we don't have a path
|
||||
if (!isset($params['path'])) {
|
||||
$name = $tmpConnection->getDatabasePlatform()->quoteSingleIdentifier($name);
|
||||
}
|
||||
|
||||
try {
|
||||
$tmpConnection->getSchemaManager()->createDatabase($name);
|
||||
$output->writeln(sprintf('<info>Created database for connection named <comment>%s</comment></info>', $name));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>Could not create database for connection named <comment>%s</comment></error>', $name));
|
||||
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
|
||||
}
|
||||
|
||||
$tmpConnection->close();
|
||||
}
|
||||
}
|
55
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Command/DoctrineCommand.php
vendored
Normal file
55
vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Command/DoctrineCommand.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Doctrine\ORM\Tools\EntityGenerator;
|
||||
|
||||
/**
|
||||
* Base class for Doctrine console commands to extend from.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class DoctrineCommand extends ContainerAwareCommand
|
||||
{
|
||||
protected function getEntityGenerator()
|
||||
{
|
||||
$entityGenerator = new EntityGenerator();
|
||||
$entityGenerator->setGenerateAnnotations(false);
|
||||
$entityGenerator->setGenerateStubMethods(true);
|
||||
$entityGenerator->setRegenerateEntityIfExists(false);
|
||||
$entityGenerator->setUpdateEntityIfExists(true);
|
||||
$entityGenerator->setNumSpaces(4);
|
||||
$entityGenerator->setAnnotationPrefix('ORM\\');
|
||||
|
||||
return $entityGenerator;
|
||||
}
|
||||
|
||||
protected function getEntityManager($name)
|
||||
{
|
||||
return $this->getContainer()->get('doctrine')->getManager($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a doctrine dbal connection by symfony name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return Doctrine\DBAL\Connection
|
||||
*/
|
||||
protected function getDoctrineConnection($name)
|
||||
{
|
||||
return $this->getContainer()->get('doctrine')->getConnection($name);
|
||||
}
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Database tool allows you to easily drop and create your configured databases.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class DropDatabaseDoctrineCommand extends DoctrineCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('doctrine:database:drop')
|
||||
->setDescription('Drops the configured databases')
|
||||
->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
|
||||
->addOption('force', null, InputOption::VALUE_NONE, 'Set this parameter to execute this action')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:database:drop</info> command drops the default connections
|
||||
database:
|
||||
|
||||
<info>php app/console doctrine:database:drop</info>
|
||||
|
||||
The --force parameter has to be used to actually drop the database.
|
||||
|
||||
You can also optionally specify the name of a connection to drop the database
|
||||
for:
|
||||
|
||||
<info>php app/console doctrine:database:drop --connection=default</info>
|
||||
|
||||
<error>Be careful: All data in a given database will be lost when executing
|
||||
this command.</error>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$connection = $this->getDoctrineConnection($input->getOption('connection'));
|
||||
|
||||
$params = $connection->getParams();
|
||||
|
||||
$name = isset($params['path']) ? $params['path'] : (isset($params['dbname']) ? $params['dbname'] : false);
|
||||
|
||||
if (!$name) {
|
||||
throw new \InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.");
|
||||
}
|
||||
|
||||
if ($input->getOption('force')) {
|
||||
// Only quote if we don't have a path
|
||||
if (!isset($params['path'])) {
|
||||
$name = $connection->getDatabasePlatform()->quoteSingleIdentifier($name);
|
||||
}
|
||||
|
||||
try {
|
||||
$connection->getSchemaManager()->dropDatabase($name);
|
||||
$output->writeln(sprintf('<info>Dropped database for connection named <comment>%s</comment></info>', $name));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>Could not drop database for connection named <comment>%s</comment></error>', $name));
|
||||
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
|
||||
}
|
||||
} else {
|
||||
$output->writeln('<error>ATTENTION:</error> This operation should not be executed in a production environment.');
|
||||
$output->writeln('');
|
||||
$output->writeln(sprintf('<info>Would drop the database named <comment>%s</comment>.</info>', $name));
|
||||
$output->writeln('Please run the operation with --force to execute');
|
||||
$output->writeln('<error>All data will be lost!</error>');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\ORM\Tools\EntityRepositoryGenerator;
|
||||
use Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory;
|
||||
|
||||
/**
|
||||
* Generate entity classes from mapping information
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class GenerateEntitiesDoctrineCommand extends DoctrineCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('doctrine:generate:entities')
|
||||
->setAliases(array('generate:doctrine:entities'))
|
||||
->setDescription('Generates entity classes and method stubs from your mapping information')
|
||||
->addArgument('name', InputArgument::REQUIRED, 'A bundle name, a namespace, or a class name')
|
||||
->addOption('path', null, InputOption::VALUE_REQUIRED, 'The path where to generate entities when it cannot be guessed')
|
||||
->addOption('no-backup', null, InputOption::VALUE_NONE, 'Do not backup existing entities files.')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:generate:entities</info> command generates entity classes
|
||||
and method stubs from your mapping information:
|
||||
|
||||
You have to limit generation of entities:
|
||||
|
||||
* To a bundle:
|
||||
|
||||
<info>php app/console doctrine:generate:entities MyCustomBundle</info>
|
||||
|
||||
* To a single entity:
|
||||
|
||||
<info>php app/console doctrine:generate:entities MyCustomBundle:User</info>
|
||||
<info>php app/console doctrine:generate:entities MyCustomBundle/Entity/User</info>
|
||||
|
||||
* To a namespace
|
||||
|
||||
<info>php app/console doctrine:generate:entities MyCustomBundle/Entity</info>
|
||||
|
||||
If the entities are not stored in a bundle, and if the classes do not exist,
|
||||
the command has no way to guess where they should be generated. In this case,
|
||||
you must provide the <comment>--path</comment> option:
|
||||
|
||||
<info>php app/console doctrine:generate:entities Blog/Entity --path=src/</info>
|
||||
|
||||
By default, the unmodified version of each entity is backed up and saved
|
||||
(e.g. Product.php~). To prevent this task from creating the backup file,
|
||||
pass the <comment>--no-backup</comment> option:
|
||||
|
||||
<info>php app/console doctrine:generate:entities Blog/Entity --no-backup</info>
|
||||
|
||||
<error>Important:</error> Even if you specified Inheritance options in your
|
||||
XML or YAML Mapping files the generator cannot generate the base and
|
||||
child classes for you correctly, because it doesn't know which
|
||||
class is supposed to extend which. You have to adjust the entity
|
||||
code manually for inheritance to work!
|
||||
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$manager = new DisconnectedMetadataFactory($this->getContainer()->get('doctrine'));
|
||||
|
||||
try {
|
||||
$bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('name'));
|
||||
|
||||
$output->writeln(sprintf('Generating entities for bundle "<info>%s</info>"', $bundle->getName()));
|
||||
$metadata = $manager->getBundleMetadata($bundle);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$name = strtr($input->getArgument('name'), '/', '\\');
|
||||
|
||||
if (false !== $pos = strpos($name, ':')) {
|
||||
$name = $this->getContainer()->get('doctrine')->getEntityNamespace(substr($name, 0, $pos)).'\\'.substr($name, $pos + 1);
|
||||
}
|
||||
|
||||
if (class_exists($name)) {
|
||||
$output->writeln(sprintf('Generating entity "<info>%s</info>"', $name));
|
||||
$metadata = $manager->getClassMetadata($name, $input->getOption('path'));
|
||||
} else {
|
||||
$output->writeln(sprintf('Generating entities for namespace "<info>%s</info>"', $name));
|
||||
$metadata = $manager->getNamespaceMetadata($name, $input->getOption('path'));
|
||||
}
|
||||
}
|
||||
|
||||
$generator = $this->getEntityGenerator();
|
||||
|
||||
$backupExisting = !$input->getOption('no-backup');
|
||||
$generator->setBackupExisting($backupExisting);
|
||||
|
||||
$repoGenerator = new EntityRepositoryGenerator();
|
||||
foreach ($metadata->getMetadata() as $m) {
|
||||
if ($backupExisting) {
|
||||
$basename = substr($m->name, strrpos($m->name, '\\') + 1);
|
||||
$output->writeln(sprintf(' > backing up <comment>%s.php</comment> to <comment>%s.php~</comment>', $basename, $basename));
|
||||
}
|
||||
// Getting the metadata for the entity class once more to get the correct path if the namespace has multiple occurrences
|
||||
try {
|
||||
$entityMetadata = $manager->getClassMetadata($m->getName(), $input->getOption('path'));
|
||||
} catch (\RuntimeException $e) {
|
||||
// fall back to the bundle metadata when no entity class could be found
|
||||
$entityMetadata = $metadata;
|
||||
}
|
||||
|
||||
$output->writeln(sprintf(' > generating <comment>%s</comment>', $m->name));
|
||||
$generator->generate(array($m), $entityMetadata->getPath());
|
||||
|
||||
if ($m->customRepositoryClassName && false !== strpos($m->customRepositoryClassName, $metadata->getNamespace())) {
|
||||
$repoGenerator->writeEntityRepositoryClass($m->customRepositoryClassName, $metadata->getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\ORM\Mapping\Driver\DatabaseDriver;
|
||||
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
|
||||
use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
|
||||
use Doctrine\ORM\Tools\Console\MetadataFilter;
|
||||
|
||||
/**
|
||||
* Import Doctrine ORM metadata mapping information from an existing database.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class ImportMappingDoctrineCommand extends DoctrineCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('doctrine:mapping:import')
|
||||
->addArgument('bundle', InputArgument::REQUIRED, 'The bundle to import the mapping information to')
|
||||
->addArgument('mapping-type', InputArgument::OPTIONAL, 'The mapping type to export the imported mapping information to')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be mapped.')
|
||||
->addOption('force', null, InputOption::VALUE_NONE, 'Force to overwrite existing mapping files.')
|
||||
->setDescription('Imports mapping information from an existing database')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:mapping:import</info> command imports mapping information
|
||||
from an existing database:
|
||||
|
||||
<info>php app/console doctrine:mapping:import "MyCustomBundle" xml</info>
|
||||
|
||||
You can also optionally specify which entity manager to import from with the
|
||||
<info>--em</info> option:
|
||||
|
||||
<info>php app/console doctrine:mapping:import "MyCustomBundle" xml --em=default</info>
|
||||
|
||||
If you don't want to map every entity that can be found in the database, use the
|
||||
<info>--filter</info> option. It will try to match the targeted mapped entity with the
|
||||
provided pattern string.
|
||||
|
||||
<info>php app/console doctrine:mapping:import "MyCustomBundle" xml --filter=MyMatchedEntity</info>
|
||||
|
||||
Use the <info>--force</info> option, if you want to override existing mapping files:
|
||||
|
||||
<info>php app/console doctrine:mapping:import "MyCustomBundle" xml --force</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('bundle'));
|
||||
|
||||
$destPath = $bundle->getPath();
|
||||
$type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
|
||||
if ('annotation' === $type) {
|
||||
$destPath .= '/Entity';
|
||||
} else {
|
||||
$destPath .= '/Resources/config/doctrine';
|
||||
}
|
||||
if ('yaml' === $type) {
|
||||
$type = 'yml';
|
||||
}
|
||||
|
||||
$cme = new ClassMetadataExporter();
|
||||
$exporter = $cme->getExporter($type);
|
||||
$exporter->setOverwriteExistingFiles($input->getOption('force'));
|
||||
|
||||
if ('annotation' === $type) {
|
||||
$entityGenerator = $this->getEntityGenerator();
|
||||
$exporter->setEntityGenerator($entityGenerator);
|
||||
}
|
||||
|
||||
$em = $this->getEntityManager($input->getOption('em'));
|
||||
|
||||
$databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());
|
||||
$em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
|
||||
|
||||
$emName = $input->getOption('em');
|
||||
$emName = $emName ? $emName : 'default';
|
||||
|
||||
$cmf = new DisconnectedClassMetadataFactory();
|
||||
$cmf->setEntityManager($em);
|
||||
$metadata = $cmf->getAllMetadata();
|
||||
$metadata = MetadataFilter::filter($metadata, $input->getOption('filter'));
|
||||
if ($metadata) {
|
||||
$output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
|
||||
foreach ($metadata as $class) {
|
||||
$className = $class->name;
|
||||
$class->name = $bundle->getNamespace().'\\Entity\\'.$className;
|
||||
if ('annotation' === $type) {
|
||||
$path = $destPath.'/'.$className.'.php';
|
||||
} else {
|
||||
$path = $destPath.'/'.$className.'.orm.'.$type;
|
||||
}
|
||||
$output->writeln(sprintf(' > writing <comment>%s</comment>', $path));
|
||||
$code = $exporter->exportClassMetadata($class);
|
||||
if (!is_dir($dir = dirname($path))) {
|
||||
mkdir($dir, 0777, true);
|
||||
}
|
||||
file_put_contents($path, $code);
|
||||
}
|
||||
} else {
|
||||
$output->writeln('Database does not have any mapping information.', 'ERROR');
|
||||
$output->writeln('', 'ERROR');
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand;
|
||||
|
||||
/**
|
||||
* Command to clear the metadata cache of the various cache drivers.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class ClearMetadataCacheDoctrineCommand extends MetadataCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:cache:clear-metadata')
|
||||
->setDescription('Clears all metadata cache for a entity manager')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:cache:clear-metadata</info> command clears all metadata
|
||||
cache for the default entity manager:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-metadata</info>
|
||||
|
||||
You can also optionally specify the <comment>--em</comment> option to specify
|
||||
which entity manager to clear the cache for:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-metadata --em=default</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand;
|
||||
|
||||
/**
|
||||
* Command to clear the query cache of the various cache drivers.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class ClearQueryCacheDoctrineCommand extends QueryCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:cache:clear-query')
|
||||
->setDescription('Clears all query cache for a entity manager')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:cache:clear-query</info> command clears all query cache for
|
||||
the default entity manager:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-query</info>
|
||||
|
||||
You can also optionally specify the <comment>--em</comment> option to specify
|
||||
which entity manager to clear the cache for:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-query --em=default</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand;
|
||||
|
||||
/**
|
||||
* Command to clear the result cache of the various cache drivers.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class ClearResultCacheDoctrineCommand extends ResultCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:cache:clear-result')
|
||||
->setDescription('Clears result cache for a entity manager')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:cache:clear-result</info> command clears all result cache
|
||||
for the default entity manager:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result</info>
|
||||
|
||||
You can also optionally specify the <comment>--em</comment> option to specify
|
||||
which entity manager to clear the cache for:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result --em=default</info>
|
||||
|
||||
If you don't want to clear all result cache you can specify some additional
|
||||
options to control what cache is deleted:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result --id=cache_key</info>
|
||||
|
||||
Or you can specify a <comment>--regex</comment> to delete cache entries that
|
||||
match it:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result --regex="user_(.*)"</info>
|
||||
|
||||
You can also specify a <comment>--prefix</comment> or
|
||||
<comment>--suffix</comment> to delete cache entries for:
|
||||
|
||||
<info>php app/console doctrine:cache:clear-result --prefix="user_" --suffix="_frontend"</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
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\ConvertMappingCommand;
|
||||
use Doctrine\ORM\Tools\Export\Driver\XmlExporter;
|
||||
use Doctrine\ORM\Tools\Export\Driver\YamlExporter;
|
||||
|
||||
/**
|
||||
* Convert Doctrine ORM metadata mapping information between the various supported
|
||||
* formats.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class ConvertMappingDoctrineCommand extends ConvertMappingCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this
|
||||
->setName('doctrine:mapping:convert')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:mapping:convert</info> command converts mapping information
|
||||
between supported formats:
|
||||
|
||||
<info>php app/console doctrine:mapping:convert xml /path/to/output</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
|
||||
|
||||
protected function getExporter($toType, $destPath)
|
||||
{
|
||||
$exporter = parent::getExporter($toType, $destPath);
|
||||
if ($exporter instanceof XmlExporter) {
|
||||
$exporter->setExtension('.orm.xml');
|
||||
} elseif ($exporter instanceof YamlExporter) {
|
||||
$exporter->setExtension('.orm.yml');
|
||||
}
|
||||
|
||||
return $exporter;
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
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\SchemaTool\CreateCommand;
|
||||
|
||||
/**
|
||||
* Command to execute the SQL needed to generate the database schema for
|
||||
* a given entity manager.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class CreateSchemaDoctrineCommand extends CreateCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:schema:create')
|
||||
->setDescription('Executes (or dumps) the SQL needed to generate the database schema')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:schema:create</info> command executes the SQL needed to
|
||||
generate the database schema for the default entity manager:
|
||||
|
||||
<info>php app/console doctrine:schema:create</info>
|
||||
|
||||
You can also generate the database schema for a specific entity manager:
|
||||
|
||||
<info>php app/console doctrine:schema:create --em=default</info>
|
||||
|
||||
Finally, instead of executing the SQL, you can output the SQL:
|
||||
|
||||
<info>php app/console doctrine:schema:create --dump-sql</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
|
||||
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
|
||||
|
||||
/**
|
||||
* Provides some helper and convenience methods to configure doctrine commands in the context of bundles
|
||||
* and multiple connections/entity managers.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class DoctrineCommandHelper
|
||||
{
|
||||
/**
|
||||
* Convenience method to push the helper sets of a given entity manager into the application.
|
||||
*
|
||||
* @param Application $application
|
||||
* @param string $emName
|
||||
*/
|
||||
static public function setApplicationEntityManager(Application $application, $emName)
|
||||
{
|
||||
$em = $application->getKernel()->getContainer()->get('doctrine')->getManager($emName);
|
||||
$helperSet = $application->getHelperSet();
|
||||
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
|
||||
$helperSet->set(new EntityManagerHelper($em), 'em');
|
||||
}
|
||||
|
||||
static public function setApplicationConnection(Application $application, $connName)
|
||||
{
|
||||
$connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection($connName);
|
||||
$helperSet = $application->getHelperSet();
|
||||
$helperSet->set(new ConnectionHelper($connection), 'db');
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
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\SchemaTool\DropCommand;
|
||||
|
||||
/**
|
||||
* Command to drop the database schema for a set of classes based on their mappings.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class DropSchemaDoctrineCommand extends DropCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:schema:drop')
|
||||
->setDescription('Executes (or dumps) the SQL needed to drop the current database schema')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:schema:drop</info> command generates the SQL needed to
|
||||
drop the database schema of the default entity manager:
|
||||
|
||||
<info>php app/console doctrine:schema:drop --dump-sql</info>
|
||||
|
||||
Alternatively, you can execute the generated queries:
|
||||
|
||||
<info>php app/console doctrine:schema:drop --force</info>
|
||||
|
||||
You can also optionally specify the name of a entity manager to drop the
|
||||
schema for:
|
||||
|
||||
<info>php app/console doctrine:schema:drop --em=default</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
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\EnsureProductionSettingsCommand;
|
||||
|
||||
/**
|
||||
* Ensure the Doctrine ORM is configured properly for a production environment.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class EnsureProductionSettingsDoctrineCommand extends EnsureProductionSettingsCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:ensure-production-settings')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:ensure-production-settings</info> command ensures that
|
||||
Doctrine is properly configured for a production environment.:
|
||||
|
||||
<info>php app/console doctrine:ensure-production-settings</info>
|
||||
|
||||
You can also optionally specify the <comment>--em</comment> option to specify
|
||||
which entity manager to use:
|
||||
|
||||
<info>php app/console doctrine:ensure-production-settings --em=default</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
use Doctrine\ORM\Mapping\MappingException;
|
||||
use Doctrine\ORM\Tools\Console\Command\InfoCommand;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Show information about mapped entities
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class InfoDoctrineCommand extends InfoCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('doctrine:mapping:info')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setDescription('Shows basic information about all mapped entities')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:mapping:info</info> shows basic information about which
|
||||
entities exist and possibly if their mapping information contains errors or
|
||||
not.
|
||||
|
||||
<info>php app/console doctrine:mapping:info</info>
|
||||
|
||||
If you are using multiple entity managers you can pick your choice with the
|
||||
<info>--em</info> option:
|
||||
|
||||
<info>php app/console doctrine:mapping:info --em=default</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
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\RunDqlCommand;
|
||||
|
||||
/**
|
||||
* Execute a Doctrine DQL query and output the results.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class RunDqlDoctrineCommand extends RunDqlCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:query:dql')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:query:dql</info> command executes the given DQL query and
|
||||
outputs the results:
|
||||
|
||||
<info>php app/console doctrine:query:dql "SELECT u FROM UserBundle:User u"</info>
|
||||
|
||||
You can also optional specify some additional options like what type of
|
||||
hydration to use when executing the query:
|
||||
|
||||
<info>php app/console doctrine:query:dql "SELECT u FROM UserBundle:User u" --hydrate=array</info>
|
||||
|
||||
Additionally you can specify the first result and maximum amount of results to
|
||||
show:
|
||||
|
||||
<info>php app/console doctrine:query:dql "SELECT u FROM UserBundle:User u" --first-result=0 --max-result=30</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
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\DBAL\Tools\Console\Command\RunSqlCommand;
|
||||
|
||||
/**
|
||||
* Execute a SQL query and output the results.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class RunSqlDoctrineCommand extends RunSqlCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:query:sql')
|
||||
->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:query:sql</info> command executes the given DQL query and
|
||||
outputs the results:
|
||||
|
||||
<info>php app/console doctrine:query:sql "SELECT * from user"</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
|
||||
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
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\SchemaTool\UpdateCommand;
|
||||
|
||||
/**
|
||||
* Command to generate the SQL needed to update the database schema to match
|
||||
* the current mapping information.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
class UpdateSchemaDoctrineCommand extends UpdateCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:schema:update')
|
||||
->setDescription('Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:schema:update</info> command generates the SQL needed to
|
||||
synchronize the database schema with the current mapping metadata of the
|
||||
default entity manager.
|
||||
|
||||
For example, if you add metadata for a new column to an entity, this command
|
||||
would generate and output the SQL needed to add the new column to the database:
|
||||
|
||||
<info>php app/console doctrine:schema:update --dump-sql</info>
|
||||
|
||||
Alternatively, you can execute the generated queries:
|
||||
|
||||
<info>php app/console doctrine:schema:update --force</info>
|
||||
|
||||
You can also update the database schema for a specific entity manager:
|
||||
|
||||
<info>php app/console doctrine:schema:update --em=default</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
parent::execute($input, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Doctrine Bundle
|
||||
*
|
||||
* The code was originally distributed inside the Symfony framework.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
* (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
|
||||
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand as DoctrineValidateSchemaCommand;
|
||||
|
||||
/**
|
||||
* Command to run Doctrine ValidateSchema() on the current mappings.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Neil Katin <symfony@askneil.com>
|
||||
*/
|
||||
class ValidateSchemaCommand extends DoctrineValidateSchemaCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->setName('doctrine:schema:validate')
|
||||
->setDescription('Validates the doctrine mapping files')
|
||||
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:schema:validate</info> checks the current mappings
|
||||
for valid forward and reverse mappings.
|
||||
|
||||
<info>php app/console doctrine:schema:validate</info>
|
||||
|
||||
You can also optionally specify the <comment>--em</comment> option to specify
|
||||
which entity manager use for the validation.
|
||||
|
||||
<info>php app/console doctrine:schema:validate --em=default</info>
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
|
||||
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user