Skip to content

Commit

Permalink
Merge pull request #871 from doctrine/add-uninitialized-proxy-method
Browse files Browse the repository at this point in the history
add forward compatible method
  • Loading branch information
dbu authored May 5, 2024
2 parents 296ecae + 903a564 commit b4a547b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,9 @@ public function getDocumentId(object $document): string
{
return $this->wrapped->getDocumentId($document);
}

public function isUninitializedObject(mixed $value): bool
{
return $this->wrapped->isUninitializedObject($value);
}
}
6 changes: 6 additions & 0 deletions lib/Doctrine/ODM/PHPCR/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Doctrine\ODM\PHPCR\Translation\TranslationStrategy\ChildTranslationStrategy;
use Doctrine\ODM\PHPCR\Translation\TranslationStrategy\TranslationStrategyInterface;
use Doctrine\Persistence\ObjectRepository;
use Doctrine\Persistence\Proxy;
use PHPCR\ItemNotFoundException;
use PHPCR\NodeInterface;
use PHPCR\PathNotFoundException;
Expand Down Expand Up @@ -656,4 +657,9 @@ public function getDocumentId(object $document): ?string
{
return $this->unitOfWork->getDocumentId($document);
}

public function isUninitializedObject(mixed $value): bool
{
return $value instanceof Proxy && !$value->__isInitialized();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public function testCheckIfAllPublicMethodsAreDecorated(): void
sort($dmMethods);

$dmiMethods = get_class_methods(DocumentManagerInterface::class);
$dmiMethods = array_diff($dmiMethods, ['__construct']);
if (!in_array('isUninitializedObject', $dmiMethods)) {
$dmiMethods[] = 'isUninitializedObject'; // this method will only be added i ORM 4.*
}
sort($dmiMethods);

$dmdMethods = get_class_methods(OwnDocumentManager::class);
Expand Down

0 comments on commit b4a547b

Please sign in to comment.