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,5 +1,12 @@
<?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\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
@@ -9,19 +16,16 @@ use Symfony\Component\Workflow\Registry;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class AccompanyingCourseMenuBuilder
*
* @package Chill\PersonBundle\Menu
* @author mathieu.jaumotte@champs-libres.coop
* Class AccompanyingCourseMenuBuilder.
*/
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
{
protected Registry $registry;
/**
* @var TranslatorInterface
*/
protected $translator;
protected Registry $registry;
public function __construct(TranslatorInterface $translator, Registry $registry)
{
@@ -29,11 +33,6 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
$this->registry = $registry;
}
public static function getMenuIds(): array
{
return [ 'accompanyingCourse' ];
}
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
{
/** @var AccompanyingPeriod $period */
@@ -42,16 +41,16 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
$menu->addChild($this->translator->trans('Resume Accompanying Course'), [
'route' => 'chill_person_accompanying_course_index',
'routeParameters' => [
'accompanying_period_id' => $period->getId()
]])
->setExtras(['order' => 10]);
'accompanying_period_id' => $period->getId(),
], ])
->setExtras(['order' => 10]);
$menu->addChild($this->translator->trans('Edit Accompanying Course'), [
'route' => 'chill_person_accompanying_course_edit',
'routeParameters' => [
'accompanying_period_id' => $period->getId()
]])
->setExtras(['order' => 20]);
'accompanying_period_id' => $period->getId(),
], ])
->setExtras(['order' => 20]);
if (AccompanyingPeriod::STEP_DRAFT === $period->getStep()) {
// no more menu items if the period is draft
@@ -61,16 +60,16 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
$menu->addChild($this->translator->trans('Accompanying Course History'), [
'route' => 'chill_person_accompanying_course_history',
'routeParameters' => [
'accompanying_period_id' => $period->getId()
]])
->setExtras(['order' => 30]);
'accompanying_period_id' => $period->getId(),
], ])
->setExtras(['order' => 30]);
$menu->addChild($this->translator->trans('Accompanying Course Action'), [
'route' => 'chill_person_accompanying_period_work_list',
'routeParameters' => [
'id' => $period->getId()
]])
->setExtras(['order' => 40]);
'id' => $period->getId(),
], ])
->setExtras(['order' => 40]);
$workflow = $this->registry->get($period, 'accompanying_period_lifecycle');
@@ -78,11 +77,14 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
$menu->addChild($this->translator->trans('Close Accompanying Course'), [
'route' => 'chill_person_accompanying_course_close',
'routeParameters' => [
'accompanying_period_id' => $period->getId()
]])
'accompanying_period_id' => $period->getId(),
], ])
->setExtras(['order' => 99999]);
}
}
public static function getMenuIds(): array
{
return ['accompanyingCourse'];
}
}

View File

@@ -1,61 +1,46 @@
<?php
/*
* Copyright (C) 2018 Champs-Libres <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\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
/**
*
*
*/
class AdminMenuBuilder implements LocalMenuBuilderInterface
{
/**
*
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
{
$this->authorizationChecker = $authorizationChecker;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
return;
}
$menu->addChild('Person', [
'route' => 'chill_person_admin'
])
'route' => 'chill_person_admin',
])
->setExtras([
'order' => 20
'order' => 20,
]);
}
public static function getMenuIds(): array
{
return [ 'admin_section' ];
return ['admin_section'];
}
}

View File

@@ -1,15 +1,20 @@
<?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\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\PersonBundle\Entity\Household\Household;
use Knp\Menu\MenuItem;
use Symfony\Contracts\Translation\TranslatorInterface;
class HouseholdMenuBuilder implements LocalMenuBuilderInterface
{
/**
* @var TranslatorInterface
*/
@@ -20,11 +25,6 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
$this->translator = $translator;
}
public static function getMenuIds(): array
{
return [ 'household' ];
}
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
{
$household = $parameters['household'];
@@ -32,32 +32,34 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
$menu->addChild($this->translator->trans('household.Household summary'), [
'route' => 'chill_person_household_summary',
'routeParameters' => [
'household_id' => $household->getId()
]])
->setExtras(['order' => 10]);
'household_id' => $household->getId(),
], ])
->setExtras(['order' => 10]);
$menu->addChild($this->translator->trans('household.Accompanying period'), [
'route' => 'chill_person_household_accompanying_period',
'routeParameters' => [
'household_id' => $household->getId()
]])
->setExtras(['order' => 20]);
'household_id' => $household->getId(),
], ])
->setExtras(['order' => 20]);
$menu->addChild($this->translator->trans('household.Addresses'), [
'route' => 'chill_person_household_addresses',
'routeParameters' => [
'household_id' => $household->getId()
]])
->setExtras(['order' => 30]);
'household_id' => $household->getId(),
], ])
->setExtras(['order' => 30]);
$menu->addChild($this->translator->trans('household.Relationship'), [
'route' => 'chill_person_household_relationship',
'routeParameters' => [
'household_id' => $household->getId()
]])
'household_id' => $household->getId(),
], ])
->setExtras(['order' => 40]);
}
public static function getMenuIds(): array
{
return ['household'];
}
}

