. */ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain, Doctrine\Common\Persistence\Mapping\ClassMetadata, Doctrine\ORM\Mapping\MappingException; /** * The DriverChain allows you to add multiple other mapping drivers for * certain namespaces * * @since 2.0 * @author Benjamin Eberlei * @author Guilherme Blanco * @author Jonathan H. Wage * @author Roman Borschel */ class DriverChain extends MappingDriverChain { /** * The default driver * * @var MappingDriver */ private $defaultDriver; /** * Get the default driver. * * @return MappingDriver|null */ public function getDefaultDriver() { return $this->defaultDriver; } /** * Set the default driver. * * @param MappingDriver $driver */ public function setDefaultDriver(MappingDriver $driver) { $this->defaultDriver = $driver; } /** * {@inheritDoc} * @throws MappingException */ public function loadMetadataForClass($className, ClassMetadata $metadata) { /* @var $driver MappingDriver */ foreach ($this->getDrivers() as $namespace => $driver) { if (strpos($className, $namespace) === 0) { $driver->loadMetadataForClass($className, $metadata); return; } } if ($this->defaultDriver !== null) { $this->defaultDriver->loadMetadataForClass($className, $metadata); return; } throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className); } /** * {@inheritDoc} */ public function isTransient($className) { if (!parent::isTransient($className)) { return false; } if ($this->defaultDriver !== null) { return $this->defaultDriver->isTransient($className); } return true; } }