diff --git a/composer.json b/composer.json index 96f22df..dd3944d 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "jackalope/jackalope-doctrine-dbal": "^1.4", "phpunit/phpunit": "^9.4", "psr/http-message": "^1.0", - "refugis/doctrine-extra": "^2.4.0", + "refugis/doctrine-extra": "^2.4 || ^3.0", "refugis/elastica-odm": "2.x-dev", "roave/security-advisories": "dev-master", "solido/php-coding-standards": "dev-master", diff --git a/src/Doctrine/DBAL/PagerIterator.php b/src/Doctrine/DBAL/PagerIterator.php index 4763d92..e9991b9 100644 --- a/src/Doctrine/DBAL/PagerIterator.php +++ b/src/Doctrine/DBAL/PagerIterator.php @@ -4,10 +4,12 @@ namespace Solido\Pagination\Doctrine\DBAL; +use BadMethodCallException; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Query\QueryBuilder; use Doctrine\DBAL\Types\Types; +use Doctrine\Persistence\ObjectManager; use Refugis\DoctrineExtra\DBAL\IteratorTrait; use Refugis\DoctrineExtra\ObjectIteratorInterface; use RuntimeException; @@ -81,7 +83,7 @@ public function rewind(): void } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function filterObjects(array $objects): array { @@ -93,7 +95,7 @@ protected function filterObjects(array $objects): array } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function getObjects(): array { @@ -143,4 +145,9 @@ private static function toArray(object $rowObject): array { return json_decode(json_encode($rowObject, JSON_THROW_ON_ERROR, 512), true, 512, JSON_THROW_ON_ERROR); } + + public function getObjectManager(): ObjectManager + { + throw new BadMethodCallException('Cannot retrieve the object manager from a DBAL iterator'); + } } diff --git a/src/Doctrine/ORM/PagerIterator.php b/src/Doctrine/ORM/PagerIterator.php index 47d33db..2080c4d 100644 --- a/src/Doctrine/ORM/PagerIterator.php +++ b/src/Doctrine/ORM/PagerIterator.php @@ -86,7 +86,7 @@ public function setFetchMode(string $className, string $associationName, string } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function filterObjects(array $objects): array { @@ -98,7 +98,7 @@ protected function filterObjects(array $objects): array } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function getObjects(): array { diff --git a/src/Doctrine/PhpCr/PagerIterator.php b/src/Doctrine/PhpCr/PagerIterator.php index b697247..02fbb53 100644 --- a/src/Doctrine/PhpCr/PagerIterator.php +++ b/src/Doctrine/PhpCr/PagerIterator.php @@ -67,7 +67,7 @@ public function rewind(): void } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function filterObjects(array $objects): array { @@ -79,7 +79,7 @@ protected function filterObjects(array $objects): array } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function getObjects(): array { diff --git a/src/Elastica/PagerIterator.php b/src/Elastica/PagerIterator.php index 1d2b156..00f6a35 100644 --- a/src/Elastica/PagerIterator.php +++ b/src/Elastica/PagerIterator.php @@ -5,6 +5,7 @@ namespace Solido\Pagination\Elastica; use DateTimeImmutable; +use Doctrine\Persistence\ObjectManager; use Elastica\Query; use Refugis\DoctrineExtra\IteratorTrait; use Refugis\DoctrineExtra\ObjectIteratorInterface; @@ -68,7 +69,7 @@ public function rewind(): void } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function filterObjects(array $objects): array { @@ -80,7 +81,7 @@ protected function filterObjects(array $objects): array } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function getObjects(): array { @@ -146,4 +147,9 @@ protected function getObjects(): array return $search->execute(); } + + public function getObjectManager(): ObjectManager + { + return $this->search->getDocumentManager(); + } }