Created
October 25, 2017 01:37
-
-
Save cricri92/95055f1c6d5d702626420385814312ad to your computer and use it in GitHub Desktop.
Data fixture para crear un usuario con rol docente y otro con rol profesor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ReincorporacionBundle\DataFixtures\ORM; | |
use AppBundle\Entity\Usuario; | |
use Doctrine\Common\Persistence\ObjectManager; | |
use Doctrine\Common\DataFixtures\AbstractFixture; | |
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | |
use ReincorporacionBundle\Entity\Desincorporacion; | |
use Symfony\Component\DependencyInjection\ContainerAwareInterface; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
class LoadDataReincorporacion extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface | |
{ | |
/** | |
* @var ContainerInterface | |
*/ | |
private $container; | |
public function setContainer(ContainerInterface $container = null) | |
{ | |
$this->container = $container; | |
} | |
public function load(ObjectManager $manager) { | |
// Usuario docente regular | |
$docenteRegular = new Usuario(); | |
$docenteRegular->setCedula('21032767'); | |
$docenteRegular->setEdad(0); | |
$docenteRegular->setSexo(''); | |
$docenteRegular->setPrimerNombre('Ornela'); | |
$docenteRegular->setSegundoNombre('Mercedes'); | |
$docenteRegular->setPrimerApellido('Ruiz'); | |
$docenteRegular->setSegundoApellido(' '); | |
$docenteRegular->setNacionalidad('_'); | |
$docenteRegular->setCorreo('[email protected]'); | |
$docenteRegular->setTelefono(''); | |
$docenteRegular->setRif(''); | |
$docenteRegular->setActivo(true); | |
$docenteRegular->setIsRegister(true); | |
$docenteRegular->setDireccion('Valencia'); | |
$encoder = $this->container->get('security.password_encoder'); | |
$password = $encoder->encodePassword($docenteRegular, '1234'); | |
$docenteRegular->setPassword($password); | |
$docenteRegular->addRol($this->getReference('Profesor')); | |
$manager->persist($docenteRegular); | |
$this->addReference('ornela-user', $docenteRegular); | |
$manager->flush(); | |
// Usuario Asuntos Profesorales | |
$asuntosProfesorales = new Usuario(); | |
$asuntosProfesorales->setCedula('7155304'); | |
$asuntosProfesorales->setEdad(0); | |
$asuntosProfesorales->setSexo(''); | |
$asuntosProfesorales->setPrimerNombre('Alixia'); | |
$asuntosProfesorales->setSegundoNombre('Mercedes'); | |
$asuntosProfesorales->setPrimerApellido('Alfonzo'); | |
$asuntosProfesorales->setSegundoApellido(' '); | |
$asuntosProfesorales->setNacionalidad('_'); | |
$asuntosProfesorales->setCorreo('[email protected]'); | |
$asuntosProfesorales->setTelefono(''); | |
$asuntosProfesorales->setRif(''); | |
$asuntosProfesorales->setActivo(true); | |
$asuntosProfesorales->setIsRegister(true); | |
$asuntosProfesorales->setDireccion('Valencia'); | |
$encoder = $this->container->get('security.password_encoder'); | |
$password = $encoder->encodePassword($asuntosProfesorales, '1234'); | |
$asuntosProfesorales->setPassword($password); | |
$asuntosProfesorales->addRol($this->getReference('Asuntos Profesorales')); | |
$manager->persist($asuntosProfesorales); | |
$this->addReference('alixia-user', $asuntosProfesorales); | |
$manager->flush(); | |
} | |
public function getOrder() | |
{ | |
return 13; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment