mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add fixture for location type
This commit is contained in:
parent
d1e2257db6
commit
8962c1c05f
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\DataFixtures\ORM;
|
||||
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\MainBundle\Entity\LocationType;
|
||||
|
||||
/**
|
||||
* Load location types into database
|
||||
*
|
||||
* @author Champs Libres
|
||||
*/
|
||||
class LoadLocationType extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function getOrder() {
|
||||
return 52;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager): void {
|
||||
|
||||
echo "loading some location type... \n";
|
||||
|
||||
$arr = [
|
||||
[
|
||||
'name' => ['fr' => 'Mairie'],
|
||||
'address_required' => LocationType::STATUS_OPTIONAL
|
||||
],
|
||||
[
|
||||
'name' => ['fr' => 'Guichet d\'accueil'],
|
||||
'address_required' => LocationType::STATUS_OPTIONAL
|
||||
],
|
||||
[
|
||||
'name' => ['fr' => 'Domicile de l\'usager'],
|
||||
'address_required' => LocationType::STATUS_REQUIRED
|
||||
],
|
||||
[
|
||||
'name' => ['fr' => 'Centre d\'aide sociale'],
|
||||
'address_required' => LocationType::STATUS_OPTIONAL
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($arr as $a) {
|
||||
$locationType = (new LocationType())
|
||||
->setTitle($a['name'])
|
||||
->setAvailableForUsers(True)
|
||||
->setAddressRequired($a['address_required']);
|
||||
$manager->persist($locationType);
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user