Make explicit the design decisions of ConsoleRunner
This commit is contained in:
parent
d4b94e097a
commit
5109322f7d
@ -1,5 +1,9 @@
|
|||||||
# Upgrade to 2.6
|
# Upgrade to 2.6
|
||||||
|
|
||||||
|
## Minor BC BREAK: `Doctrine\ORM\Tools\Console\ConsoleRunner` is now final
|
||||||
|
|
||||||
|
Since it's just an utilitarian class and should not be inherited.
|
||||||
|
|
||||||
## Minor BC BREAK: removed `Doctrine\ORM\Query\Parser#isInternalFunction`
|
## Minor BC BREAK: removed `Doctrine\ORM\Query\Parser#isInternalFunction`
|
||||||
|
|
||||||
Method `Doctrine\ORM\Query\QueryException::associationPathInverseSideNotSupported`
|
Method `Doctrine\ORM\Query\QueryException::associationPathInverseSideNotSupported`
|
||||||
|
@ -19,44 +19,44 @@
|
|||||||
|
|
||||||
namespace Doctrine\ORM\Tools\Console;
|
namespace Doctrine\ORM\Tools\Console;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Tools\Console as DBALConsole;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
|
||||||
|
use Doctrine\ORM\Version;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\Helper\HelperSet;
|
use Symfony\Component\Console\Helper\HelperSet;
|
||||||
use Doctrine\ORM\Version;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
|
|
||||||
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles running the Console Tools inside Symfony Console context.
|
* Handles running the Console Tools inside Symfony Console context.
|
||||||
*/
|
*/
|
||||||
class ConsoleRunner
|
final class ConsoleRunner
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a Symfony Console HelperSet
|
* Create a Symfony Console HelperSet
|
||||||
*
|
*
|
||||||
* @param EntityManagerInterface $entityManager
|
* @param EntityManagerInterface $entityManager
|
||||||
|
*
|
||||||
* @return HelperSet
|
* @return HelperSet
|
||||||
*/
|
*/
|
||||||
public static function createHelperSet(EntityManagerInterface $entityManager)
|
public static function createHelperSet(EntityManagerInterface $entityManager) : HelperSet
|
||||||
{
|
{
|
||||||
return new HelperSet(
|
return new HelperSet(
|
||||||
[
|
[
|
||||||
'db' => new ConnectionHelper($entityManager->getConnection()),
|
'db' => new DBALConsole\Helper\ConnectionHelper($entityManager->getConnection()),
|
||||||
'em' => new EntityManagerHelper($entityManager)
|
'em' => new EntityManagerHelper($entityManager),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs console with the given helperset.
|
* Runs console with the given helper set.
|
||||||
*
|
*
|
||||||
* @param \Symfony\Component\Console\Helper\HelperSet $helperSet
|
* @param \Symfony\Component\Console\Helper\HelperSet $helperSet
|
||||||
* @param \Symfony\Component\Console\Command\Command[] $commands
|
* @param \Symfony\Component\Console\Command\Command[] $commands
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function run(HelperSet $helperSet, $commands = [])
|
public static function run(HelperSet $helperSet, array $commands = []) : void
|
||||||
{
|
{
|
||||||
$cli = self::createApplication($helperSet, $commands);
|
$cli = self::createApplication($helperSet, $commands);
|
||||||
$cli->run();
|
$cli->run();
|
||||||
@ -71,7 +71,7 @@ class ConsoleRunner
|
|||||||
*
|
*
|
||||||
* @return \Symfony\Component\Console\Application
|
* @return \Symfony\Component\Console\Application
|
||||||
*/
|
*/
|
||||||
static public function createApplication(HelperSet $helperSet, $commands = [])
|
public static function createApplication(HelperSet $helperSet, array $commands = []) : Application
|
||||||
{
|
{
|
||||||
$cli = new Application('Doctrine Command Line Interface', Version::VERSION);
|
$cli = new Application('Doctrine Command Line Interface', Version::VERSION);
|
||||||
$cli->setCatchExceptions(true);
|
$cli->setCatchExceptions(true);
|
||||||
@ -87,40 +87,40 @@ class ConsoleRunner
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function addCommands(Application $cli)
|
public static function addCommands(Application $cli) : void
|
||||||
{
|
{
|
||||||
$cli->addCommands(
|
$cli->addCommands(
|
||||||
[
|
[
|
||||||
// DBAL Commands
|
// DBAL Commands
|
||||||
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
|
new DBALConsole\Command\ImportCommand(),
|
||||||
new \Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand(),
|
new DBALConsole\Command\ReservedWordsCommand(),
|
||||||
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
|
new DBALConsole\Command\RunSqlCommand(),
|
||||||
|
|
||||||
// ORM Commands
|
// ORM Commands
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ClearCache\CollectionRegionCommand(),
|
new Command\ClearCache\CollectionRegionCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ClearCache\EntityRegionCommand(),
|
new Command\ClearCache\EntityRegionCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
|
new Command\ClearCache\MetadataCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
|
new Command\ClearCache\QueryCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand(),
|
new Command\ClearCache\QueryRegionCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
|
new Command\ClearCache\ResultCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
|
new Command\SchemaTool\CreateCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
|
new Command\SchemaTool\UpdateCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
|
new Command\SchemaTool\DropCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
|
new Command\EnsureProductionSettingsCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
|
new Command\ConvertDoctrine1SchemaCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
|
new Command\GenerateRepositoriesCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
|
new Command\GenerateEntitiesCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
|
new Command\GenerateProxiesCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
|
new Command\ConvertMappingCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
|
new Command\RunDqlCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
|
new Command\ValidateSchemaCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\InfoCommand(),
|
new Command\InfoCommand(),
|
||||||
new \Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand(),
|
new Command\MappingDescribeCommand(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function printCliConfigTemplate()
|
public static function printCliConfigTemplate() : void
|
||||||
{
|
{
|
||||||
echo <<<'HELP'
|
echo <<<'HELP'
|
||||||
You are missing a "cli-config.php" or "config/cli-config.php" file in your
|
You are missing a "cli-config.php" or "config/cli-config.php" file in your
|
||||||
@ -139,6 +139,5 @@ $entityManager = GetEntityManager();
|
|||||||
return ConsoleRunner::createHelperSet($entityManager);
|
return ConsoleRunner::createHelperSet($entityManager);
|
||||||
|
|
||||||
HELP;
|
HELP;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user