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
|
|
|
|