Subida del módulo y tema de PrestaShop

This commit is contained in:
Kaloyan
2026-04-09 18:31:51 +02:00
parent 12c253296f
commit 16b3ff9424
39262 changed files with 7418797 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Sharding\PoolingShardConnection;
use InvalidArgumentException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
use function array_merge;
use function in_array;
use function sprintf;
/**
* Database tool allows you to easily create your configured databases.
*
* @final
*/
class CreateDatabaseDoctrineCommand extends DoctrineCommand
{
protected function configure(): void
{
$this
->setName('doctrine:database:create')
->setDescription('Creates the configured database')
->addOption('shard', 's', InputOption::VALUE_REQUIRED, 'The shard connection to use for this command')
->addOption('connection', 'c', InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
->addOption('if-not-exists', null, InputOption::VALUE_NONE, 'Don\'t trigger an error, when the database already exists')
->setHelp(<<<EOT
The <info>%command.name%</info> command creates the default connections database:
<info>php %command.full_name%</info>
You can also optionally specify the name of a connection to create the database for:
<info>php %command.full_name% --connection=default</info>
EOT
);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$connectionName = $input->getOption('connection');
if (empty($connectionName)) {
$connectionName = $this->getDoctrine()->getDefaultConnectionName();
}
$connection = $this->getDoctrineConnection($connectionName);
$ifNotExists = $input->getOption('if-not-exists');
$params = $connection->getParams();
if (isset($params['primary'])) {
$params = $params['primary'];
}
// Cannot inject `shard` option in parent::getDoctrineConnection
// cause it will try to connect to a non-existing database
if (isset($params['shards'])) {
$shards = $params['shards'];
// Default select global
$params = array_merge($params, $params['global'] ?? []);
unset($params['global']['dbname'], $params['global']['path'], $params['global']['url']);
if ($input->getOption('shard')) {
foreach ($shards as $i => $shard) {
if ($shard['id'] === (int) $input->getOption('shard')) {
// Select sharded database
$params = array_merge($params, $shard);
unset($params['shards'][$i]['dbname'], $params['shards'][$i]['path'], $params['shards'][$i]['url'], $params['id']);
break;
}
}
}
}
$hasPath = isset($params['path']);
$name = $hasPath ? $params['path'] : ($params['dbname'] ?? false);
if (! $name) {
throw new InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be created.");
}
// Need to get rid of _every_ occurrence of dbname from connection configuration and we have already extracted all relevant info from url
unset($params['dbname'], $params['path'], $params['url']);
$tmpConnection = DriverManager::getConnection($params);
if ($tmpConnection instanceof PoolingShardConnection) {
$tmpConnection->connect($input->getOption('shard'));
} else {
$tmpConnection->connect();
}
$shouldNotCreateDatabase = $ifNotExists && in_array($name, $tmpConnection->getSchemaManager()->listDatabases());
// Only quote if we don't have a path
if (! $hasPath) {
$name = $tmpConnection->getDatabasePlatform()->quoteSingleIdentifier($name);
}
$error = false;
try {
if ($shouldNotCreateDatabase) {
$output->writeln(sprintf('<info>Database <comment>%s</comment> for connection named <comment>%s</comment> already exists. Skipped.</info>', $name, $connectionName));
} else {
$tmpConnection->getSchemaManager()->createDatabase($name);
$output->writeln(sprintf('<info>Created database <comment>%s</comment> for connection named <comment>%s</comment></info>', $name, $connectionName));
}
} catch (Throwable $e) {
$output->writeln(sprintf('<error>Could not create database <comment>%s</comment> for connection named <comment>%s</comment></error>', $name, $connectionName));
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
$error = true;
}
$tmpConnection->close();
return $error ? 1 : 0;
}
}

View File

@@ -0,0 +1,96 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Sharding\PoolingShardConnection;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\EntityGenerator;
use Doctrine\Persistence\ManagerRegistry;
use LogicException;
use Symfony\Component\Console\Command\Command;
use function sprintf;
/**
* Base class for Doctrine console commands to extend from.
*
* @internal
*/
abstract class DoctrineCommand extends Command
{
/** @var ManagerRegistry */
private $doctrine;
public function __construct(ManagerRegistry $doctrine)
{
parent::__construct();
$this->doctrine = $doctrine;
}
/**
* get a doctrine entity generator
*
* @return EntityGenerator
*/
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;
}
/**
* Get a doctrine entity manager by symfony name.
*
* @param string $name
* @param int|null $shardId
*
* @return EntityManager
*/
protected function getEntityManager($name, $shardId = null)
{
$manager = $this->getDoctrine()->getManager($name);
if ($shardId) {
if (! $manager instanceof EntityManagerInterface) {
throw new LogicException(sprintf('Sharding is supported only in EntityManager of instance "%s".', EntityManagerInterface::class));
}
$connection = $manager->getConnection();
if (! $connection instanceof PoolingShardConnection) {
throw new LogicException(sprintf("Connection of EntityManager '%s' must implement shards configuration.", $name));
}
$connection->connect($shardId);
}
return $manager;
}
/**
* Get a doctrine dbal connection by symfony name.
*
* @param string $name
*
* @return Connection
*/
protected function getDoctrineConnection($name)
{
return $this->getDoctrine()->getConnection($name);
}
/** @return ManagerRegistry */
protected function getDoctrine()
{
return $this->doctrine;
}
}

