mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
add list of task
This commit is contained in:
66
Controller/TaskController.php
Normal file
66
Controller/TaskController.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user