| Total Complexity | 4 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class LoadOrganisations extends BaseFixture |
||
| 20 | { |
||
| 21 | const ORDER = 1; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var SerializerInterface |
||
| 25 | */ |
||
| 26 | private $serializer; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * LoadEvent constructor. |
||
| 30 | */ |
||
| 31 | public function __construct(SerializerInterface $serializer) |
||
| 32 | { |
||
| 33 | $this->serializer = $serializer; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Load data fixtures with the passed EntityManager. |
||
| 38 | */ |
||
| 39 | public function load(ObjectManager $manager) |
||
| 40 | { |
||
| 41 | //prepare resources |
||
| 42 | $json = file_get_contents(__DIR__ . '/Resources/organisations.json'); |
||
| 43 | $organisations = $this->serializer->deserialize($json, Organisation::class . '[]', 'json'); |
||
| 44 | |||
| 45 | foreach ($organisations as $organisation) { |
||
| 46 | $manager->persist($organisation); |
||
| 47 | } |
||
| 48 | |||
| 49 | $manager->flush(); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get the order of this fixture. |
||
| 54 | * |
||
| 55 | * @return int |
||
| 56 | */ |
||
| 57 | public function getOrder() |
||
| 60 | } |
||
| 61 | } |
||
| 62 |