forked from doctrine/data-fixtures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoleFixture.php
31 lines (24 loc) · 865 Bytes
/
RoleFixture.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
declare(strict_types=1);
namespace Doctrine\Tests\Common\DataFixtures\TestFixtures;
use Doctrine\Common\DataFixtures\ReferenceRepository;
use Doctrine\Common\DataFixtures\SharedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Tests\Common\DataFixtures\TestEntity\Role;
class RoleFixture implements SharedFixtureInterface
{
/** @var ReferenceRepository|null */
private $referenceRepository;
public function setReferenceRepository(ReferenceRepository $referenceRepository)
{
$this->referenceRepository = $referenceRepository;
}
public function load(ObjectManager $manager)
{
$adminRole = new Role();
$adminRole->setName('admin');
$manager->persist($adminRole);
$this->referenceRepository->addReference('admin-role', $adminRole);
$manager->flush();
}
}