Completed
Push — master ( 73634f...8a94ba )
by Philip
02:09
created

Users::setContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Dontdrinkandroot\Gitki\WebBundle\DataFixtures\ORM;
4
5
use Doctrine\Common\DataFixtures\FixtureInterface;
6
use Doctrine\Common\Persistence\ObjectManager;
7
use FOS\UserBundle\Model\UserManagerInterface;
8
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9
use Symfony\Component\DependencyInjection\ContainerInterface;
10
11
class Users implements FixtureInterface, ContainerAwareInterface
12
{
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
        /** @var UserManagerInterface $userManager */
33
        $userManager = $this->container->get('fos_user.user_manager');
34
35
        $user = $userManager->createUser();
36
        $user->setUsername('watcher');
37
        $user->setEmail('[email protected]');
38
        $user->setPlainPassword('watcher');
39
        $user->setEnabled(true);
40
41
        $userManager->updateUser($user);
42
43
        $user = $userManager->createUser();
44
        $user->setUsername('committer');
45
        $user->setEmail('[email protected]');
46
        $user->setPlainPassword('committer');
47
        $user->setEnabled(true);
48
49
        $userManager->updateUser($user);
50
51
        $user = $userManager->createUser();
52
        $user->setUsername('admin');
53
        $user->setEmail('[email protected]');
54
        $user->setPlainPassword('admin');
55
        $user->setEnabled(true);
56
57
        $userManager->updateUser($user);
58
    }
59
}
60