Skip to content

Commit

Permalink
Use the Persistence Proxy interface for checking ORM proxy objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker authored and franmomu committed Nov 25, 2023
1 parent 5d0b93d commit daa263a
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/References/Mapping/Event/Adapter/ODM.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Proxy\Proxy as ORMProxy;
use Doctrine\Persistence\Proxy as PersistenceProxy;
use Gedmo\Mapping\Event\Adapter\ODM as BaseAdapterODM;
use Gedmo\References\Mapping\Event\ReferencesAdapter;
use ProxyManager\Proxy\GhostObjectInterface;
Expand All @@ -32,7 +32,7 @@ public function getIdentifier($om, $object, $single = true)
}

if ($om instanceof EntityManagerInterface) {
if ($object instanceof ORMProxy) {
if ($object instanceof PersistenceProxy) {
$id = $om->getUnitOfWork()->getEntityIdentifier($object);
} else {
$meta = $om->getClassMetadata(get_class($object));
Expand Down
4 changes: 2 additions & 2 deletions src/References/Mapping/Event/Adapter/ORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Doctrine\ODM\MongoDB\DocumentManager as MongoDocumentManager;
use Doctrine\ODM\PHPCR\DocumentManager as PhpcrDocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Proxy\Proxy as ORMProxy;
use Doctrine\Persistence\Proxy as PersistenceProxy;
use Gedmo\Exception\InvalidArgumentException;
use Gedmo\Mapping\Event\Adapter\ORM as BaseAdapterORM;
use Gedmo\References\Mapping\Event\ReferencesAdapter;
Expand Down Expand Up @@ -79,7 +79,7 @@ public function getSingleReference($om, $class, $identifier)

public function extractIdentifier($om, $object, $single = true)
{
if ($object instanceof ORMProxy) {
if ($object instanceof PersistenceProxy) {
$id = $om->getUnitOfWork()->getEntityIdentifier($object);
} else {
$meta = $om->getClassMetadata(get_class($object));
Expand Down
1 change: 0 additions & 1 deletion src/Tool/Wrapper/EntityWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Persistence\Proxy as PersistenceProxy;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Tree/Entity/Repository/NestedTreeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
namespace Gedmo\Tree\Entity\Repository;

use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\Proxy;
use Gedmo\Exception\InvalidArgumentException;
use Gedmo\Exception\RuntimeException;
use Gedmo\Exception\UnexpectedValueException;
Expand Down
2 changes: 1 addition & 1 deletion src/Tree/Strategy/ORM/Nested.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Persistence\Proxy;
use Gedmo\Exception\InvalidArgumentException;
use Gedmo\Exception\UnexpectedValueException;
use Gedmo\Mapping\Event\AdapterInterface;
Expand Down
3 changes: 1 addition & 2 deletions tests/Gedmo/Timestampable/TimestampableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
namespace Gedmo\Tests\Timestampable;

use Doctrine\Common\EventManager;
use Doctrine\ORM\Proxy\Proxy;
use Gedmo\Tests\Mapping\Fixture\Xml\Timestampable;
use Doctrine\Persistence\Proxy;
use Gedmo\Tests\Timestampable\Fixture\Article;
use Gedmo\Tests\Timestampable\Fixture\Author;
use Gedmo\Tests\Timestampable\Fixture\Comment;
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Translatable/Issue/Issue84Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Gedmo\Tests\Translatable\Issue;

use Doctrine\Common\EventManager;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Persistence\Proxy;
use Gedmo\Tests\Tool\BaseTestCaseORM;
use Gedmo\Tests\Translatable\Fixture\Article;
use Gedmo\Translatable\Entity\Translation;
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Wrapper/EntityWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Gedmo\Tests\Wrapper;

use Doctrine\Common\EventManager;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Persistence\Proxy;
use Gedmo\Tests\Tool\BaseTestCaseORM;
use Gedmo\Tests\Wrapper\Fixture\Entity\Article;
use Gedmo\Tests\Wrapper\Fixture\Entity\Composite;
Expand Down

0 comments on commit daa263a

Please sign in to comment.