diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 8338af8c6..25b7e5860 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -43,16 +43,16 @@ use Symfony\Component\Serializer\SerializerInterface; */ class CRUDController extends AbstractController { - + /** - * The crud configuration + * The crud configuration * * This configuration si defined by `chill_main['crud']`. * * @var array */ protected $crudConfig; - + /** * @param array $config */ @@ -60,7 +60,7 @@ class CRUDController extends AbstractController { $this->crudConfig = $config; } - + /** * @param $parameter * @return Response @@ -69,7 +69,7 @@ class CRUDController extends AbstractController { return new Response($parameter); } - + /** * @param Request $request * @param $id @@ -79,7 +79,7 @@ class CRUDController extends AbstractController { return $this->deleteAction('delete', $request, $id); } - + /** * @param string $action * @param Request $request @@ -90,78 +90,78 @@ class CRUDController extends AbstractController protected function deleteAction(string $action, Request $request, $id, $formClass = null) { $this->onPreDelete($action, $request, $id); - + $entity = $this->getEntity($action, $id, $request); - + $postFetch = $this->onPostFetchEntity($action, $request, $entity); - + if ($postFetch instanceof Response) { return $postFetch; } - + if (NULL === $entity) { throw $this->createNotFoundException(sprintf("The %s with id %s " . "is not found"), $this->getCrudName(), $id); } - + $response = $this->checkACL($action, $entity); if ($response instanceof Response) { return $response; } - + $response = $this->onPostCheckACL($action, $request, $entity); if ($response instanceof Response) { return $response; } - + $form = $this->createFormFor($action, $entity, $formClass); - + $form->handleRequest($request); - + if ($form->isSubmitted() && $form->isValid()) { $this->onFormValid($entity, $form, $request); $em = $this->getDoctrine()->getManager(); - + $this->onPreRemove($action, $entity, $form, $request); $this->removeEntity($action, $entity, $form, $request); $this->onPostRemove($action, $entity, $form, $request); - + $this->onPreFlush($action, $entity, $form, $request); $em->flush(); $this->onPostFlush($action, $entity, $form, $request); - + $this->addFlash('success', $this->generateFormSuccessMessage($action, $entity)); - + $result = $this->onBeforeRedirectAfterSubmission($action, $entity, $form, $request); - + if ($result instanceof Response) { return $result; } - + return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', ['id' => $entity->getId()]); - + } elseif ($form->isSubmitted()) { $this->addFlash('error', $this->generateFormErrorMessage($action, $form)); } - + $defaultTemplateParameters = [ 'form' => $form->createView(), 'entity' => $entity, 'crud_name' => $this->getCrudName() ]; - + return $this->render( - $this->getTemplateFor($action, $entity, $request), + $this->getTemplateFor($action, $entity, $request), $this->generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters) ); } - + /** * @param string $action * @param Request $request */ protected function onPreDelete(string $action, Request $request) {} - + /** * @param string $action * @param $entity @@ -169,7 +169,7 @@ class CRUDController extends AbstractController * @param Request $request */ protected function onPreRemove(string $action, $entity, FormInterface $form, Request $request) {} - + /** * @param string $action * @param $entity @@ -177,7 +177,7 @@ class CRUDController extends AbstractController * @param Request $request */ protected function onPostRemove(string $action, $entity, FormInterface $form, Request $request) {} - + /** * @param string $action * @param $entity @@ -190,10 +190,10 @@ class CRUDController extends AbstractController ->getManager() ->remove($entity); } - + /** * Base method called by index action. - * + * * @param Request $request * @return type */ @@ -201,14 +201,14 @@ class CRUDController extends AbstractController { return $this->indexEntityAction('index', $request); } - + /** * Build an index page. - * + * * Some steps may be overriden during this process of rendering. - * + * * This method: - * + * * 1. Launch `onPreIndex` * x. check acl. If it does return a response instance, return it * x. launch `onPostCheckACL`. If it does return a response instance, return it @@ -219,15 +219,15 @@ class CRUDController extends AbstractController * x. fetch the results, using `getQueryResult` * x. Launch `onPostIndexFetchQuery`. If it does return a response instance, return it * 4. create default parameters: - * - * The default parameters are: - * + * + * The default parameters are: + * * * entities: the list en entities ; * * crud_name: the name of the crud ; * * paginator: a paginator element ; - * 5. Launch rendering, the parameter is fetch using `getTemplateFor` + * 5. Launch rendering, the parameter is fetch using `getTemplateFor` * The parameters may be personnalized using `generateTemplateParameter`. - * + * * @param string $action * @param Request $request * @return type @@ -235,80 +235,80 @@ class CRUDController extends AbstractController protected function indexEntityAction($action, Request $request) { $this->onPreIndex($action, $request); - + $response = $this->checkACL($action, null); if ($response instanceof Response) { return $response; } - + if (!isset($entity)) { $entity = ''; } - + $response = $this->onPostCheckACL($action, $request, $entity); if ($response instanceof Response) { return $response; } - + $totalItems = $this->countEntities($action, $request); $paginator = $this->getPaginatorFactory()->create($totalItems); - - $response = $this->onPreIndexBuildQuery($action, $request, $totalItems, + + $response = $this->onPreIndexBuildQuery($action, $request, $totalItems, $paginator); - + if ($response instanceof Response) { return $response; } - + $query = $this->queryEntities($action, $request, $paginator); - - $response = $this->onPostIndexBuildQuery($action, $request, $totalItems, + + $response = $this->onPostIndexBuildQuery($action, $request, $totalItems, $paginator, $query); - + if ($response instanceof Response) { return $response; } - + $entities = $this->getQueryResult($action, $request, $totalItems, $paginator, $query); - - $response = $this->onPostIndexFetchQuery($action, $request, $totalItems, + + $response = $this->onPostIndexFetchQuery($action, $request, $totalItems, $paginator, $entities); - + if ($response instanceof Response) { return $response; } - + $defaultTemplateParameters = [ 'entities' => $entities, 'crud_name' => $this->getCrudName(), 'paginator' => $paginator ]; - + return $this->render( - $this->getTemplateFor($action, $entities, $request), + $this->getTemplateFor($action, $entities, $request), $this->generateTemplateParameter($action, $entities, $request, $defaultTemplateParameters) ); } - + /** * @param string $action * @param Request $request */ protected function onPreIndex(string $action, Request $request) { } - + /** * method used by indexAction - * + * * @param string $action * @param Request $request * @param int $totalItems * @param PaginatorInterface $paginator */ protected function onPreIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator) { } - + /** * method used by indexAction - * + * * @param string $action * @param Request $request * @param int $totalItems @@ -316,10 +316,10 @@ class CRUDController extends AbstractController * @param mixed $query */ protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $query) { } - + /** * method used by indexAction - * + * * @param string $action * @param Request $request * @param int $totalItems @@ -327,14 +327,14 @@ class CRUDController extends AbstractController * @param mixed $entities */ protected function onPostIndexFetchQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $entities) { } - + /** * Build the base query for listing all entities, normally use in a listing * page. - * + * * This base query does not contains any `WHERE` or `SELECT` clauses. Those * are added by other methods, like `queryEntities` and `countQueries`. - * + * * @param string $action * @param Request $request * @return QueryBuilder @@ -347,16 +347,16 @@ class CRUDController extends AbstractController ->from($this->getEntityClass(), 'e') ; } - + /** * Query the entity. - * + * * By default, get all entities. - * + * * The method `orderEntity` is called internally to order entities. - * + * * It returns, by default, a query builder. - * + * * @param string $action * @param Request $request * @param PaginatorInterface $paginator @@ -367,15 +367,15 @@ class CRUDController extends AbstractController $query = $this->buildQueryEntities($action, $request) ->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber()) ->setMaxResults($paginator->getItemsPerPage()); - + // allow to order queries and return the new query return $this->orderQuery($action, $query, $request, $paginator); } - - + + /** * Add ordering fields in the query build by self::queryEntities - * + * * @param string $action * @param QueryBuilder|mixed $query by default, an instance of QueryBuilder * @param Request $request @@ -386,10 +386,10 @@ class CRUDController extends AbstractController { return $query; } - + /** * Get the result of the query - * + * * @param string $action * @param Request $request * @param int $totalItems @@ -397,14 +397,14 @@ class CRUDController extends AbstractController * @param mixed $query * @return mixed */ - protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $query) + protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $query) { return $query->getQuery()->getResult(); } - + /** * Count the number of entities - * + * * @param string $action * @param Request $request * @return int @@ -417,12 +417,12 @@ class CRUDController extends AbstractController ->getSingleScalarResult() ; } - + /** * BAse method for edit action - * + * * IMplemented by the method formEditAction, with action as 'edit' - * + * * @param Request $request * @param mixed $id * @return Response @@ -431,12 +431,12 @@ class CRUDController extends AbstractController { return $this->formEditAction('edit', $request, $id); } - + /** * Base method for new action - * + * * Implemented by the method formNewAction, with action as 'new' - * + * * @param Request $request * @return Response */ @@ -444,12 +444,12 @@ class CRUDController extends AbstractController { return $this->formCreateAction('new', $request); } - + /** * Base method for the view action. - * + * * Implemented by the method viewAction, with action as 'view' - * + * * @param Request $request * @param mixed $id * @return Response @@ -458,28 +458,28 @@ class CRUDController extends AbstractController { return $this->viewAction('view', $request, $id); } - + /** * The view action. - * + * * Some steps may be overriden during this process of rendering: - * + * * This method: - * + * * 1. fetch the entity, using `getEntity` * 2. launch `onPostFetchEntity`. If postfetch is an instance of Response, * this response is returned. * 2. throw an HttpNotFoundException if entity is null * 3. check ACL using `checkACL` ; - * 4. launch `onPostCheckACL`. If the result is an instance of Response, + * 4. launch `onPostCheckACL`. If the result is an instance of Response, * this response is returned ; * 5. generate default template parameters: - * + * * * `entity`: the fetched entity ; * * `crud_name`: the crud name - * 6. Launch rendering, the parameter is fetch using `getTemplateFor` + * 6. Launch rendering, the parameter is fetch using `getTemplateFor` * The parameters may be personnalized using `generateTemplateParameter`. - * + * * @param string $action * @param Request $request * @param mixed $id @@ -488,23 +488,23 @@ class CRUDController extends AbstractController protected function viewAction(string $action, Request $request, $id, $_format = 'html'): Response { $entity = $this->getEntity($action, $id, $request); - + $postFetch = $this->onPostFetchEntity($action, $request, $entity); - + if ($postFetch instanceof Response) { return $postFetch; } - + if (NULL === $entity) { throw $this->createNotFoundException(sprintf("The %s with id %s " . "is not found", $this->getCrudName(), $id)); } - + $response = $this->checkACL($action, $entity); if ($response instanceof Response) { return $response; } - + $response = $this->onPostCheckACL($action, $request, $entity); if ($response instanceof Response) { return $response; @@ -515,9 +515,9 @@ class CRUDController extends AbstractController 'entity' => $entity, 'crud_name' => $this->getCrudName() ]; - + return $this->render( - $this->getTemplateFor($action, $entity, $request), + $this->getTemplateFor($action, $entity, $request), $this->generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters) ); } elseif ($_format === 'json') { @@ -537,45 +537,45 @@ class CRUDController extends AbstractController { return []; } - - + + /** * The edit action. - * + * * Some steps may be overriden during this process of rendering: - * + * * This method: - * + * * 1. fetch the entity, using `getEntity` * 2. launch `onPostFetchEntity`. If postfetch is an instance of Response, * this response is returned. * 2. throw an HttpNotFoundException if entity is null * 3. check ACL using `checkACL` ; - * 4. launch `onPostCheckACL`. If the result is an instance of Response, + * 4. launch `onPostCheckACL`. If the result is an instance of Response, * this response is returned ; * 5. generate a form using `createFormFor`, and handle request on this form; - * + * * If the form is valid, the entity is stored and flushed, and a redirection * is returned. - * + * * In this case, those hooks are available: - * + * * * onFormValid * * onPreFlush * * onPostFlush - * * onBeforeRedirectAfterSubmission. If this method return an instance of + * * onBeforeRedirectAfterSubmission. If this method return an instance of * Response, this response is returned. - * + * * 5. generate default template parameters: - * + * * * `entity`: the fetched entity ; * * `crud_name`: the crud name ; * * `form`: the formview instance. - * - * 6. Launch rendering, the parameter is fetch using `getTemplateFor` + * + * 6. Launch rendering, the parameter is fetch using `getTemplateFor` * The parameters may be personnalized using `generateTemplateParameter`. - * + * * @param string $action * @param Request $request * @param mixed $id @@ -587,98 +587,98 @@ class CRUDController extends AbstractController protected function formEditAction(string $action, Request $request, $id, string $formClass = null, array $formOptions = []): Response { $entity = $this->getEntity($action, $id, $request); - + if (NULL === $entity) { throw $this->createNotFoundException(sprintf("The %s with id %s " - . "is not found"), $this->getCrudName(), $id); + . "is not found", $this->getCrudName(), $id)); } - + $response = $this->checkACL($action, $entity); if ($response instanceof Response) { return $response; } - + $response = $this->onPostCheckACL($action, $request, $entity); if ($response instanceof Response) { return $response; } - + $form = $this->createFormFor($action, $entity, $formClass, $formOptions); - + $form->handleRequest($request); - + if ($form->isSubmitted() && $form->isValid()) { $this->onFormValid($entity, $form, $request); $em = $this->getDoctrine()->getManager(); - + $this->onPreFlush($action, $entity, $form, $request); $em->flush(); $this->onPostFlush($action, $entity, $form, $request); - + $this->addFlash('success', $this->generateFormSuccessMessage($action, $entity)); - + $result = $this->onBeforeRedirectAfterSubmission($action, $entity, $form, $request); - + if ($result instanceof Response) { return $result; } - + return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_index'); - + } elseif ($form->isSubmitted()) { $this->addFlash('error', $this->generateFormErrorMessage($action, $form)); } - + $defaultTemplateParameters = [ 'form' => $form->createView(), 'entity' => $entity, 'crud_name' => $this->getCrudName() ]; - + return $this->render( - $this->getTemplateFor($action, $entity, $request), + $this->getTemplateFor($action, $entity, $request), $this->generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters) ); } - + /** * The new (or creation) action. - * + * * Some steps may be overriden during this process of rendering: - * + * * This method: - * + * * 1. Create or duplicate an entity: - * - * If the `duplicate` parameter is present, the entity is duplicated + * + * If the `duplicate` parameter is present, the entity is duplicated * using the `duplicate` method. - * + * * If not, the entity is created using the `create` method. * 3. check ACL using `checkACL` ; - * 4. launch `onPostCheckACL`. If the result is an instance of Response, + * 4. launch `onPostCheckACL`. If the result is an instance of Response, * this response is returned ; * 5. generate a form using `createFormFor`, and handle request on this form; - * + * * If the form is valid, the entity is stored and flushed, and a redirection * is returned. - * + * * In this case, those hooks are available: - * + * * * onFormValid * * onPreFlush * * onPostFlush - * * onBeforeRedirectAfterSubmission. If this method return an instance of + * * onBeforeRedirectAfterSubmission. If this method return an instance of * Response, this response is returned. - * + * * 5. generate default template parameters: - * + * * * `entity`: the fetched entity ; * * `crud_name`: the crud name ; * * `form`: the formview instance. - * - * 6. Launch rendering, the parameter is fetch using `getTemplateFor` + * + * 6. Launch rendering, the parameter is fetch using `getTemplateFor` * The parameters may be personnalized using `generateTemplateParameter`. - * + * * @param string $action * @param Request $request * @param type $formClass @@ -691,62 +691,62 @@ class CRUDController extends AbstractController } else { $entity = $this->createEntity($action, $request); } - + $response = $this->checkACL($action, $entity); if ($response instanceof Response) { return $response; } - + $response = $this->onPostCheckACL($action, $request, $entity); if ($response instanceof Response) { return $response; } - + $form = $this->createFormFor($action, $entity, $formClass); - + $form->handleRequest($request); - + if ($form->isSubmitted() && $form->isValid()) { $this->onFormValid($entity, $form, $request); $em = $this->getDoctrine()->getManager(); - + $this->onPrePersist($action, $entity, $form, $request); $em->persist($entity); $this->onPostPersist($action, $entity, $form, $request); - + $this->onPreFlush($action, $entity, $form, $request); $em->flush(); $this->onPostFlush($action, $entity, $form, $request); $this->getPaginatorFactory(); $this->addFlash('success', $this->generateFormSuccessMessage($action, $entity)); - + $result = $this->onBeforeRedirectAfterSubmission($action, $entity, $form, $request); - + if ($result instanceof Response) { return $result; } - + return $this->redirectToRoute('chill_crud_'.$this->getCrudName().'_view', ['id' => $entity->getId()]); - + } elseif ($form->isSubmitted()) { $this->addFlash('error', $this->generateFormErrorMessage($action, $form)); } - + $defaultTemplateParameters = [ 'form' => $form->createView(), 'entity' => $entity, 'crud_name' => $this->getCrudName() ]; - + return $this->render( - $this->getTemplateFor($action, $entity, $request), + $this->getTemplateFor($action, $entity, $request), $this->generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters) ); } - + /** * get the instance of the entity with the given id - * + * * @param string $id * @return object */ @@ -756,10 +756,10 @@ class CRUDController extends AbstractController ->getRepository($this->getEntityClass()) ->find($id); } - + /** * Duplicate an entity - * + * * @param string $action * @param Request $request * @return mixed @@ -768,24 +768,24 @@ class CRUDController extends AbstractController { $id = $request->query->get('duplicate_id', 0); $originalEntity = $this->getEntity($action, $id, $request); - + $this->getDoctrine()->getManager() ->detach($originalEntity); - + return $originalEntity; } - + /** - * + * * @return string the complete fqdn of the class */ protected function getEntityClass(): string { return $this->crudConfig['class']; } - + /** - * + * * @return string the crud name */ protected function getCrudName(): string @@ -795,13 +795,13 @@ class CRUDController extends AbstractController /** * check the acl. Called by every action. - * - * By default, check the role given by `getRoleFor` for the value given in + * + * By default, check the role given by `getRoleFor` for the value given in * $entity. - * + * * Throw an \Symfony\Component\Security\Core\Exception\AccessDeniedHttpException * if not accessible. - * + * * @param string $action * @param mixed $entity * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedHttpException @@ -810,10 +810,10 @@ class CRUDController extends AbstractController { $this->denyAccessUnlessGranted($this->getRoleFor($action), $entity); } - + /** * get the role given from the config. - * + * * @param string $action * @return string */ @@ -822,27 +822,27 @@ class CRUDController extends AbstractController if (\array_key_exists('role', $this->getActionConfig($action))) { return $this->getActionConfig($action)['role']; } - + return $this->buildDefaultRole($action); } /** * build a default role name, using the crud resolver. - * + * * This method should not be overriden. Override `getRoleFor` instead. - * + * * @param string $action * @return string */ protected function buildDefaultRole($action) { - return $this->getCrudResolver()->buildDefaultRole($this->getCrudName(), + return $this->getCrudResolver()->buildDefaultRole($this->getCrudName(), $action); } - + /** * get the default form class from config - * + * * @param string $action * @return string the FQDN of the form class */ @@ -852,27 +852,27 @@ class CRUDController extends AbstractController return $this->crudConfig[$action]['form_class'] ?? $this->getDefaultDeleteFormClass($action); } - + return $this->crudConfig[$action]['form_class'] ?? $this->crudConfig['form_class']; } - + protected function getDefaultDeleteFormClass($action) { return CRUDDeleteEntityForm::class; } - + /** * Create a form - * + * * use the method `getFormClassFor` - * + * * A hook is available: `customizeForm` allow you to customize the form * if needed. - * + * * It is preferable to override customizeForm instead of overriding * this method. - * + * * @param string $action * @param mixed $entity * @param string $formClass @@ -882,17 +882,17 @@ class CRUDController extends AbstractController protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface { $formClass = $formClass ?? $this->getFormClassFor($action); - + $form = $this->createForm($formClass, $entity, $formOptions); - + $this->customizeForm($action, $form); - + return $form; } - + /** * Customize the form created by createFormFor. - * + * * @param string $action * @param FormInterface $form */ @@ -900,12 +900,12 @@ class CRUDController extends AbstractController { } - + /** * Generate a message which explains an error about the form. - * + * * Used in form actions - * + * * @param string $action * @param FormInterface $form * @return string @@ -913,13 +913,13 @@ class CRUDController extends AbstractController protected function generateFormErrorMessage(string $action, FormInterface $form): string { $msg = 'This form contains errors'; - + return $this->getTranslator()->trans($msg); } - + /** * Generate a success message when a form could be flushed successfully - * + * * @param string $action * @param mixed $entity * @return string @@ -939,13 +939,13 @@ class CRUDController extends AbstractController default: $msg = "crud.default.success"; } - + return $this->getTranslator()->trans($msg); } - + /** * Customize template parameters. - * + * * @param string $action * @param mixed $entity * @param Request $request @@ -953,9 +953,9 @@ class CRUDController extends AbstractController * @return array */ protected function generateTemplateParameter( - string $action, - $entity, - Request $request, + string $action, + $entity, + Request $request, array $defaultTemplateParameters = [] ) { return $defaultTemplateParameters; @@ -963,7 +963,7 @@ class CRUDController extends AbstractController /** * Create an entity. - * + * * @param string $action * @param Request $request * @return object @@ -971,17 +971,17 @@ class CRUDController extends AbstractController protected function createEntity(string $action, Request $request): object { $type = $this->getEntityClass(); - + return new $type; } - + /** * Get the template for the current crud. - * - * This template may be defined in configuration. If any template are - * defined, return the default template for the actions new, edit, index, + * + * This template may be defined in configuration. If any template are + * defined, return the default template for the actions new, edit, index, * and view. - * + * * @param string $action * @param mixed $entity the entity for the current request, or an array of entities * @param Request $request @@ -993,11 +993,11 @@ class CRUDController extends AbstractController if ($this->hasCustomTemplate($action, $entity, $request)) { return $this->getActionConfig($action)['template']; } - + switch ($action) { case 'new': return '@ChillMain/CRUD/new.html.twig'; - case 'edit': + case 'edit': return '@ChillMain/CRUD/edit.html.twig'; case 'index': return '@ChillMain/CRUD/index.html.twig'; @@ -1011,7 +1011,7 @@ class CRUDController extends AbstractController . "action"); } } - + /** * @param $action * @param $entity @@ -1022,7 +1022,7 @@ class CRUDController extends AbstractController { return !empty($this->getActionConfig($action)['template']); } - + /** * @param string $action * @param $entity @@ -1032,7 +1032,7 @@ class CRUDController extends AbstractController protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request) { } - + /** * @param string $action * @param $entity @@ -1042,7 +1042,7 @@ class CRUDController extends AbstractController protected function onPostFlush(string $action, $entity, FormInterface $form, Request $request) { } - + /** * @param string $action * @param $entity @@ -1052,7 +1052,7 @@ class CRUDController extends AbstractController protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request) { } - + /** * @param string $action * @param $entity @@ -1062,7 +1062,7 @@ class CRUDController extends AbstractController protected function onPostPersist(string $action, $entity, FormInterface $form, Request $request) { } - + /** * @param $action * @param Request $request @@ -1073,7 +1073,7 @@ class CRUDController extends AbstractController { return null; } - + /** * @param $action * @param Request $request @@ -1084,7 +1084,7 @@ class CRUDController extends AbstractController { return null; } - + /** * @param object $entity * @param FormInterface $form @@ -1093,16 +1093,16 @@ class CRUDController extends AbstractController protected function onFormValid(object $entity, FormInterface $form, Request $request) { } - + /** * Return a redirect response depending on the value of submit button. - * + * * The handled values are : - * + * * * save-and-close: return to index of current crud ; * * save-and-new: return to new page of current crud ; * * save-and-view: return to view page of current crud ; - * + * * @param string $action * @param mixed $entity * @param FormInterface $form @@ -1124,7 +1124,7 @@ class CRUDController extends AbstractController ]); } } - + /** * Include services * @@ -1135,7 +1135,7 @@ class CRUDController extends AbstractController { return $this->crudConfig['actions'][$action]; } - + /** * @return PaginatorFactory */ @@ -1143,7 +1143,7 @@ class CRUDController extends AbstractController { return $this->container->get('chill_main.paginator_factory'); } - + /** * @return TranslatorInterface */ @@ -1151,7 +1151,7 @@ class CRUDController extends AbstractController { return $this->container->get('translator'); } - + /** * @return AuthorizationHelper */ @@ -1159,19 +1159,19 @@ class CRUDController extends AbstractController { return $this->container->get(AuthorizationHelper::class); } - + /** * @param Role $role * @param Scope|null $scope * @return \Chill\MainBundle\Entity\Center[] */ - protected function getReachableCenters(Role $role, Scope $scope = null) + protected function getReachableCenters(Role $role, Scope $scope = null) { return $this->getAuthorizationHelper() ->getReachableCenters($this->getUser(), $role, $scope) ; } - + /** * @return EventDispatcherInterface */ @@ -1179,7 +1179,7 @@ class CRUDController extends AbstractController { return $this->get(EventDispatcherInterface::class); } - + /** * @return Resolver */ @@ -1187,7 +1187,7 @@ class CRUDController extends AbstractController { return $this->get(Resolver::class); } - + /** * @return array */ diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php index c12156fc7..ec47c6e0b 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialActions.php @@ -37,32 +37,32 @@ class LoadSocialActions extends AbstractFixture implements OrderedFixtureInterfa return 10020; } - public static $socialActions = array( - 'social_action_info_conseil' => array( - 'title' => array( + public static $socialActions = [ + 'social_action_info_conseil' => [ + 'title' => [ 'fr' => 'Informer, conseiller' - ), + ], 'issue' => 'social_issue_prev_prot' - ), - 'social_action_instruire' => array( - 'title' => array( + ], + 'social_action_instruire' => [ + 'title' => [ 'fr' => 'Instruire l\'imprime unique pour des impayés' - ), + ], 'issue' => 'social_issue_prev_prot' - ), - 'social_action_MASP' => array( - 'title' => array( + ], + 'social_action_MASP' => [ + 'title' => [ 'fr' => 'MASP' - ), + ], 'issue' => 'social_issue_diff_fin' - ), - 'social_action_protection_enfant' => array( - 'title' => array( + ], + 'social_action_protection_enfant' => [ + 'title' => [ 'fr' => 'Protection Enfant confié dans le cadre judiciaire' - ), + ], 'issue' => 'social_issue_enfant_protection' - ), - ); + ], + ]; public function load(ObjectManager $manager) { diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialGoals.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialGoals.php index f71d6cf3a..a6c2b0ef0 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialGoals.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialGoals.php @@ -38,20 +38,20 @@ class LoadSocialGoals extends AbstractFixture implements OrderedFixtureInterface return 10030; } - public static $socialGoals = array( - 'social_goal_instuire_dossier' => array( - 'title' => array( + public static $socialGoals = [ + 'social_goal_instuire_dossier' => [ + 'title' => [ 'fr' => 'Instruire le dossier de surendettement' - ), + ], 'action' => 'social_action_MASP' - ), - 'social_goal_proteger' => array( - 'title' => array( + ], + 'social_goal_proteger' => [ + 'title' => [ 'fr' => 'Protéger via une assistance educative placement' - ), + ], 'action' => 'social_action_protection_enfant' - ), - ); + ], + ]; public function load(ObjectManager $manager) { diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialIssues.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialIssues.php index c5b635f5b..eb9c303ed 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialIssues.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialIssues.php @@ -37,36 +37,36 @@ class LoadSocialIssues extends AbstractFixture implements OrderedFixtureInterfac return 10010; } - public static $socialIssues = array( - 'social_issue_diff_fin_or_admin' => array( - 'title' => array( + public static $socialIssues = [ + 'social_issue_diff_fin_or_admin' => [ + 'title' => [ 'fr' => 'ADULTE - DIFFICULTES FINANCIERES ET/OU ADMINISTRATIVES' - ) - ), - 'social_issue_prev_prot' => array( - 'title' => array( + ] + ], + 'social_issue_prev_prot' => [ + 'title' => [ 'fr' => 'ADULTE PREVENTION/PROTECTION' - ), + ], 'parent' => 'social_issue_diff_fin_or_admin' - ), - 'social_issue_diff_fin' => array( - 'title' => array( + ], + 'social_issue_diff_fin' => [ + 'title' => [ 'fr' => 'Difficulté financière' - ), + ], 'parent' => 'social_issue_diff_fin_or_admin' - ), - 'social_issue_enfant_famille' => array( - 'title' => array( + ], + 'social_issue_enfant_famille' => [ + 'title' => [ 'fr' => 'Enfant / famille' - ) - ), - 'social_issue_enfant_protection' => array( - 'title' => array( + ] + ], + 'social_issue_enfant_protection' => [ + 'title' => [ 'fr' => 'enfant - protection' - ), + ], 'parent' => 'social_issue_enfant_famille' - ), - ); + ], + ]; public function load(ObjectManager $manager) { diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialResults.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialResults.php index 33cff5eea..573313573 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialResults.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialResults.php @@ -38,34 +38,34 @@ class LoadSocialResults extends AbstractFixture implements OrderedFixtureInterfa return 10040; } - public static $socialResults = array( - 'social_result_FSL_acces' => array( - 'title' => array( + public static $socialResults = [ + 'social_result_FSL_acces' => [ + 'title' => [ 'fr' => 'FSL - accès cautionnement' - ), + ], 'action' => 'social_action_instruire' - ), - 'social_result_FSL_maintien' => array( - 'title' => array( + ], + 'social_result_FSL_maintien' => [ + 'title' => [ 'fr' => 'FSL maintien - impayés de loyer' - ), + ], 'action' => 'social_action_MASP' - ), - 'social_result_soutien_parental' => array( - 'title' => array( + ], + 'social_result_soutien_parental' => [ + 'title' => [ 'fr' => 'Soutien parental' - ), + ], // 'action' => 'social_action_protection_enfant', (via le goal) 'goal' => 'social_goal_proteger' - ), - 'social_result_accompagnement_mineur' => array( - 'title' => array( + ], + 'social_result_accompagnement_mineur' => [ + 'title' => [ 'fr' => 'Accompagnement du mineur' - ), + ], // 'action' => 'social_action_protection_enfant', (via le goal) 'goal' => 'social_goal_proteger', - ), - ); + ], + ]; public function load(ObjectManager $manager) {