|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Fidry\AliceBundleExtension package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Théo FIDRY <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Fidry\AliceBundleExtension\Context\Doctrine; |
|
13
|
|
|
|
|
14
|
|
|
use Doctrine\ODM\MongoDB\DocumentManager; |
|
15
|
|
|
use Doctrine\ODM\MongoDB\SchemaManager; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Context to load fixtures files with Alice loader. |
|
19
|
|
|
* |
|
20
|
|
|
* @author Théo FIDRY <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class AliceODMContext extends AbstractAliceContext |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
|
|
public function createSchema() |
|
28
|
|
|
{ |
|
29
|
|
|
$schemaManager = $this->getSchemaManager(); |
|
30
|
|
|
|
|
31
|
|
|
$schemaManager->createCollections(); |
|
32
|
|
|
$schemaManager->ensureIndexes(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
|
|
public function dropSchema() |
|
39
|
|
|
{ |
|
40
|
|
|
$schemaManager = $this->getSchemaManager(); |
|
41
|
|
|
|
|
42
|
|
|
$schemaManager->deleteIndexes(); |
|
43
|
|
|
$schemaManager->dropCollections(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritdoc} |
|
48
|
|
|
*/ |
|
49
|
|
|
public function emptyDatabase() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->dropSchema(); |
|
52
|
|
|
$this->createSchema(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* {@inheritdoc} |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function getPersister() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->resolvePersister($this->getDocumentManager()); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* {@inheritdoc} |
|
65
|
|
|
*/ |
|
66
|
|
|
protected function getFixturesFinder() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->kernel->getContainer()->get('hautelook_alice.doctrine.mongodb.fixtures_finder'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return SchemaManager |
|
73
|
|
|
*/ |
|
74
|
|
|
private function getSchemaManager() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->getDocumentManager()->getSchemaManager(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return DocumentManager |
|
81
|
|
|
*/ |
|
82
|
|
|
private function getDocumentManager() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->kernel->getContainer()->get('doctrine_mongodb.odm.default_document_manager'); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
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: