LoadAdminData   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setContainer() 0 4 1
A load() 0 9 2
A getOrder() 0 4 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