cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,37 +1,29 @@
<?php
/**
* 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.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Security\Authorization;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
use function in_array;
class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE';
/**
* details are for seeing:
*
* * SocialIssues
*/
public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS';
public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE';
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE';
public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE';
/**
* Give all the right above
*/
public const FULL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_FULL';
public const ALL = [
self::SEE,
self::SEE_DETAILS,
@@ -41,10 +33,30 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole
self::FULL,
];
private VoterHelperInterface $voterHelper;
public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE';
public const DELETE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE';
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE';
/**
* Give all the right above.
*/
public const FULL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_FULL';
public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE';
/**
* details are for seeing:.
*
* * SocialIssues
*/
public const SEE_DETAILS = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS';
private Security $security;
private VoterHelperInterface $voterHelper;
public function __construct(
Security $security,
VoterHelperFactoryInterface $voterHelperFactory
@@ -58,6 +70,21 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole
->build();
}
public function getRoles(): array
{
return self::ALL;
}
public function getRolesWithHierarchy(): array
{
return ['Accompanying period' => $this->getRoles()];
}
public function getRolesWithoutScope(): array
{
return [];
}
protected function supports($attribute, $subject)
{
return $this->voterHelper->supports($attribute, $subject);
@@ -71,7 +98,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole
if ($subject instanceof AccompanyingPeriod) {
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
if (\in_array($attribute, [self::EDIT, self::DELETE], true)) {
if (in_array($attribute, [self::EDIT, self::DELETE], true)) {
return false;
}
}
@@ -79,7 +106,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole
if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) {
// only creator can see, edit, delete, etc.
if ($subject->getCreatedBy() === $token->getUser()
|| NULL === $subject->getCreatedBy()) {
|| null === $subject->getCreatedBy()) {
return true;
}
@@ -94,19 +121,4 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole
return $this->voterHelper->voteOnAttribute($attribute, $subject, $token);
}
public function getRoles(): array
{
return self::ALL;
}
public function getRolesWithoutScope(): array
{
return [];
}
public function getRolesWithHierarchy(): array
{
return ['Accompanying period' => $this->getRoles()];
}
}

View File

@@ -1,8 +1,15 @@
<?php
/**
* 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\PersonBundle\Security\Authorization;
class HouseholdVoter
{
const SHOW = PersonVoter::SEE;
public const SHOW = PersonVoter::SEE;
}

View File

@@ -1,44 +1,35 @@
<?php
/*
* Copyright (C) 2015 Julien Fastré <julien.fastre@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\PersonBundle\Security\Authorization;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Entity\Center;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Role\Role;
class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
const CREATE = 'CHILL_PERSON_CREATE';
const UPDATE = 'CHILL_PERSON_UPDATE';
const SEE = 'CHILL_PERSON_SEE';
const STATS = 'CHILL_PERSON_STATS';
const LISTS = 'CHILL_PERSON_LISTS';
const DUPLICATE = 'CHILL_PERSON_DUPLICATE';
public const CREATE = 'CHILL_PERSON_CREATE';
public const DUPLICATE = 'CHILL_PERSON_DUPLICATE';
public const LISTS = 'CHILL_PERSON_LISTS';
public const SEE = 'CHILL_PERSON_SEE';
public const STATS = 'CHILL_PERSON_STATS';
public const UPDATE = 'CHILL_PERSON_UPDATE';
protected VoterHelperInterface $voter;
@@ -49,9 +40,23 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
->generate(self::class)
->addCheckFor(Center::class, [self::STATS, self::LISTS, self::DUPLICATE])
->addCheckFor(Person::class, [self::CREATE, self::UPDATE, self::SEE, self::DUPLICATE])
->addCheckFor(null, [self::CREATE] )
->build()
;
->addCheckFor(null, [self::CREATE])
->build();
}
public function getRoles(): array
{
return $this->getAttributes();
}
public function getRolesWithHierarchy(): array
{
return ['Person' => $this->getRoles()];
}
public function getRolesWithoutScope(): array
{
return $this->getAttributes();
}
protected function supports($attribute, $subject)
@@ -66,22 +71,6 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
private function getAttributes()
{
return array(self::CREATE, self::UPDATE, self::SEE, self::STATS, self::LISTS, self::DUPLICATE);
return [self::CREATE, self::UPDATE, self::SEE, self::STATS, self::LISTS, self::DUPLICATE];
}
public function getRoles(): array
{
return $this->getAttributes();
}
public function getRolesWithoutScope(): array
{
return $this->getAttributes();
}
public function getRolesWithHierarchy(): array
{
return ['Person' => $this->getRoles()];
}
}