LoadAdminData::setContainer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Alpixel\Bundle\UserBundle\DataFixtures\ORM;
4
5
use Doctrine\Common\DataFixtures\FixtureInterface;
6
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
use Doctrine\Common\Persistence\ObjectManager;
8
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9
use Symfony\Component\DependencyInjection\ContainerInterface;
10
use Nelmio\Alice\Loader\NativeLoader;
11
12
class LoadAdminData implements FixtureInterface, ContainerAwareInterface, OrderedFixtureInterface
13
{
14
    /**
15
     * @var ContainerInterface
16
     */
17
    private $container;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function setContainer(ContainerInterface $container = null)
23
    {
24
        $this->container = $container;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function load(ObjectManager $manager)
31
    {
32
        $loader = new NativeLoader();
33
        $objectSet = $loader->loadFile(__DIR__ . '/../../Resources/fixtures/admin.yml');
34
        foreach ($objectSet->getObjects() as $obj) {
35
            $manager->persist($obj);
36
        }
37
        $manager->flush();
38
    }
39
40
    public function getOrder()
41
    {
42
        return 1; // the order in which fixtures will be loaded
43
    }
44
}
45