Skip to content

Commit 7390fd3

Browse files
committed
fixing usage of legacy manager registry
The user's app might use either the new or old class. This is already handled correctly on DoctrineHelper.
1 parent fabbbef commit 7390fd3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Validator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
namespace Symfony\Bundle\MakerBundle;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
15+
use Doctrine\Persistence\ManagerRegistry;
1516
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
1617
use Symfony\Component\Security\Core\User\UserInterface;
1718

@@ -155,8 +156,15 @@ public static function validatePropertyName(string $name)
155156
return $name;
156157
}
157158

158-
public static function validateDoctrineFieldName(string $name, ManagerRegistry $registry)
159+
/**
160+
* @param ManagerRegistry|LegacyManagerRegistry $registry
161+
*/
162+
public static function validateDoctrineFieldName(string $name, $registry)
159163
{
164+
if (!$registry instanceof ManagerRegistry && !$registry instanceof LegacyManagerRegistry) {
165+
throw new \InvalidArgumentException(sprintf('Argument 2 to %s::validateDoctrineFieldName must be an instance of %s, %s passed.', __CLASS__, ManagerRegistry::class, \is_object($registry) ? \get_class($registry) : \gettype($registry)));
166+
}
167+
160168
// check reserved words
161169
if ($registry->getConnection()->getDatabasePlatform()->getReservedKeywordsList()->isKeyword($name)) {
162170
throw new \InvalidArgumentException(sprintf('Name "%s" is a reserved word.', $name));

0 commit comments

Comments
 (0)