1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Commander project. |
4
|
|
|
* |
5
|
|
|
* @author Daniel Schröder <[email protected]> |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace GravityMedia\Commander\Provider; |
9
|
|
|
|
10
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
11
|
|
|
use Doctrine\Common\Annotations\AnnotationRegistry; |
12
|
|
|
use Doctrine\Common\Annotations\CachedReader; |
13
|
|
|
use Doctrine\Common\Cache\Cache; |
14
|
|
|
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; |
15
|
|
|
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain; |
16
|
|
|
use Doctrine\ORM\Mapping\Driver\AnnotationDriver; |
17
|
|
|
use Gedmo\DoctrineExtensions; |
18
|
|
|
use GravityMedia\Commander\Commander; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Mapping driver provider class. |
22
|
|
|
* |
23
|
|
|
* @package GravityMedia\Commander\Provider |
24
|
|
|
*/ |
25
|
|
|
class MappingDriverProvider |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* The cache. |
29
|
|
|
* |
30
|
|
|
* @var Cache |
31
|
|
|
*/ |
32
|
|
|
protected $cache; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The mapping driver. |
36
|
|
|
* |
37
|
|
|
* @var MappingDriver |
38
|
|
|
*/ |
39
|
|
|
protected $mappingDriver; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Create mapping driver provider object. |
43
|
|
|
* |
44
|
|
|
* @param Cache $cache |
45
|
|
|
*/ |
46
|
|
|
public function __construct(Cache $cache) |
47
|
|
|
{ |
48
|
|
|
$this->cache = $cache; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get mapping driver. |
53
|
|
|
* |
54
|
|
|
* @return MappingDriver |
55
|
|
|
*/ |
56
|
|
|
public function getMappingDriver() |
57
|
|
|
{ |
58
|
|
|
if (null === $this->mappingDriver) { |
59
|
|
|
AnnotationRegistry::registerFile( |
60
|
|
|
__DIR__ . '/../../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
$driverChain = new MappingDriverChain(); |
64
|
|
|
$reader = new CachedReader(new AnnotationReader(), $this->cache); |
65
|
|
|
|
66
|
|
|
DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $reader); |
67
|
|
|
|
68
|
|
|
$annotationDriver = new AnnotationDriver($reader, [__DIR__ . '/../ORM']); |
|
|
|
|
69
|
|
|
$driverChain->addDriver($annotationDriver, Commander::ENTITY_NAMESPACE); |
70
|
|
|
|
71
|
|
|
$this->mappingDriver = $driverChain; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return $this->mappingDriver; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: