Skip to content

Commit

Permalink
Deprecate console helper
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Apr 10, 2022
1 parent a3d82f8 commit 045f4e2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
9 changes: 8 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Upgrade to 2.12

## Deprecate `Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper`

Using a console helper to provide the ORM's console commands with one or
multiple entity managers had been deprecated with 2.9 already. This leaves
The `EntityManagerHelper` class with no purpose which is why it is now
deprecated too. Applications that still rely on the `em` console helper, can
easily recreate that class in their own codebase.

## Deprecate custom repository classes that don't extend `EntityRepository`

Although undocumented, it is currently possible to configure a custom repository
Expand All @@ -19,7 +27,6 @@ This is now deprecated. Please extend `EntityRepository` instead.
+$entityManager->getRepository(CmsUser::class);
```


## BC Break: `AttributeDriver` and `AnnotationDriver` no longer extends parent class from `doctrine/persistence`

Both these classes used to extend an abstract `AnnotationDriver` class defined
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ final class ConsoleRunner
{
/**
* Create a Symfony Console HelperSet
*
* @deprecated This method will be removed in ORM 3.0 without replacement.
*/
public static function createHelperSet(EntityManagerInterface $entityManager): HelperSet
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

use function assert;

/**
* @deprecated This class will be removed in ORM 3.0 without replacement.
*/
final class HelperSetManagerProvider implements EntityManagerProvider
{
/** @var HelperSet */
Expand Down
10 changes: 9 additions & 1 deletion lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

namespace Doctrine\ORM\Tools\Console\Helper;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Helper\Helper;

/**
* Doctrine CLI Connection Helper.
*
* @link www.doctrine-project.org
* @deprecated This class will be removed in ORM 3.0 without replacement.
*/
class EntityManagerHelper extends Helper
{
Expand All @@ -23,6 +24,13 @@ class EntityManagerHelper extends Helper

public function __construct(EntityManagerInterface $em)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/orm',
'https://github.com/doctrine/orm/pull/9641',
'The %s class is deprecated and will be removed in ORM 3.0',
self::class
);

$this->_em = $em;
}

Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<referencedClass name="Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand"/>
<referencedClass name="Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper"/>
<referencedClass name="Doctrine\ORM\Tools\Console\EntityManagerProvider\HelperSetManagerProvider"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedConstant>
Expand Down

0 comments on commit 045f4e2

Please sign in to comment.