mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 23:04:58 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -14,11 +14,8 @@ namespace Chill\PersonBundle\CRUD\Controller;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Exception;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use function array_merge;
|
||||
|
||||
/**
|
||||
* Class EntityPersonCRUDController
|
||||
@@ -68,25 +65,21 @@ class EntityPersonCRUDController extends CRUDController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $entity
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = []): array
|
||||
{
|
||||
$person = $this->getPerson($request);
|
||||
|
||||
if (null === $person) {
|
||||
throw new Exception('the `person_id` parameter is not set in the query. '
|
||||
. 'You should set it or override the current method to allow another '
|
||||
. 'behaviour: ' . __METHOD__);
|
||||
throw new \Exception('the `person_id` parameter is not set in the query. You should set it or override the current method to allow another behaviour: '.__METHOD__);
|
||||
}
|
||||
|
||||
return parent::generateTemplateParameter(
|
||||
$action,
|
||||
$entity,
|
||||
$request,
|
||||
array_merge(['person' => $person], $defaultTemplateParameters)
|
||||
\array_merge(['person' => $person], $defaultTemplateParameters)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,7 +115,6 @@ class EntityPersonCRUDController extends CRUDController
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
* @param mixed $entity
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -142,25 +134,22 @@ class EntityPersonCRUDController extends CRUDController
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $entity
|
||||
*/
|
||||
protected function onBeforeRedirectAfterSubmission(string $action, $entity, \Symfony\Component\Form\FormInterface $form, Request $request): ?Response
|
||||
{
|
||||
$next = $request->request->get('submit', 'save-and-close');
|
||||
|
||||
return match ($next) {
|
||||
'save-and-close' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_index', [
|
||||
'save-and-close' => $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_index', [
|
||||
'person_id' => $this->getPerson($request)->getId(),
|
||||
]),
|
||||
'save-and-new' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_new', [
|
||||
'save-and-new' => $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_new', [
|
||||
'person_id' => $this->getPerson($request)->getId(),
|
||||
]),
|
||||
'new' => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [
|
||||
'new' => $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', [
|
||||
'id' => $entity->getId(),
|
||||
'person_id' => $this->getPerson($request)->getId(),
|
||||
]),
|
||||
default => $this->redirectToRoute('chill_crud_' . $this->getCrudName() . '_view', [
|
||||
default => $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', [
|
||||
'id' => $entity->getId(),
|
||||
'person_id' => $this->getPerson($request)->getId(),
|
||||
]),
|
||||
|
@@ -11,10 +11,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\CRUD\Controller;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -24,7 +22,7 @@ class OneToOneEntityPersonCRUDController extends CRUDController
|
||||
{
|
||||
protected function generateRedirectOnCreateRoute($action, Request $request, $entity): string
|
||||
{
|
||||
throw new BadMethodCallException('Not implemented yet.');
|
||||
throw new \BadMethodCallException('Not implemented yet.');
|
||||
}
|
||||
|
||||
protected function getEntity($action, $id, Request $request): ?object
|
||||
@@ -54,9 +52,7 @@ class OneToOneEntityPersonCRUDController extends CRUDController
|
||||
'new' => '@ChillPerson/CRUD/new.html.twig',
|
||||
'edit' => '@ChillPerson/CRUD/edit.html.twig',
|
||||
'index' => '@ChillPerson/CRUD/index.html.twig',
|
||||
default => throw new LogicException("the view for action {$action} is not "
|
||||
. 'defined. You should override ' . __METHOD__ . ' to add this '
|
||||
. 'action'),
|
||||
default => throw new \LogicException("the view for action {$action} is not ".'defined. You should override '.__METHOD__.' to add this action'),
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user