mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
67 lines
1.9 KiB
PHP
67 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Chill\TaskBundle\Controller;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use Chill\TaskBundle\Entity\SingleTask;
|
|
use Chill\MainBundle\Entity\User;
|
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
|
|
class TaskController extends Controller
|
|
{
|
|
/**
|
|
* @Route("/{_locale}/task/task/list/{personId}")
|
|
*/
|
|
public function listAction(Request $request, Person $personId)
|
|
{
|
|
$person = $personId;
|
|
$em = $this->getDoctrine()
|
|
->getManager();
|
|
// collect parameters for filter
|
|
$params = [];
|
|
|
|
$params['person'] = $person;
|
|
|
|
$singleTasks = $this->get('chill_task.single_task_repository')
|
|
->findByParameters($params, $this->getUser());
|
|
|
|
return $this->render('ChillTaskBundle:Task:index.html.twig', [
|
|
'single_tasks' => $singleTasks,
|
|
'person' => $person
|
|
]);
|
|
}
|
|
|
|
protected function getPersonParam(Request $request, EntityManagerInterface $em)
|
|
{
|
|
$person = $em->getRepository(Person::class)
|
|
->find($request->query->getInt('person_id'))
|
|
;
|
|
|
|
if (NULL === $person) {
|
|
throw $this->createNotFoundException('person not found');
|
|
}
|
|
|
|
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person, "You are "
|
|
. "not allowed to see this person");
|
|
|
|
return $person;
|
|
}
|
|
|
|
protected function getUserParam(Request $request, EntityManagerInterface $em)
|
|
{
|
|
$user = $em->getRepository(User::class)
|
|
->find($request->query->getInt('user_id'))
|
|
;
|
|
|
|
if (NULL === $user) {
|
|
throw $this->createNotFoundException('user not found');
|
|
}
|
|
|
|
return $user;
|
|
}
|
|
|
|
}
|