rector rules for upgrade to php 8.2 and symfony 5.4 applied + php cs fixer

This commit is contained in:
2024-04-19 10:56:49 +02:00
parent 00756a3bde
commit 8e3322f578
70 changed files with 2026 additions and 2025 deletions

View File

@@ -1,15 +1,22 @@
<?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\ChillJobBundle\Controller;
use Chill\PersonBundle\CRUD\Controller\OneToOneEntityPersonCRUDController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Chill\ChillJobBundle\Form\CSPersonPersonalSituationType;
use Chill\ChillJobBundle\Form\CSPersonDispositifsType;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\HttpFoundation\Response;
class CSPersonController extends OneToOneEntityPersonCRUDController
@@ -21,7 +28,7 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
$request,
$id,
CSPersonPersonalSituationType::class
);
);
}
public function dispositifsEdit(Request $request, $id)
@@ -31,7 +38,7 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
$request,
$id,
CSPersonDispositifsType::class
);
);
}
public function personalSituationView(Request $request, $id): Response
@@ -46,7 +53,7 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
protected function generateRedirectOnCreateRoute($action, Request $request, $entity)
{
switch($action) {
switch ($action) {
case 'ps_situation_view':
$route = 'chill_crud_csperson_personal_situation_edit';
break;
@@ -62,36 +69,32 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
protected function checkACL($action, $entity)
{
switch($action) {
case 'ps_situation_edit':
case 'dispositifs_edit':
$this->denyAccessUnlessGranted(PersonVoter::UPDATE,
$entity->getPerson());
break;
case 'ps_situation_view':
case 'dispositifs_view':
$this->denyAccessUnlessGranted(PersonVoter::SEE,
$entity->getPerson());
break;
default:
parent::checkACL($action, $entity);
}
match ($action) {
'ps_situation_edit', 'dispositifs_edit' => $this->denyAccessUnlessGranted(
PersonVoter::UPDATE,
$entity->getPerson()
),
'ps_situation_view', 'dispositifs_view' => $this->denyAccessUnlessGranted(
PersonVoter::SEE,
$entity->getPerson()
),
default => parent::checkACL($action, $entity),
};
}
protected function onBeforeRedirectAfterSubmission(string $action, $entity, FormInterface $form, Request $request)
{
switch($action) {
case 'ps_situation_edit':
return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_personal_situation_view',
['id' => $entity->getId()]);
case 'dispositifs_edit':
return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_dispositifs_view',
['id' => $entity->getId()]);
default:
return null;
}
return match ($action) {
'ps_situation_edit' => $this->redirectToRoute(
'chill_crud_'.$this->getCrudName().'_personal_situation_view',
['id' => $entity->getId()]
),
'dispositifs_edit' => $this->redirectToRoute(
'chill_crud_'.$this->getCrudName().'_dispositifs_view',
['id' => $entity->getId()]
),
default => null,
};
}
protected function getTemplateFor($action, $entity, Request $request)
@@ -110,22 +113,26 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
}
}
protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface
protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface
{
switch ($action) {
case 'dispositifs_edit':
$form = $this->createForm($formClass, $entity, \array_merge(
$formOptions, [ 'center' => $entity->getPerson()->getCenter() ]));
$this->customizeForm($action, $form);
$form = $this->createForm($formClass, $entity, \array_merge(
$formOptions,
['center' => $entity->getPerson()->getCenter()]
));
$this->customizeForm($action, $form);
return $form;
return $form;
case 'ps_situation_edit':
$form = $this->createForm($formClass, $entity, \array_merge(
$formOptions, [ 'center' => $entity->getPerson()->getCenter() ]));
$this->customizeForm($action, $form);
$form = $this->createForm($formClass, $entity, \array_merge(
$formOptions,
['center' => $entity->getPerson()->getCenter()]
));
$this->customizeForm($action, $form);
return $form;
return $form;
default:
return parent::createFormFor($action, $entity, $formClass, $formOptions);
@@ -134,18 +141,16 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
protected function generateLabelForButton($action, $formName, $form)
{
switch($action):
switch ($action) {
case 'ps_situation_edit':
case 'dispositifs_edit':
if ($formName === 'submit') {
if ('submit' === $formName) {
return 'Enregistrer';
} else {
throw new \LogicException("this formName is not supported: $formName");
}
throw new \LogicException("this formName is not supported: {$formName}");
break;
default:
return parent::generateLabelForButton($action, $formName, $form);
endswitch;
}
}
}