Skip to content

Commit 3c9a2cb

Browse files
committed
Merge branch '2.x' into '3.x'
2 parents ef4d04c + df8527e commit 3c9a2cb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Form/Transformer/EntityToIdObjectTransformer.php

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

1212
namespace FOS\RestBundle\Form\Transformer;
1313

14-
use Doctrine\Common\Persistence\ObjectManager;
14+
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
15+
use Doctrine\Persistence\ObjectManager;
1516
use Symfony\Component\Form\DataTransformerInterface;
1617
use Symfony\Component\Form\Exception\TransformationFailedException;
1718

@@ -27,8 +28,12 @@ class EntityToIdObjectTransformer implements DataTransformerInterface
2728
private $om;
2829
private $entityName;
2930

30-
public function __construct(ObjectManager $om, string $entityName)
31+
public function __construct($om, string $entityName)
3132
{
33+
if (!$om instanceof ObjectManager && !$om instanceof LegacyObjectManager) {
34+
throw new \TypeError(sprintf('The first argument of %s() must be an instance of "%s" ("%s" given).', __METHOD__, ObjectManager::class, is_object($om) ? get_class($om) : gettype($om)));
35+
}
36+
3237
$this->entityName = $entityName;
3338
$this->om = $om;
3439
}

0 commit comments

Comments
 (0)