123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace Gedmo\Mapping\Driver;
- use Gedmo\Mapping\Driver,
- Doctrine\Common\Persistence\Mapping\ClassMetadata;
- /**
- * The chain mapping driver enables chained
- * extension mapping driver support
- *
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
- * @package Gedmo.Mapping.Driver
- * @subpackage Chain
- * @link http://www.gediminasm.org
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
- */
- class Chain implements Driver
- {
- /**
- * List of drivers nested
- * @var array
- */
- private $_drivers = array();
- /**
- * Add a nested driver.
- *
- * @param Driver $nestedDriver
- * @param string $namespace
- */
- public function addDriver(Driver $nestedDriver, $namespace)
- {
- $this->_drivers[$namespace] = $nestedDriver;
- }
- /**
- * Get the array of nested drivers.
- *
- * @return array $drivers
- */
- public function getDrivers()
- {
- return $this->_drivers;
- }
- /**
- * {@inheritDoc}
- */
- public function readExtendedMetadata(ClassMetadata $meta, array &$config)
- {
- foreach ($this->_drivers as $namespace => $driver) {
- if (strpos($meta->name, $namespace) === 0) {
- $driver->readExtendedMetadata($meta, $config);
- return;
- }
- }
- // commenting it for customized mapping support, debugging of such cases might get harder
- //throw new \Gedmo\Exception\UnexpectedValueException('Class ' . $meta->name . ' is not a valid entity or mapped super class.');
- }
- /**
- * Passes in the mapping read by original driver
- *
- * @param $driver
- * @return void
- */
- public function setOriginalDriver($driver)
- {
- //not needed here
- }
- }
|