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

View File

@ -15,24 +15,20 @@
* 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' %}
{% block title %}{{ 'Task list'|trans }}{% endblock %}
{% macro thead() %}
{% endmacro %}
{% macro row(task) %}
{% endmacro %}
{# filter tasks #}
{% block filtertasks %}{#
sf4 check: prevent error message: `A block definition cannot be nested under non-capturing nodes.` #}
{% block filtertasks %}
{% if person is not null %}
{% block personcontent %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %}