vendor/doctrine/persistence/src/Persistence/Mapping/Driver/AnnotationDriver.php line 62

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Persistence\Mapping\Driver;
  3. use Doctrine\Common\Annotations\Reader;
  4. use ReflectionClass;
  5. use function get_class;
  6. /**
  7.  * The AnnotationDriver reads the mapping metadata from docblock annotations.
  8.  *
  9.  * @deprecated use ColocatedMappingDriver directly instead.
  10.  */
  11. abstract class AnnotationDriver implements MappingDriver
  12. {
  13.     use ColocatedMappingDriver;
  14.     /**
  15.      * The annotation reader.
  16.      *
  17.      * @var Reader
  18.      */
  19.     protected $reader;
  20.     /**
  21.      * Name of the entity annotations as keys.
  22.      *
  23.      * @var array<class-string, bool|int>
  24.      */
  25.     protected $entityAnnotationClasses = [];
  26.     /**
  27.      * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
  28.      * docblock annotations.
  29.      *
  30.      * @param Reader               $reader The AnnotationReader to use, duck-typed.
  31.      * @param string|string[]|null $paths  One or multiple paths where mapping classes can be found.
  32.      */
  33.     public function __construct($reader$paths null)
  34.     {
  35.         $this->reader $reader;
  36.         $this->addPaths((array) $paths);
  37.     }
  38.     /**
  39.      * Retrieve the current annotation reader
  40.      *
  41.      * @return Reader
  42.      */
  43.     public function getReader()
  44.     {
  45.         return $this->reader;
  46.     }
  47.     /**
  48.      * {@inheritDoc}
  49.      */
  50.     public function isTransient($className)
  51.     {
  52.         $classAnnotations $this->reader->getClassAnnotations(new ReflectionClass($className));
  53.         foreach ($classAnnotations as $annot) {
  54.             if (isset($this->entityAnnotationClasses[get_class($annot)])) {
  55.                 return false;
  56.             }
  57.         }
  58.         return true;
  59.     }
  60. }