mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,35 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
|
||||
/**
|
||||
* Adding acl for person document
|
||||
*
|
||||
* Adding acl for person document.
|
||||
*/
|
||||
class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
@@ -38,13 +27,13 @@ class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
return 35000;
|
||||
}
|
||||
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
|
||||
$permissionsGroup = $this->getReference($permissionsGroupRef);
|
||||
printf("processing permission group %s \n", $permissionsGroup->getName());
|
||||
foreach (LoadScopes::$references as $scopeRef){
|
||||
|
||||
foreach (LoadScopes::$references as $scopeRef) {
|
||||
$scope = $this->getReference($scopeRef);
|
||||
printf("processing scope %s \n", $scope->getName()['en']);
|
||||
//create permission group
|
||||
@@ -52,41 +41,47 @@ class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
case 'social':
|
||||
if ($scope->getName()['en'] === 'administrative') {
|
||||
printf("denying power on administrative \n");
|
||||
|
||||
break 2; // we do not want any power on administrative
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'administrative':
|
||||
case 'direction':
|
||||
if (in_array($scope->getName()['en'], array('administrative', 'social'), true)) {
|
||||
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
||||
printf("denying power on %s\n", $scope->getName()['en']);
|
||||
|
||||
break 2; // we do not want any power on social or administrative
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Adding Person report acl to %s "
|
||||
printf(
|
||||
'Adding Person report acl to %s '
|
||||
. "permission group, scope '%s' \n",
|
||||
$permissionsGroup->getName(), $scope->getName()['en']);
|
||||
$permissionsGroup->getName(),
|
||||
$scope->getName()['en']
|
||||
);
|
||||
$roleScopeUpdate = (new RoleScope())
|
||||
->setRole(PersonDocumentVoter::CREATE)
|
||||
->setScope($scope);
|
||||
->setRole(PersonDocumentVoter::CREATE)
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeUpdate);
|
||||
$roleScopeCreate = (new RoleScope())
|
||||
->setRole(PersonDocumentVoter::UPDATE)
|
||||
->setScope($scope);
|
||||
->setRole(PersonDocumentVoter::UPDATE)
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeCreate);
|
||||
$roleScopeDelete = (new RoleScope())
|
||||
->setRole(PersonDocumentVoter::DELETE)
|
||||
->setScope($scope);
|
||||
->setRole(PersonDocumentVoter::DELETE)
|
||||
->setScope($scope);
|
||||
$permissionsGroup->addRoleScope($roleScopeDelete);
|
||||
$manager->persist($roleScopeUpdate);
|
||||
$manager->persist($roleScopeCreate);
|
||||
$manager->persist($roleScopeDelete);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user