class MappingDriverChain in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain
The DriverChain allows you to add multiple other mapping drivers for certain namespaces.
@since 2.2 @author Benjamin Eberlei <kontakt@beberlei.de> @author Guilherme Blanco <guilhermeblanco@hotmail.com> @author Jonathan H. Wage <jonwage@gmail.com> @author Roman Borschel <roman@code-factory.org>
Hierarchy
- class \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain implements MappingDriver
Expanded class hierarchy of MappingDriverChain
1 file declares its use of MappingDriverChain
- ChainDriverTest.php in vendor/
doctrine/ common/ tests/ Doctrine/ Tests/ Common/ Persistence/ Mapping/ ChainDriverTest.php
File
- vendor/
doctrine/ common/ lib/ Doctrine/ Common/ Persistence/ Mapping/ Driver/ MappingDriverChain.php, line 35
Namespace
Doctrine\Common\Persistence\Mapping\DriverView source
class MappingDriverChain implements MappingDriver {
/**
* The default driver.
*
* @var MappingDriver|null
*/
private $defaultDriver = null;
/**
* @var array
*/
private $drivers = array();
/**
* Gets the default driver.
*
* @return MappingDriver|null
*/
public function getDefaultDriver() {
return $this->defaultDriver;
}
/**
* Set the default driver.
*
* @param MappingDriver $driver
*
* @return void
*/
public function setDefaultDriver(MappingDriver $driver) {
$this->defaultDriver = $driver;
}
/**
* Adds a nested driver.
*
* @param MappingDriver $nestedDriver
* @param string $namespace
*
* @return void
*/
public function addDriver(MappingDriver $nestedDriver, $namespace) {
$this->drivers[$namespace] = $nestedDriver;
}
/**
* Gets the array of nested drivers.
*
* @return array $drivers
*/
public function getDrivers() {
return $this->drivers;
}
/**
* {@inheritDoc}
*/
public function loadMetadataForClass($className, ClassMetadata $metadata) {
/* @var $driver MappingDriver */
foreach ($this->drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) {
$driver
->loadMetadataForClass($className, $metadata);
return;
}
}
if (null !== $this->defaultDriver) {
$this->defaultDriver
->loadMetadataForClass($className, $metadata);
return;
}
throw MappingException::classNotFoundInNamespaces($className, array_keys($this->drivers));
}
/**
* {@inheritDoc}
*/
public function getAllClassNames() {
$classNames = array();
$driverClasses = array();
/* @var $driver MappingDriver */
foreach ($this->drivers as $namespace => $driver) {
$oid = spl_object_hash($driver);
if (!isset($driverClasses[$oid])) {
$driverClasses[$oid] = $driver
->getAllClassNames();
}
foreach ($driverClasses[$oid] as $className) {
if (strpos($className, $namespace) === 0) {
$classNames[$className] = true;
}
}
}
if (null !== $this->defaultDriver) {
foreach ($this->defaultDriver
->getAllClassNames() as $className) {
$classNames[$className] = true;
}
}
return array_keys($classNames);
}
/**
* {@inheritDoc}
*/
public function isTransient($className) {
/* @var $driver MappingDriver */
foreach ($this->drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) {
return $driver
->isTransient($className);
}
}
if ($this->defaultDriver !== null) {
return $this->defaultDriver
->isTransient($className);
}
return true;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MappingDriverChain:: |
private | property | The default driver. | |
MappingDriverChain:: |
private | property | ||
MappingDriverChain:: |
public | function | Adds a nested driver. | |
MappingDriverChain:: |
public | function |
Gets the names of all mapped classes known to this driver. Overrides MappingDriver:: |
|
MappingDriverChain:: |
public | function | Gets the default driver. | |
MappingDriverChain:: |
public | function | Gets the array of nested drivers. | |
MappingDriverChain:: |
public | function |
Returns whether the class with the specified name should have its metadata loaded.
This is only the case if it is either mapped as an Entity or a MappedSuperclass. Overrides MappingDriver:: |
|
MappingDriverChain:: |
public | function |
Loads the metadata for the specified class into the provided container. Overrides MappingDriver:: |
|
MappingDriverChain:: |
public | function | Set the default driver. |