vendor/doctrine/mongodb-odm-bundle/Repository/ServiceRepositoryTrait.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Bundle\MongoDBBundle\Repository;
  4. use Doctrine\ODM\MongoDB\DocumentManager;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. use LogicException;
  7. use function assert;
  8. use function sprintf;
  9. /** @template T of object */
  10. trait ServiceRepositoryTrait
  11. {
  12.     /**
  13.      * @param ManagerRegistry $registry      The ManagerRegistry to use
  14.      * @param string          $documentClass The class name of the entity this repository manages
  15.      * @psalm-param class-string<T> $documentClass
  16.      */
  17.     public function __construct(ManagerRegistry $registry$documentClass)
  18.     {
  19.         $manager $registry->getManagerForClass($documentClass);
  20.         assert($manager instanceof DocumentManager || $manager === null);
  21.         if ($manager === null) {
  22.             throw new LogicException(sprintf(
  23.                 'Could not find the document manager for class "%s". Check your Doctrine configuration to make sure it is configured to load this document’s metadata.',
  24.                 $documentClass,
  25.             ));
  26.         }
  27.         parent::__construct($manager$manager->getUnitOfWork(), $manager->getClassMetadata($documentClass));
  28.     }
  29. }