mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-17 07:44:24 +00:00
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\MainBundle\DataFixtures\ORM;
|
|
|
|
use Chill\MainBundle\Entity\Center;
|
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
|
|
class LoadCenters extends AbstractFixture implements OrderedFixtureInterface
|
|
{
|
|
public static $centers = [
|
|
[
|
|
'name' => 'Center A',
|
|
'ref' => 'centerA',
|
|
],
|
|
[
|
|
'name' => 'Center B',
|
|
'ref' => 'centerB',
|
|
],
|
|
];
|
|
|
|
public static $refs = [];
|
|
|
|
public function getOrder()
|
|
{
|
|
return 100;
|
|
}
|
|
|
|
public function load(ObjectManager $manager)
|
|
{
|
|
foreach (static::$centers as $new) {
|
|
$center = new Center();
|
|
$center->setName($new['name']);
|
|
|
|
$manager->persist($center);
|
|
$this->addReference($new['ref'], $center);
|
|
static::$refs[] = $new['ref'];
|
|
}
|
|
|
|
$manager->flush();
|
|
}
|
|
}
|