View File

@@ -1,20 +1,12 @@
<?php
/*
* Copyright (C) 2018 Champs-Libres <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\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
@@ -31,18 +23,15 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*
* - person details ;
* - accompanying period (if `visible`)
*
*/
class PersonMenuBuilder implements LocalMenuBuilderInterface
{
/**
*
* @var string 'visible' or 'hidden'
*/
protected $showAccompanyingPeriod;
/**
*
* @var TranslatorInterface
*/
protected $translator;
@@ -62,52 +51,52 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
$menu->addChild($this->translator->trans('Person details'), [
'route' => 'chill_person_view',
'routeParameters' => [
'person_id' => $parameters['person']->getId()
]
])
'route' => 'chill_person_view',
'routeParameters' => [
'person_id' => $parameters['person']->getId(),
],
])
->setExtras([
'order' => 50
'order' => 50,
]);
$menu->addChild($this->translator->trans('household.person history'), [
'route' => 'chill_person_household_person_history',
'routeParameters' => [
'person_id' => $parameters['person']->getId()
]
'route' => 'chill_person_household_person_history',
'routeParameters' => [
'person_id' => $parameters['person']->getId(),
],
])
->setExtras([
'order' => 99999
]);
->setExtras([
'order' => 99999,
]);
$menu->addChild($this->translator->trans('Person duplicate'), [
'route' => 'chill_person_duplicate_view',
'routeParameters' => [
'person_id' => $parameters['person']->getId()
]
'route' => 'chill_person_duplicate_view',
'routeParameters' => [
'person_id' => $parameters['person']->getId(),
],
])
->setExtras([
'order' => 99999
]);
->setExtras([
'order' => 99999,
]);
if ($this->showAccompanyingPeriod === 'visible'
if ('visible' === $this->showAccompanyingPeriod
&& $this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['person'])
) {
$menu->addChild($this->translator->trans('Accompanying period list'), [
'route' => 'chill_person_accompanying_period_list',
'routeParameters' => [
'person_id' => $parameters['person']->getId()
]
])
'route' => 'chill_person_accompanying_period_list',
'routeParameters' => [
'person_id' => $parameters['person']->getId(),
],
])
->setExtras([
'order' => 100
'order' => 100,
]);
}
}
public static function getMenuIds(): array
{
return [ 'person' ];
return ['person'];
}
}

View File

@@ -1,35 +1,22 @@
<?php
/*
* Copyright (C) 2018 Champs-Libres <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\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Translation\TranslatorInterface;
/**
* Class SectionMenuBuilder
*
* @package Chill\PersonBundle\Menu
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* Class SectionMenuBuilder.
*/
class SectionMenuBuilder implements LocalMenuBuilderInterface
{
@@ -37,55 +24,47 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
/**
* @var TranslatorInterface
*/
protected $translator;
/**
* SectionMenuBuilder constructor.
*
* @param AuthorizationCheckerInterface $authorizationChecker
* @param TranslatorInterface $translator
*/
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator)
{
$this->authorizationChecker = $authorizationChecker;
$this->translator = $translator;
}
/**
* @param $menuId
* @param MenuItem $menu
* @param array $parameters
*/
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
if ($this->authorizationChecker->isGranted(PersonVoter::CREATE)) {
$menu->addChild($this->translator->trans('Add a person'), [
'route' => 'chill_person_new'
])
'route' => 'chill_person_new',
])
->setExtras([
'order' => 10,
'icons' => [ 'plus' ]
'icons' => ['plus'],
]);
}
$menu->addChild($this->translator->trans('Create an accompanying course'), [
'route' => 'chill_person_accompanying_course_new'
])
'route' => 'chill_person_accompanying_course_new',
])
->setExtras([
'order' => 11,
'icons' => [ 'plus' ]
'icons' => ['plus'],
]);
}
/**
* @return array
*/
public static function getMenuIds(): array
{
return [ 'section' ];
return ['section'];
}
}