Pass class as second parameter to getReference() fixture method

This commit is contained in:
2024-11-28 13:28:52 +01:00
parent 19e6ceba28
commit f820273dd7
27 changed files with 94 additions and 59 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
@@ -55,8 +56,8 @@ class LoadRoleScopes extends AbstractFixture implements OrderedFixtureInterface
foreach (LoadScopes::$references as $scopeReference) {
$roleScope = new RoleScope();
$roleScope->setRole($key)
->setScope($this->getReference($scopeReference, null));
$reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference, null)->getName()['en'];
->setScope($this->getReference($scopeReference, Scope::class));
$reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference, Scope::class)->getName()['en'];
echo "Creating {$reference} \n";
$this->addReference($reference, $roleScope);
$manager->persist($roleScope);