|
@@ -7,6 +7,7 @@ use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
7
|
7
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
8
|
8
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
9
|
9
|
use Muzich\CoreBundle\Entity\User;
|
|
10
|
+use Muzich\CoreBundle\Entity\FollowUser;
|
10
|
11
|
|
11
|
12
|
class LoadUserData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
|
12
|
13
|
{
|
|
@@ -32,6 +33,8 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface, C
|
32
|
33
|
* @param string $email
|
33
|
34
|
* @param string $password_raw
|
34
|
35
|
* @param array $roles
|
|
36
|
+ *
|
|
37
|
+ * @return User
|
35
|
38
|
*/
|
36
|
39
|
protected function createUser($username, $email, $password_raw, $superadmin = false, $enabled = true)
|
37
|
40
|
{
|
|
@@ -49,6 +52,17 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface, C
|
49
|
52
|
$this->user_manager->updateUser($user, false);
|
50
|
53
|
$this->entity_manager->persist($user);
|
51
|
54
|
$this->addReference('user_'.$username, $user);
|
|
55
|
+
|
|
56
|
+ return $user;
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ protected function heFollowHim($follower, $followed)
|
|
60
|
+ {
|
|
61
|
+ $heFollowHim = new FollowUser();
|
|
62
|
+ $heFollowHim->setFollower($follower);
|
|
63
|
+ $heFollowHim->setFollowed($followed);
|
|
64
|
+ $follower->addFollowUser($heFollowHim);
|
|
65
|
+ $this->entity_manager->persist($heFollowHim);
|
52
|
66
|
}
|
53
|
67
|
|
54
|
68
|
public function load($entity_manager)
|
|
@@ -56,13 +70,19 @@ class LoadUserData extends AbstractFixture implements OrderedFixtureInterface, C
|
56
|
70
|
$this->entity_manager = $entity_manager;
|
57
|
71
|
$this->user_manager = $this->container->get('fos_user.user_manager');
|
58
|
72
|
|
59
|
|
- $this->createUser('admin', 'admin@root', 'toor');
|
60
|
|
- $this->createUser('bux', 'bux@root', 'toor');
|
61
|
|
- $this->createUser('jean', 'jean@root', 'toor');
|
62
|
|
- $this->createUser('paul', 'paul@root', 'toor');
|
63
|
|
- $this->createUser('bob', 'bob@root', 'toor');
|
64
|
|
- $this->createUser('joelle', 'joelle@root', 'toor');
|
|
73
|
+ // Création des Users
|
|
74
|
+ $admin = $this->createUser('admin', 'admin@root', 'toor');
|
|
75
|
+ $bux = $this->createUser('bux', 'bux@root', 'toor');
|
|
76
|
+ $jean = $this->createUser('jean', 'jean@root', 'toor');
|
|
77
|
+ $paul = $this->createUser('paul', 'paul@root', 'toor');
|
|
78
|
+ $bob = $this->createUser('bob', 'bob@root', 'toor');
|
|
79
|
+ $joelle = $this->createUser('joelle', 'joelle@root', 'toor');
|
65
|
80
|
|
|
81
|
+ // Relations
|
|
82
|
+ $this->heFollowHim($bux, $jean);
|
|
83
|
+ $this->heFollowHim($bux, $paul);
|
|
84
|
+ $this->heFollowHim($joelle, $bux);
|
|
85
|
+
|
66
|
86
|
$this->entity_manager->flush();
|
67
|
87
|
}
|
68
|
88
|
}
|