mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-10 00:34:58 +00:00
Fix calendarControllerTest: fix acl, and add calendar acl on fixtures
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Chill\CalendarBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
class LoadCalendarACL extends Fixture implements OrderedFixtureInterface
|
||||
{
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$roleScopes = [];
|
||||
|
||||
foreach ([
|
||||
CalendarVoter::CREATE,
|
||||
CalendarVoter::DELETE,
|
||||
CalendarVoter::DELETE
|
||||
] as $role) {
|
||||
$roleScopes[] = $r = (new RoleScope())
|
||||
->setRole($role);
|
||||
$manager->persist($r);
|
||||
}
|
||||
|
||||
foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) {
|
||||
/** @var PermissionsGroup $group */
|
||||
$group = $this->getReference($permissionGroupRef);
|
||||
|
||||
foreach ($roleScopes as $scope) {
|
||||
$group->addRoleScope($scope);
|
||||
}
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
public function getOrder(): int
|
||||
{
|
||||
return 16000;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user