/
Driver.php
48 lines (42 loc) · 1.26 KB
/
Driver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Concrete\Core\Database\EntityManager\Driver;
use \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
/**
* Each Doctrine MappingDriver must be wrapped by this class, so all Drivers can be
* loaded correctly during the bootstrap of the application
* Each new Doctrine MappingDriver must also be wrapped in a new instance of this class
*/
class Driver implements DriverInterface
{
protected $namespace;
protected $driver;
/**
* Constructor
*
* @param string $namespace
* @param \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver $driver
*/
public function __construct($namespace, MappingDriver $driver)
{
// Important: Doctrine internally works with namespaces that don't start
// with a backslash. If a namespace which starts with a backslash
// is provided, doctrine wouldn't find it in the DriverChain and
// through a MappingException
$this->namespace = ltrim($namespace, '\\');
$this->driver = $driver;
}
/**
* {@inheritDoc}
*/
public function getDriver()
{
return $this->driver;
}
/**
* {@inheritDoc}
*/
public function getNamespace()
{
return $this->namespace;
}
}