vendor/gedmo/doctrine-extensions/src/Mapping/Driver/Chain.php line 80

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Doctrine Behavioral Extensions package.
  4.  * (c) Gediminas Morkevicius <gediminas.morkevicius@gmail.com> http://www.gediminasm.org
  5.  * For the full copyright and license information, please view the LICENSE
  6.  * file that was distributed with this source code.
  7.  */
  8. namespace Gedmo\Mapping\Driver;
  9. use Gedmo\Mapping\Driver;
  10. /**
  11.  * The chain mapping driver enables chained
  12.  * extension mapping driver support
  13.  *
  14.  * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  15.  *
  16.  * @final since gedmo/doctrine-extensions 3.11
  17.  */
  18. class Chain implements Driver
  19. {
  20.     /**
  21.      * The default driver
  22.      *
  23.      * @var Driver|null
  24.      */
  25.     private $defaultDriver;
  26.     /**
  27.      * List of drivers nested
  28.      *
  29.      * @var Driver[]
  30.      */
  31.     private $_drivers = [];
  32.     /**
  33.      * Add a nested driver.
  34.      *
  35.      * @param string $namespace
  36.      *
  37.      * @return void
  38.      */
  39.     public function addDriver(Driver $nestedDriver$namespace)
  40.     {
  41.         $this->_drivers[$namespace] = $nestedDriver;
  42.     }
  43.     /**
  44.      * Get the array of nested drivers.
  45.      *
  46.      * @return Driver[] $drivers
  47.      */
  48.     public function getDrivers()
  49.     {
  50.         return $this->_drivers;
  51.     }
  52.     /**
  53.      * Get the default driver.
  54.      *
  55.      * @return Driver|null
  56.      */
  57.     public function getDefaultDriver()
  58.     {
  59.         return $this->defaultDriver;
  60.     }
  61.     /**
  62.      * Set the default driver.
  63.      *
  64.      * @return void
  65.      */
  66.     public function setDefaultDriver(Driver $driver)
  67.     {
  68.         $this->defaultDriver $driver;
  69.     }
  70.     public function readExtendedMetadata($meta, array &$config)
  71.     {
  72.         foreach ($this->_drivers as $namespace => $driver) {
  73.             if (=== strpos($meta->getName(), $namespace)) {
  74.                 $driver->readExtendedMetadata($meta$config);
  75.                 return;
  76.             }
  77.         }
  78.         if (null !== $this->defaultDriver) {
  79.             $this->defaultDriver->readExtendedMetadata($meta$config);
  80.             return;
  81.         }
  82.         // commenting it for customized mapping support, debugging of such cases might get harder
  83.         // throw new \Gedmo\Exception\UnexpectedValueException('Class ' . $meta->getName() . ' is not a valid entity or mapped super class.');
  84.     }
  85.     /**
  86.      * Passes in the mapping read by original driver
  87.      */
  88.     public function setOriginalDriver($driver)
  89.     {
  90.         // not needed here
  91.     }
  92. }