Skip to content

Commit

Permalink
deprecate all ORM proxy commands (#1581)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Nov 16, 2022
1 parent 2f094c9 commit 03ad8e6
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Command/Proxy/ClearMetadataCacheDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Command to clear the metadata cache of the various cache drivers.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand instead
*/
class ClearMetadataCacheDoctrineCommand extends MetadataCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/ClearQueryCacheDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Command to clear the query cache of the various cache drivers.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand instead
*/
class ClearQueryCacheDoctrineCommand extends QueryCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/ClearResultCacheDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Command to clear the result cache of the various cache drivers.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand instead
*/
class ClearResultCacheDoctrineCommand extends ResultCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/CollectionRegionDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Command to clear a collection cache region.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\ClearCache\CollectionRegionCommand instead
*/
class CollectionRegionDoctrineCommand extends CollectionRegionCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/ConvertMappingDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
/**
* Convert Doctrine ORM metadata mapping information between the various supported
* formats.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand instead
*/
class ConvertMappingDoctrineCommand extends ConvertMappingCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/CreateSchemaDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Command to execute the SQL needed to generate the database schema for
* a given entity manager.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand instead
*/
class CreateSchemaDoctrineCommand extends CreateCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/DropSchemaDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Command to drop the database schema for a set of classes based on their mappings.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand instead
*/
class DropSchemaDoctrineCommand extends DropCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/EnsureProductionSettingsDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Ensure the Doctrine ORM is configured properly for a production environment.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand instead
*/
class EnsureProductionSettingsDoctrineCommand extends EnsureProductionSettingsCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/EntityRegionCacheDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Command to clear a entity cache region.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\ClearCache\EntityRegionCommand instead
*/
class EntityRegionCacheDoctrineCommand extends EntityRegionCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/InfoDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Show information about mapped entities
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\InfoCommand instead
*/
class InfoDoctrineCommand extends InfoCommand
{
Expand Down
15 changes: 14 additions & 1 deletion Command/Proxy/OrmProxyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/** @internal */
use function trigger_deprecation;

/**
* @internal
* @deprecated
*/
trait OrmProxyCommand
{
private ?EntityManagerProvider $entityManagerProvider;
Expand All @@ -15,6 +20,14 @@ public function __construct(?EntityManagerProvider $entityManagerProvider = null
{
parent::__construct($entityManagerProvider);
$this->entityManagerProvider = $entityManagerProvider;

trigger_deprecation(
'doctrine/doctrine-bundle',
'2.8',
'Class "%s" is deprecated. Use "%s" instead.',
self::class,
parent::class
);
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/QueryRegionCacheDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Command to clear a query cache region.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand instead
*/
class QueryRegionCacheDoctrineCommand extends QueryRegionCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/RunDqlDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Execute a Doctrine DQL query and output the results.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\RunDqlCommand instead
*/
class RunDqlDoctrineCommand extends RunDqlCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/UpdateSchemaDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Command to generate the SQL needed to update the database schema to match
* the current mapping information.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand instead
*/
class UpdateSchemaDoctrineCommand extends UpdateCommand
{
Expand Down
2 changes: 2 additions & 0 deletions Command/Proxy/ValidateSchemaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* Command to run Doctrine ValidateSchema() on the current mappings.
*
* @deprecated use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand instead
*/
class ValidateSchemaCommand extends DoctrineValidateSchemaCommand
{
Expand Down
28 changes: 14 additions & 14 deletions Resources/config/orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,72 +181,72 @@
<service id="doctrine.orm.entity_value_resolver.expression_language" class="Symfony\Component\ExpressionLanguage\ExpressionLanguage" />

<!-- commands -->
<service id="doctrine.cache_clear_metadata_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\ClearMetadataCacheDoctrineCommand">
<service id="doctrine.cache_clear_metadata_command" class="Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:cache:clear-metadata" />
</service>

<service id="doctrine.cache_clear_query_cache_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\ClearQueryCacheDoctrineCommand">
<service id="doctrine.cache_clear_query_cache_command" class="Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:cache:clear-query" />
</service>

<service id="doctrine.cache_clear_result_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\ClearResultCacheDoctrineCommand">
<service id="doctrine.cache_clear_result_command" class="Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:cache:clear-result" />
</service>

<service id="doctrine.cache_collection_region_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\CollectionRegionDoctrineCommand">
<service id="doctrine.cache_collection_region_command" class="Doctrine\ORM\Tools\Console\Command\ClearCache\CollectionRegionCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:cache:clear-collection-region" />
</service>

<service id="doctrine.mapping_convert_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\ConvertMappingDoctrineCommand">
<service id="doctrine.mapping_convert_command" class="Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:mapping:convert" />
</service>

<service id="doctrine.schema_create_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand">
<service id="doctrine.schema_create_command" class="Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:schema:create" />
</service>

<service id="doctrine.schema_drop_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\DropSchemaDoctrineCommand">
<service id="doctrine.schema_drop_command" class="Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:schema:drop" />
</service>

<service id="doctrine.ensure_production_settings_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\EnsureProductionSettingsDoctrineCommand">
<service id="doctrine.ensure_production_settings_command" class="Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:ensure-production-settings" />
</service>

<service id="doctrine.clear_entity_region_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\EntityRegionCacheDoctrineCommand">
<service id="doctrine.clear_entity_region_command" class="Doctrine\ORM\Tools\Console\Command\ClearCache\EntityRegionCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:cache:clear-entity-region" />
</service>

<service id="doctrine.mapping_info_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\InfoDoctrineCommand">
<service id="doctrine.mapping_info_command" class="Doctrine\ORM\Tools\Console\Command\InfoCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:mapping:info" />
</service>

<service id="doctrine.clear_query_region_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\QueryRegionCacheDoctrineCommand">
<service id="doctrine.clear_query_region_command" class="Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:cache:clear-query-region" />
</service>

<service id="doctrine.query_dql_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\RunDqlDoctrineCommand">
<service id="doctrine.query_dql_command" class="Doctrine\ORM\Tools\Console\Command\RunDqlCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:query:dql" />
</service>

<service id="doctrine.schema_update_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand">
<service id="doctrine.schema_update_command" class="Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:schema:update" />
</service>

<service id="doctrine.schema_validate_command" class="Doctrine\Bundle\DoctrineBundle\Command\Proxy\ValidateSchemaCommand">
<service id="doctrine.schema_validate_command" class="Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand">
<argument type="service" id="doctrine.orm.command.entity_manager_provider" />
<tag name="console.command" command="doctrine:schema:validate" />
</service>
Expand Down
8 changes: 4 additions & 4 deletions Tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Doctrine\Bundle\DoctrineBundle\Tests;

use Doctrine\Bundle\DoctrineBundle\Command\Proxy\InfoDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Orm\ManagerRegistryAwareEntityManagerProvider;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\EventManager;
Expand All @@ -13,6 +11,8 @@
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Console\Command\InfoCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
use Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer;
Expand Down Expand Up @@ -61,8 +61,8 @@ public function testContainer(): void
$this->assertInstanceOf(ProxyCacheWarmer::class, $container->get('doctrine.orm.proxy_cache_warmer'));
$this->assertInstanceOf(ManagerRegistry::class, $container->get('doctrine'));
$this->assertInstanceOf(UniqueEntityValidator::class, $container->get('doctrine.orm.validator.unique'));
$this->assertInstanceOf(InfoDoctrineCommand::class, $container->get('doctrine.mapping_info_command'));
$this->assertInstanceOf(UpdateSchemaDoctrineCommand::class, $container->get('doctrine.schema_update_command'));
$this->assertInstanceOf(InfoCommand::class, $container->get('doctrine.mapping_info_command'));
$this->assertInstanceOf(UpdateCommand::class, $container->get('doctrine.schema_update_command'));

$this->assertSame($container->get('my.platform'), $container->get('doctrine.dbal.default_connection')->getDatabasePlatform());

Expand Down
9 changes: 5 additions & 4 deletions UPGRADE-2.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ Dependencies

Commands
--------
* Support for using Shards has been removed from `\Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand` as it's not supported using DBAL 3.
* Support for using Shards has been removed from `\Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand` as it's not supported using DBAL 3.
* Support for using Shards has been removed from `\Doctrine\Bundle\DoctrineBundle\Command\ImportMappingDoctrineCommand` as it's not supported using DBAL 3.
* The `\Doctrine\Bundle\DoctrineBundle\Command\Proxy\ImportDoctrineCommand` command has been removed as it's not supported using DBAL 3.
* Support for using Shards has been removed from `Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand` as it's not supported using DBAL 3.
* Support for using Shards has been removed from `Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand` as it's not supported using DBAL 3.
* Support for using Shards has been removed from `Doctrine\Bundle\DoctrineBundle\Command\ImportMappingDoctrineCommand` as it's not supported using DBAL 3.
* The `Doctrine\Bundle\DoctrineBundle\Command\Proxy\ImportDoctrineCommand` command has been removed as it's not supported using DBAL 3.
* All ORM proxy commands in the namespace `Doctrine\Bundle\DoctrineBundle\Command\Proxy\` have been deprecated. Use their corresponding ORM command class directly instead.

Configuration
--------
Expand Down
1 change: 1 addition & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<directory name="vendor"/>
<!-- Deprecated classes, not worth fixing -->
<file name="Command/ImportMappingDoctrineCommand.php"/>
<file name="Command/Proxy/OrmProxyCommand.php"/>
<file name="DependencyInjection/Compiler/WellKnownSchemaFilterPass.php"/>
</ignoreFiles>
<directory name="CacheWarmer"/>
Expand Down

0 comments on commit 03ad8e6

Please sign in to comment.