|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
ÁTICA - Aplicación web para la gestión documental de centros educativos |
|
4
|
|
|
|
|
5
|
|
|
Copyright (C) 2015-2016: Luis Ramón López López |
|
6
|
|
|
|
|
7
|
|
|
This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
it under the terms of the GNU Affero General Public License as published by |
|
9
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
10
|
|
|
(at your option) any later version. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
GNU Affero General Public License for more details. |
|
16
|
|
|
|
|
17
|
|
|
You should have received a copy of the GNU Affero General Public License |
|
18
|
|
|
along with this program. If not, see [http://www.gnu.org/licenses/]. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppBundle\DataFixtures\ORM; |
|
22
|
|
|
|
|
23
|
|
|
use AppBundle\Entity\Person; |
|
24
|
|
|
use AppBundle\Entity\User; |
|
25
|
|
|
use Doctrine\Common\DataFixtures\AbstractFixture; |
|
26
|
|
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; |
|
27
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
28
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
29
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
30
|
|
|
|
|
31
|
|
|
class LoadUserPersonData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var ContainerInterface |
|
35
|
|
|
*/ |
|
36
|
|
|
private $container; |
|
37
|
|
|
|
|
38
|
|
|
public function load(ObjectManager $manager) |
|
39
|
|
|
{ |
|
40
|
|
|
$userAdmin = new User(); |
|
41
|
|
|
$userAdmin |
|
42
|
|
|
->setDisplayName('Admin') |
|
43
|
|
|
->setFirstName('Admin') |
|
44
|
|
|
->setLastName('Admin') |
|
45
|
|
|
->setGender(Person::GENDER_UNKNOWN) |
|
46
|
|
|
->setReference('admin') |
|
47
|
|
|
->setEnabled(true) |
|
48
|
|
|
->setGlobalAdministrator(true) |
|
49
|
|
|
->setPassword($this->container->get('security.password_encoder')->encodePassword($userAdmin, 'admin')) |
|
50
|
|
|
->setLoginUsername('admin'); |
|
51
|
|
|
|
|
52
|
|
|
$manager->persist($userAdmin); |
|
53
|
|
|
|
|
54
|
|
|
$this->addReference('user-admin', $userAdmin); |
|
55
|
|
|
|
|
56
|
|
|
$manager->flush(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function getOrder() |
|
60
|
|
|
{ |
|
61
|
|
|
return 10; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Sets the container. |
|
66
|
|
|
* |
|
67
|
|
|
* @param ContainerInterface|null $container A ContainerInterface instance or null |
|
68
|
|
|
*/ |
|
69
|
|
|
public function setContainer(ContainerInterface $container = null) |
|
70
|
|
|
{ |
|
71
|
|
|
$this->container = $container; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|