controller tell which layout twig must serve

This commit is contained in:
Mathieu Jaumotte 2021-02-12 16:48:08 +01:00
parent 34a913e8e6
commit 6d3b366479
2 changed files with 11 additions and 16 deletions

View File

@ -430,26 +430,27 @@ class SingleTaskController extends AbstractController
$viewParams['center'] = null; $viewParams['center'] = null;
$params['types'] = null; $params['types'] = null;
// Get parameters from url // Get parameters from url
if (!empty($request->query->get('person_id', NULL))) { if (!empty($request->query->get('person_id', NULL))) {
$personId = $request->query->getInt('person_id');
$personId = $request->query->getInt('person_id', 0);
$person = $personRepository->find($personId); $person = $personRepository->find($personId);
if ($person === null) { if ($person === null) {
throw $this->createNotFoundException("This person ' $personId ' does not exist."); throw $this->createNotFoundException("This person ' $personId ' does not exist.");
} }
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person); $this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
$viewParams['person'] = $person; $viewParams['person'] = $person;
$params['person'] = $person; $params['person'] = $person;
} elseif (!empty($request->query->get('center_id', NULL))) { }
if (!empty($request->query->get('center_id', NULL))) {
$center = $centerRepository->find($request->query->getInt('center_id')); $center = $centerRepository->find($request->query->getInt('center_id'));
if ($center === null) { if ($center === null) {
throw $this->createNotFoundException('center not found'); throw $this->createNotFoundException('center not found');
} }
$params['center'] = $center; $params['center'] = $center;
} }
@ -459,14 +460,13 @@ class SingleTaskController extends AbstractController
$params['types'] = $types; $params['types'] = $types;
} }
} }
if (!empty($request->query->get('user_id', null))) { if (!empty($request->query->get('user_id', null))) {
if ($request->query->get('user_id') === '_unassigned') { if ($request->query->get('user_id') === '_unassigned') {
$params['unassigned'] = true; $params['unassigned'] = true;
} else { } else {
$userId = $request->query->getInt('user_id', 0); // sf4 check:
// prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given`
$userId = $request->query->getInt('user_id', 0);
$user = $this->getDoctrine()->getManager() $user = $this->getDoctrine()->getManager()
->getRepository('ChillMainBundle:User') ->getRepository('ChillMainBundle:User')
->find($userId); ->find($userId);
@ -482,8 +482,7 @@ class SingleTaskController extends AbstractController
if (!empty($request->query->get('scope_id'))) { if (!empty($request->query->get('scope_id'))) {
$scopeId = $request->query->getInt('scope_id', 0); // sf4 check: $scopeId = $request->query->getInt('scope_id', 0);
// prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given`
$scope = $this->getDoctrine()->getManager() $scope = $this->getDoctrine()->getManager()
->getRepository('ChillMainBundle:Scope') ->getRepository('ChillMainBundle:Scope')

View File

@ -15,24 +15,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "@ChillPerson/layout.html.twig" %} {% extends layout %}
{% set activeRouteKey = 'chill_task_single_task_new' %} {% set activeRouteKey = 'chill_task_single_task_new' %}
{% block title %}{{ 'Task list'|trans }}{% endblock %} {% block title %}{{ 'Task list'|trans }}{% endblock %}
{% macro thead() %} {% macro thead() %}
{% endmacro %} {% endmacro %}
{% macro row(task) %} {% macro row(task) %}
{% endmacro %} {% endmacro %}
{# filter tasks #} {% block filtertasks %}
{% block filtertasks %}{#
sf4 check: prevent error message: `A block definition cannot be nested under non-capturing nodes.` #}
{% if person is not null %} {% if person is not null %}
{% block personcontent %} {% block personcontent %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %} {% include 'ChillTaskBundle:SingleTask:_list.html.twig' %}