Fix crudconfig

This commit is contained in:
Julie Lenaerts 2024-04-24 11:44:14 +02:00
parent 56d5d08ed3
commit 650e85c481
2 changed files with 10 additions and 17 deletions

View File

@ -22,7 +22,7 @@ use Symfony\Component\Routing\Annotation\Route;
class CSPersonController extends OneToOneEntityPersonCRUDController class CSPersonController extends OneToOneEntityPersonCRUDController
{ {
public function personalSituationEdit(Request $request, $id) public function personalSituationEdit(Request $request, $id): Response
{ {
return $this->formEditAction( return $this->formEditAction(
'ps_situation_edit', 'ps_situation_edit',
@ -72,7 +72,7 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
return $this->generateUrl($route, ['id' => $entity->getPerson()->getId()]); return $this->generateUrl($route, ['id' => $entity->getPerson()->getId()]);
} }
protected function checkACL($action, $entity) protected function checkACL($action, $entity): void
{ {
match ($action) { match ($action) {
'ps_situation_edit', 'dispositifs_edit' => $this->denyAccessUnlessGranted( 'ps_situation_edit', 'dispositifs_edit' => $this->denyAccessUnlessGranted(
@ -116,16 +116,8 @@ 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) { switch ($action) {
case 'dispositifs_edit':
$form = $this->createForm($formClass, $entity, \array_merge(
$formOptions,
['center' => $entity->getPerson()->getCenter()]
));
$this->customizeForm($action, $form);
return $form;
case 'ps_situation_edit': case 'ps_situation_edit':
case 'dispositifs_edit':
$form = $this->createForm($formClass, $entity, \array_merge( $form = $this->createForm($formClass, $entity, \array_merge(
$formOptions, $formOptions,
['center' => $entity->getPerson()->getCenter()] ['center' => $entity->getPerson()->getCenter()]
@ -139,7 +131,7 @@ class CSPersonController extends OneToOneEntityPersonCRUDController
} }
} }
protected function generateLabelForButton($action, $formName, $form) protected function generateLabelForButton($action, $formName, $form): string
{ {
switch ($action) { switch ($action) {
case 'ps_situation_edit': case 'ps_situation_edit':

View File

@ -48,9 +48,10 @@ class ChillJobExtension extends Extension implements PrependExtensionInterface
public function prepend(ContainerBuilder $container): void public function prepend(ContainerBuilder $container): void
{ {
$this->prependRoute($container); $this->prependRoute($container);
$this->prependCruds($container);
} }
/* protected function prependCruds(ContainerBuilder $container) protected function prependCruds(ContainerBuilder $container)
{ {
$container->prependExtensionConfig('chill_main', [ $container->prependExtensionConfig('chill_main', [
'cruds' => [ 'cruds' => [
@ -58,9 +59,9 @@ class ChillJobExtension extends Extension implements PrependExtensionInterface
'class' => CSPerson::class, 'class' => CSPerson::class,
'controller' => CSPersonController::class, 'controller' => CSPersonController::class,
'name' => 'admin_personal_situation', 'name' => 'admin_personal_situation',
// 'base_path' => '/admin/main/personal_situation',
'base_role' => 'ROLE_USER', 'base_role' => 'ROLE_USER',
'form_class' => CSPersonPersonalSituationType::class, 'base_path' => '/person/job/',
/* 'form_class' => CSPersonPersonalSituationType::class,
'actions' => [ 'actions' => [
'index' => [ 'index' => [
'role' => 'ROLE_USER', 'role' => 'ROLE_USER',
@ -74,11 +75,11 @@ class ChillJobExtension extends Extension implements PrependExtensionInterface
'role' => 'ROLE_USER', 'role' => 'ROLE_USER',
'template' => '@ChillPerson/CRUD/edit.html.twig', 'template' => '@ChillPerson/CRUD/edit.html.twig',
], ],
], ],*/
] ]
], ],
]); ]);
}*/ }
protected function prependRoute(ContainerBuilder $container): void protected function prependRoute(ContainerBuilder $container): void
{ {