refactor: Update source code based on PHP conventions.

This commit is contained in:
Pol Dellaiera
2021-04-26 15:45:05 +02:00
parent 6b2eda0f94
commit 054a28ecf4
766 changed files with 52425 additions and 53000 deletions

View File

@@ -1,58 +1,60 @@
<?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.
*
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class AccompanyingCourseMenuBuilder
*
* @package Chill\PersonBundle\Menu
* @author mathieu.jaumotte@champs-libres.coop
*/
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
{
/**
* @var TranslatorInterface
*/
protected $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
public static function getMenuIds(): array
{
return [ 'accompanyingCourse' ];
}
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
{
$menu->addChild($this->translator->trans('Resume Accompanying Course'), [
'route' => 'chill_person_accompanying_course_index',
'routeParameters' => [
'accompanying_period_id' => $parameters['accompanyingCourse']->getId()
]])
->setExtras(['order' => 10]);
'accompanying_period_id' => $parameters['accompanyingCourse']->getId(),
], ])
->setExtras(['order' => 10]);
$menu->addChild($this->translator->trans('Edit Accompanying Course'), [
'route' => 'chill_person_accompanying_course_show',
'routeParameters' => [
'accompanying_period_id' => $parameters['accompanyingCourse']->getId()
]])
->setExtras(['order' => 20]);
'accompanying_period_id' => $parameters['accompanyingCourse']->getId(),
], ])
->setExtras(['order' => 20]);
$menu->addChild($this->translator->trans('Accompanying Course Details'), [
'route' => 'chill_person_accompanying_course_history',
'routeParameters' => [
'accompanying_period_id' => $parameters['accompanyingCourse']->getId()
]])
->setExtras(['order' => 30]);
'accompanying_period_id' => $parameters['accompanyingCourse']->getId(),
], ])
->setExtras(['order' => 30]);
}
public static function getMenuIds(): array
{
return ['accompanyingCourse'];
}
}

View File

@@ -1,61 +1,50 @@
<?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.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* 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/>.
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
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,20 +1,16 @@
<?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.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* 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/>.
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
@@ -23,27 +19,24 @@ use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Add menu entrie to person menu.
*
*
* Menu entries added :
*
*
* - person details ;
* - accompanying period (if `visible`)
*
*/
class PersonMenuBuilder implements LocalMenuBuilderInterface
{
/**
*
* @var string 'visible' or 'hidden'
*/
protected $showAccompanyingPeriod;
/**
*
* @var TranslatorInterface
*/
protected $translator;
public function __construct(
$showAccompanyingPeriod,
TranslatorInterface $translator
@@ -51,44 +44,44 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
$this->showAccompanyingPeriod = $showAccompanyingPeriod;
$this->translator = $translator;
}
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('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' => 51
]);
if ($this->showAccompanyingPeriod === 'visible') {
->setExtras([
'order' => 51,
]);
if ('visible' === $this->showAccompanyingPeriod) {
$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,83 +1,63 @@
<?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.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* 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/>.
* @see https://www.champs-libres.coop/
*/
declare(strict_types=1);
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 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'],
]);
}
}
/**
* @return array
*/
public static function getMenuIds(): array
{
return [ 'section' ];
return ['section'];
}
}