vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php line 29

  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\ODM\MongoDB\Event;
  4. use Doctrine\ODM\MongoDB\DocumentManager;
  5. use Doctrine\Persistence\Event\OnClearEventArgs as BaseOnClearEventArgs;
  6. use function func_num_args;
  7. use function method_exists;
  8. use function trigger_deprecation;
  9. /**
  10.  * Provides event arguments for the onClear event.
  11.  *
  12.  * @template-extends BaseOnClearEventArgs<DocumentManager>
  13.  */
  14. final class OnClearEventArgs extends BaseOnClearEventArgs
  15. {
  16.     /**
  17.      * @deprecated
  18.      *
  19.      * @var class-string|null
  20.      */
  21.     private ?string $entityClass;
  22.     /** @param class-string|null $entityClass */
  23.     public function __construct($objectManager$entityClass null)
  24.     {
  25.         if (method_exists(parent::class, 'getEntityClass') && $entityClass !== null) {
  26.             parent::__construct($objectManager$entityClass);
  27.         } else {
  28.             if (func_num_args() > 1) {
  29.                 trigger_deprecation(
  30.                     'doctrine/mongodb-odm',
  31.                     '2.4',
  32.                     'Passing $entityClass argument to %s::%s() is deprecated and will not be supported in Doctrine ODM 3.0.',
  33.                     self::class,
  34.                     __METHOD__,
  35.                 );
  36.             }
  37.             parent::__construct($objectManager);
  38.         }
  39.         $this->entityClass $entityClass;
  40.     }
  41.     public function getDocumentManager(): DocumentManager
  42.     {
  43.         return $this->getObjectManager();
  44.     }
  45.     /**
  46.      * @deprecated no replacement planned
  47.      *
  48.      * @return class-string|null
  49.      */
  50.     public function getDocumentClass(): ?string
  51.     {
  52.         trigger_deprecation(
  53.             'doctrine/mongodb-odm',
  54.             '2.4',
  55.             'Calling %s() is deprecated and will not be supported in Doctrine ODM 3.0.',
  56.             __METHOD__,
  57.         );
  58.         return $this->entityClass;
  59.     }
  60.     /**
  61.      * Returns whether this event clears all documents.
  62.      *
  63.      * @deprecated no replacement planned
  64.      */
  65.     public function clearsAllDocuments(): bool
  66.     {
  67.         trigger_deprecation(
  68.             'doctrine/mongodb-odm',
  69.             '2.4',
  70.             'Calling %s() is deprecated and will not be supported in Doctrine ODM 3.0.',
  71.             __METHOD__,
  72.         );
  73.         return $this->entityClass !== null;
  74.     }
  75.     /** @deprecated no replacement planned */
  76.     public function clearsAllEntities(): bool
  77.     {
  78.         if (method_exists(parent::class, 'clearsAllEntities')) {
  79.             return parent::clearsAllEntities();
  80.         }
  81.         trigger_deprecation(
  82.             'doctrine/mongodb-odm',
  83.             '2.4',
  84.             'Calling %s() is deprecated and will not be supported in Doctrine ODM 3.0.',
  85.             __METHOD__,
  86.         );
  87.         return $this->entityClass !== null;
  88.     }
  89.     /**
  90.      * @deprecated no replacement planned
  91.      *
  92.      * @return class-string|null
  93.      */
  94.     public function getEntityClass(): ?string
  95.     {
  96.         if (method_exists(parent::class, 'getEntityClass')) {
  97.             return parent::getEntityClass();
  98.         }
  99.         trigger_deprecation(
  100.             'doctrine/mongodb-odm',
  101.             '2.4',
  102.             'Calling %s() is deprecated and will not be supported in Doctrine ODM 3.0.',
  103.             __METHOD__,
  104.         );
  105.         return $this->entityClass;
  106.     }
  107. }