1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Hautelook\AliceBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Baldur Rensch <[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 Hautelook\AliceBundle\Alice\DataFixtures\Fixtures; |
13
|
|
|
|
14
|
|
|
use Hautelook\AliceBundle\Faker\Provider\ProviderChain; |
15
|
|
|
use Nelmio\Alice\PersisterInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Bridge for Alice's loader. |
19
|
|
|
* |
20
|
|
|
* @author Théo FIDRY <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class Loader extends \Nelmio\Alice\Fixtures\Loader implements LoaderInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @param string $locale |
26
|
|
|
* @param ProviderChain $providerChain |
27
|
|
|
* @param int $seed |
28
|
|
|
* @param array $parameters |
29
|
|
|
*/ |
30
|
120 |
|
public function __construct($locale = 'en_US', ProviderChain $providerChain, $seed = 1, array $parameters = []) |
31
|
|
|
{ |
32
|
120 |
|
parent::__construct($locale, $providerChain->getProviders(), $seed, $parameters); |
33
|
120 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Loads a fixture file. |
37
|
|
|
* |
38
|
|
|
* @param string|array $dataOrFilename May either be the path to the file in which case it will be parsed, or be |
39
|
|
|
* an array of data (then skips the parsing). The format of the array of data |
40
|
|
|
* depends of the builders used. |
41
|
|
|
* @param array $references Array where the key is the object name and the value the actual object |
42
|
|
|
* class. The references are used to inject objects which the loader should be |
43
|
|
|
* aware of while loading the file. |
44
|
|
|
* |
45
|
|
|
* @return array|\object[] |
46
|
|
|
*/ |
47
|
78 |
|
public function load($dataOrFilename, array $references = []) |
48
|
|
|
{ |
49
|
78 |
|
$this->setReferences($references); |
50
|
78 |
|
$objects = parent::load($dataOrFilename); |
51
|
78 |
|
$this->setReferences([]); |
52
|
|
|
|
53
|
78 |
|
return $objects; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return PersisterInterface |
58
|
|
|
*/ |
59
|
78 |
|
public function getPersister() |
60
|
|
|
{ |
61
|
78 |
|
return $this->manager; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|