View File

@@ -0,0 +1,132 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command;
use Doctrine\DBAL\DriverManager;
use InvalidArgumentException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
use function array_merge;
use function in_array;
use function sprintf;
/**
* Database tool allows you to easily drop your configured databases.
*
* @final
*/
class DropDatabaseDoctrineCommand extends DoctrineCommand
{
public const RETURN_CODE_NOT_DROP = 1;
public const RETURN_CODE_NO_FORCE = 2;
/**
* {@inheritDoc}
*/
protected function configure()
{
$this
->setName('doctrine:database:drop')
->setDescription('Drops the configured database')
->addOption('shard', 's', InputOption::VALUE_REQUIRED, 'The shard connection to use for this command')
->addOption('connection', 'c', InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
->addOption('if-exists', null, InputOption::VALUE_NONE, 'Don\'t trigger an error, when the database doesn\'t exist')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Set this parameter to execute this action')
->setHelp(<<<EOT
The <info>%command.name%</info> command drops the default connections database:
<info>php %command.full_name%</info>
The <info>--force</info> 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 %command.full_name% --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): int
{
$connectionName = $input->getOption('connection');
if (empty($connectionName)) {
$connectionName = $this->getDoctrine()->getDefaultConnectionName();
}
$connection = $this->getDoctrineConnection($connectionName);
$ifExists = $input->getOption('if-exists');
$params = $connection->getParams();
if (isset($params['primary'])) {
$params = $params['primary'];
}
if (isset($params['shards'])) {
$shards = $params['shards'];
// Default select global
$params = array_merge($params, $params['global'] ?? []);
if ($input->getOption('shard')) {
foreach ($shards as $shard) {
if ($shard['id'] === (int) $input->getOption('shard')) {
// Select sharded database
$params = array_merge($params, $shard);
unset($params['id']);
break;
}
}
}
}
$name = $params['path'] ?? ($params['dbname'] ?? false);
if (! $name) {
throw new InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.");
}
unset($params['dbname'], $params['url']);
if (! $input->getOption('force')) {
$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 <comment>%s</comment> for connection named <comment>%s</comment>.</info>', $name, $connectionName));
$output->writeln('Please run the operation with --force to execute');
$output->writeln('<error>All data will be lost!</error>');
return self::RETURN_CODE_NO_FORCE;
}
// Reopen connection without database name set
// as some vendors do not allow dropping the database connected to.
$connection->close();
$connection = DriverManager::getConnection($params);
$shouldDropDatabase = ! $ifExists || in_array($name, $connection->getSchemaManager()->listDatabases());
// Only quote if we don't have a path
if (! isset($params['path'])) {
$name = $connection->getDatabasePlatform()->quoteSingleIdentifier($name);
}
try {
if ($shouldDropDatabase) {
$connection->getSchemaManager()->dropDatabase($name);
$output->writeln(sprintf('<info>Dropped database <comment>%s</comment> for connection named <comment>%s</comment></info>', $name, $connectionName));
} else {
$output->writeln(sprintf('<info>Database <comment>%s</comment> for connection named <comment>%s</comment> doesn\'t exist. Skipped.</info>', $name, $connectionName));
}
return 0;
} catch (Throwable $e) {
$output->writeln(sprintf('<error>Could not drop database <comment>%s</comment> for connection named <comment>%s</comment></error>', $name, $connectionName));
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
return self::RETURN_CODE_NOT_DROP;
}
}
}

View File

@@ -0,0 +1,165 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command;
use Doctrine\ORM\Mapping\Driver\DatabaseDriver;
use Doctrine\ORM\Tools\Console\MetadataFilter;
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
use Doctrine\Persistence\ManagerRegistry;
use InvalidArgumentException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use function chmod;
use function dirname;
use function file_put_contents;
use function is_dir;
use function mkdir;
use function sprintf;
use function str_replace;
/**
* Import Doctrine ORM metadata mapping information from an existing database.
*
* @deprecated
*
* @final
*/
class ImportMappingDoctrineCommand extends DoctrineCommand
{
/** @var string[] */
private $bundles;
/** @param string[] $bundles */
public function __construct(ManagerRegistry $doctrine, array $bundles)
{
parent::__construct($doctrine);
$this->bundles = $bundles;
}
protected function configure(): void
{
$this
->setName('doctrine:mapping:import')
->addArgument('name', InputArgument::REQUIRED, 'The bundle or namespace 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('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection 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.')
->addOption('path', null, InputOption::VALUE_REQUIRED, 'The path where the files would be generated (not used when a bundle is passed).')
->setDescription('Imports mapping information from an existing database')
->setHelp(<<<EOT
The <info>%command.name%</info> command imports mapping information
from an existing database:
Generate annotation mappings into the src/ directory using App as the namespace:
<info>php %command.full_name% App\\\Entity annotation --path=src/Entity</info>
Generate xml mappings into the config/doctrine/ directory using App as the namespace:
<info>php %command.full_name% App\\\Entity xml --path=config/doctrine</info>
Generate XML mappings into a bundle:
<info>php %command.full_name% "MyCustomBundle" xml</info>
You can also optionally specify which entity manager to import from with the
<info>--em</info> option:
<info>php %command.full_name% "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 %command.full_name% "MyCustomBundle" xml --filter=MyMatchedEntity</info>
Use the <info>--force</info> option, if you want to override existing mapping files:
<info>php %command.full_name% "MyCustomBundle" xml --force</info>
EOT
);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$type = $input->getArgument('mapping-type') ?: 'xml';
if ($type === 'yaml') {
$type = 'yml';
}
$namespaceOrBundle = $input->getArgument('name');
if (isset($this->bundles[$namespaceOrBundle])) {
$bundle = $this->getApplication()->getKernel()->getBundle($namespaceOrBundle);
$namespace = $bundle->getNamespace() . '\Entity';
$destPath = $bundle->getPath();
if ($type === 'annotation') {
$destPath .= '/Entity';
} else {
$destPath .= '/Resources/config/doctrine';
}
} else {
// assume a namespace has been passed
$namespace = $namespaceOrBundle;
$destPath = $input->getOption('path');
if ($destPath === null) {
throw new InvalidArgumentException('The --path option is required when passing a namespace (e.g. --path=src). If you intended to pass a bundle name, check your spelling.');
}
}
$cme = new ClassMetadataExporter();
$exporter = $cme->getExporter($type);
$exporter->setOverwriteExistingFiles($input->getOption('force'));
if ($type === 'annotation') {
$entityGenerator = $this->getEntityGenerator();
$exporter->setEntityGenerator($entityGenerator);
}
$em = $this->getEntityManager($input->getOption('em'), $input->getOption('shard'));
$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 = $namespace . '\\' . $className;
if ($type === 'annotation') {
$path = $destPath . '/' . str_replace('\\', '.', $className) . '.php';
} else {
$path = $destPath . '/' . str_replace('\\', '.', $className) . '.orm.' . $type;
}
$output->writeln(sprintf(' > writing <comment>%s</comment>', $path));
$code = $exporter->exportClassMetadata($class);
$dir = dirname($path);
if (! is_dir($dir)) {
mkdir($dir, 0775, true);
}
file_put_contents($path, $code);
chmod($path, 0664);
}
return 0;
}
$output->writeln('Database does not have any mapping information.');
$output->writeln('');
return 1;
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to clear the metadata cache of the various cache drivers.
*/
class ClearMetadataCacheDoctrineCommand extends MetadataCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:cache:clear-metadata')
->setDescription('Clears all metadata cache for an entity manager');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to clear the query cache of the various cache drivers.
*/
class ClearQueryCacheDoctrineCommand extends QueryCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:cache:clear-query')
->setDescription('Clears all query cache for an entity manager');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to clear the result cache of the various cache drivers.
*/
class ClearResultCacheDoctrineCommand extends ResultCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:cache:clear-result')
->setDescription('Clears result cache for an entity manager');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\ClearCache\CollectionRegionCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to clear a collection cache region.
*/
class CollectionRegionDoctrineCommand extends CollectionRegionCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:cache:clear-collection-region');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
use Doctrine\ORM\Tools\Export\Driver\AbstractExporter;
use Doctrine\ORM\Tools\Export\Driver\XmlExporter;
use Doctrine\ORM\Tools\Export\Driver\YamlExporter;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use function assert;
/**
* Convert Doctrine ORM metadata mapping information between the various supported
* formats.
*/
class ConvertMappingDoctrineCommand extends ConvertMappingCommand
{
/**
* {@inheritDoc}
*/
protected function configure()
{
parent::configure();
$this
->setName('doctrine:mapping:convert');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
/**
* @param string $toType
* @param string $destPath
*
* @return AbstractExporter
*/
protected function getExporter($toType, $destPath)
{
$exporter = parent::getExporter($toType, $destPath);
assert($exporter instanceof AbstractExporter);
if ($exporter instanceof XmlExporter) {
$exporter->setExtension('.orm.xml');
} elseif ($exporter instanceof YamlExporter) {
$exporter->setExtension('.orm.yml');
}
return $exporter;
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to execute the SQL needed to generate the database schema for
* a given entity manager.
*/
class CreateSchemaDoctrineCommand extends CreateCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:schema:create')
->setDescription('Executes (or dumps) the SQL needed to generate the database schema');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use function assert;
use function class_exists;
/**
* Provides some helper and convenience methods to configure doctrine commands in the context of bundles
* and multiple connections/entity managers.
*/
abstract class DoctrineCommandHelper
{
/**
* Convenience method to push the helper sets of a given entity manager into the application.
*
* @param string $emName
*/
public static function setApplicationEntityManager(Application $application, $emName)
{
$em = $application->getKernel()->getContainer()->get('doctrine')->getManager($emName);
assert($em instanceof EntityManagerInterface);
$helperSet = $application->getHelperSet();
if (class_exists(ConnectionHelper::class)) {
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
}
$helperSet->set(new EntityManagerHelper($em), 'em');
}
/**
* Convenience method to push the helper sets of a given connection into the application.
*
* @param string $connName
*/
public static function setApplicationConnection(Application $application, $connName)
{
$connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection($connName);
$helperSet = $application->getHelperSet();
$helperSet->set(new ConnectionHelper($connection), 'db');
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to drop the database schema for a set of classes based on their mappings.
*/
class DropSchemaDoctrineCommand extends DropCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:schema:drop')
->setDescription('Executes (or dumps) the SQL needed to drop the current database schema');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Ensure the Doctrine ORM is configured properly for a production environment.
*/
class EnsureProductionSettingsDoctrineCommand extends EnsureProductionSettingsCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:ensure-production-settings');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\ClearCache\EntityRegionCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to clear a entity cache region.
*/
class EntityRegionCacheDoctrineCommand extends EntityRegionCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:cache:clear-entity-region');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\DBAL\Tools\Console\Command\ImportCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use function trigger_deprecation;
/**
* Loads an SQL file and executes it.
*
* @deprecated Use a database client application instead.
*/
class ImportDoctrineCommand extends ImportCommand
{
/**
* {@inheritDoc}
*/
protected function configure()
{
parent::configure();
$this
->setName('doctrine:database:import')
->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
trigger_deprecation(
'doctrine/doctrine-bundle',
'2.2',
'The "%s" (doctrine:database:import) is deprecated, use a database client instead.',
self::class
);
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\InfoCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Show information about mapped entities
*/
class InfoDoctrineCommand extends InfoCommand
{
protected function configure(): void
{
$this
->setName('doctrine:mapping:info');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to clear a query cache region.
*/
class QueryRegionCacheDoctrineCommand extends QueryRegionCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:cache:clear-query-region');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\RunDqlCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Execute a Doctrine DQL query and output the results.
*/
class RunDqlDoctrineCommand extends RunDqlCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:query:dql')
->setHelp(<<<EOT
The <info>%command.name%</info> command executes the given DQL query and
outputs the results:
<info>php %command.full_name% "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 %command.full_name% "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 %command.full_name% "SELECT u FROM UserBundle:User u" --first-result=0 --max-result=30</info>
EOT
);
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\DBAL\Tools\Console\ConnectionProvider;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use function trigger_deprecation;
/**
* Execute a SQL query and output the results.
*
* @deprecated use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand instead
*/
class RunSqlDoctrineCommand extends RunSqlCommand
{
/** @var ConnectionProvider|null */
private $connectionProvider;
public function __construct(?ConnectionProvider $connectionProvider = null)
{
parent::__construct($connectionProvider);
$this->connectionProvider = $connectionProvider;
}
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:query:sql')
->setHelp(<<<EOT
The <info>%command.name%</info> command executes the given SQL query and
outputs the results:
<info>php %command.full_name% "SELECT * FROM users"</info>
EOT
);
if ($this->getDefinition()->hasOption('connection')) {
return;
}
$this->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
trigger_deprecation(
'doctrine/doctrine-bundle',
'2.2',
'The "%s" (doctrine:query:sql) is deprecated, use dbal:run-sql command instead.',
self::class
);
if (! $this->connectionProvider) {
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
// compatibility with doctrine/dbal 2.11+
// where this option is also present and unsupported before we are not switching to use a ConnectionProvider
$input->setOption('connection', null);
}
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to generate the SQL needed to update the database schema to match
* the current mapping information.
*/
class UpdateSchemaDoctrineCommand extends UpdateCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:schema:update');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand as DoctrineValidateSchemaCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Command to run Doctrine ValidateSchema() on the current mappings.
*/
class ValidateSchemaCommand extends DoctrineValidateSchemaCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('doctrine:schema:validate');
if ($this->getDefinition()->hasOption('em')) {
return;
}
$this->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
return parent::execute($input, $output);
}
}