Completed
Push — Recipes ( 630f49...c8afb0 )
by Laurent
12:15 queued 03:48
created

LoadGroupData::getGroups()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * LoadGroupData Datas of groups of GLSR application.
4
 *
5
 * PHP Version 7
6
 *
7
 * @author    Quétier Laurent <[email protected]>
8
 * @copyright 2014 Dev-Int GLSR
9
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
10
 *
11
 * @version GIT: <git_id>
12
 *
13
 * @see      https://github.com/Dev-Int/glsr
14
 */
15
16
namespace App\DataFixtures;
17
18
use App\Entity\Staff\Group;
19
use Doctrine\Common\Persistence\ObjectManager;
20
use Doctrine\Bundle\FixturesBundle\Fixture;
21
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
22
23
/**
24
 * LoadGroup Data.
25
 *
26
 * @category DataFixtures
27
 */
28
class LoadGroupData extends Fixture implements FixtureGroupInterface
29
{
30
    /**
31
     * Datas groups.
32
     *
33
     * @var array
34
     */
35
    private $datas = [
36
        ['admin', 'ROLE_SUPER_ADMIN'],
37
        ['assistant', 'ROLE_ADMIN'],
38
        ['user', 'ROLE_USER'],
39
    ];
40
41
    /**
42
     * Load data fixtures with the passed EntityManager.
43
     *
44
     * @param ObjectManager $manager
45
     */
46
    public function load(ObjectManager $manager)
47
    {
48
        foreach ($this->datas as $data) {
49
            $groupAdmin = new Group($data[0], [$data[1]]);
50
            $groupAdmin->setName($data[0]);
51
            $groupAdmin->setRoles([$data[1]]);
52
53
            $manager->persist($groupAdmin);
54
            $this->addReference('group-'.$data[0], $groupAdmin);
55
        }
56
        $manager->flush();
57
    }
58
59
    public static function getGroups(): array
60
    {
61
        return ['userGroup'];
62
    }
63
}
64