mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-03 23:46:12 +00:00
Add exports permissions when loading fixtures
This commit is contained in:
parent
2c85de05b8
commit
a180050622
@ -11,7 +11,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\GroupCenter;
|
||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
@ -62,6 +65,15 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
|
||||
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$roleScope = new RoleScope();
|
||||
$roleScope->setRole('CHILL_MAIN_COMPOSE_EXPORT');
|
||||
$permissionGroup = new PermissionsGroup();
|
||||
$permissionGroup->setName('export');
|
||||
$permissionGroup->addRoleScope($roleScope);
|
||||
|
||||
$manager->persist($roleScope);
|
||||
$manager->persist($permissionGroup);
|
||||
|
||||
foreach (self::$refs as $username => $params) {
|
||||
$user = new User();
|
||||
|
||||
@ -81,7 +93,14 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
|
||||
->setEmail(sprintf('%s@chill.social', \str_replace(' ', '', (string) $username)));
|
||||
|
||||
foreach ($params['groupCenterRefs'] as $groupCenterRef) {
|
||||
$user->addGroupCenter($this->getReference($groupCenterRef, GroupCenter::class));
|
||||
$user->addGroupCenter($gc = $this->getReference($groupCenterRef, GroupCenter::class));
|
||||
|
||||
$exportGroupCenter = new GroupCenter();
|
||||
$exportGroupCenter->setPermissionsGroup($permissionGroup);
|
||||
$exportGroupCenter->setCenter($gc->getCenter());
|
||||
$manager->persist($exportGroupCenter);
|
||||
|
||||
$user->addGroupCenter($exportGroupCenter);
|
||||
}
|
||||
|
||||
echo 'Creating user '.$username."... \n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user