mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
task: api endpoint for my tasks
This commit is contained in:
parent
6ab8f95f7d
commit
7e2fbf93f9
@ -13,6 +13,7 @@ namespace Chill\TaskBundle\Controller;
|
|||||||
|
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||||
|
use Chill\MainBundle\Serializer\Model\Collection;
|
||||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
|
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
|
||||||
use Chill\MainBundle\Timeline\TimelineBuilder;
|
use Chill\MainBundle\Timeline\TimelineBuilder;
|
||||||
@ -31,6 +32,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
@ -431,10 +434,15 @@ final class SingleTaskController extends AbstractController
|
|||||||
* @return Response
|
* @return Response
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{_locale}/task/single-task/list/my",
|
* "/{_locale}/task/single-task/list/my",
|
||||||
* name="chill_task_singletask_my_tasks"
|
* name="chill_task_singletask_my_tasks",
|
||||||
|
* defaults={"_format": "html"}
|
||||||
|
* )
|
||||||
|
* @Route(
|
||||||
|
* "/api/1.0/task/single-task/list/my",
|
||||||
|
* defaults={"_format": "json"}
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function myTasksAction()
|
public function myTasksAction(string $_format)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ROLE_USER');
|
$this->denyAccessUnlessGranted('ROLE_USER');
|
||||||
|
|
||||||
@ -459,11 +467,23 @@ final class SingleTaskController extends AbstractController
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
switch ($_format) {
|
||||||
|
case 'html':
|
||||||
return $this->render('@ChillTask/SingleTask/List/index_my_tasks.html.twig', [
|
return $this->render('@ChillTask/SingleTask/List/index_my_tasks.html.twig', [
|
||||||
'tasks' => $tasks,
|
'tasks' => $tasks,
|
||||||
'paginator' => $paginator,
|
'paginator' => $paginator,
|
||||||
'filter_order' => $filterOrder,
|
'filter_order' => $filterOrder,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
case 'json':
|
||||||
|
$collection = new Collection($tasks, $paginator);
|
||||||
|
|
||||||
|
return $this->json($collection, JsonResponse::HTTP_OK, [],
|
||||||
|
['groups' => ['read']]);
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new BadRequestException("format not supported: $format");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@ use Chill\MainBundle\Entity\User;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
use function array_fill_keys;
|
use function array_fill_keys;
|
||||||
@ -27,6 +28,9 @@ use function array_keys;
|
|||||||
* AbstractTask.
|
* AbstractTask.
|
||||||
*
|
*
|
||||||
* @ORM\MappedSuperclass
|
* @ORM\MappedSuperclass
|
||||||
|
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||||
|
* "single_task": SingleTask::class
|
||||||
|
* })
|
||||||
*/
|
*/
|
||||||
abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
||||||
{
|
{
|
||||||
@ -35,6 +39,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
|||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
* targetEntity="\Chill\MainBundle\Entity\User"
|
* targetEntity="\Chill\MainBundle\Entity\User"
|
||||||
* )
|
* )
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $assignee;
|
private $assignee;
|
||||||
|
|
||||||
@ -49,12 +54,14 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
|||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
* @ORM\Column(name="closed", type="boolean", options={ "default": false })
|
* @ORM\Column(name="closed", type="boolean", options={ "default": false })
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $closed = false;
|
private $closed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var AccompanyingPeriod
|
* @var AccompanyingPeriod
|
||||||
* @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod")
|
* @ORM\ManyToOne(targetEntity="\Chill\PersonBundle\Entity\AccompanyingPeriod")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $course;
|
private $course;
|
||||||
|
|
||||||
@ -62,6 +69,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
|||||||
* @var json
|
* @var json
|
||||||
*
|
*
|
||||||
* @ORM\Column(name="current_states", type="json")
|
* @ORM\Column(name="current_states", type="json")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $currentStates = [];
|
private $currentStates = [];
|
||||||
|
|
||||||
@ -69,6 +77,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(name="description", type="text")
|
* @ORM\Column(name="description", type="text")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $description = '';
|
private $description = '';
|
||||||
|
|
||||||
@ -77,6 +86,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
|||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||||
* )
|
* )
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $person;
|
private $person;
|
||||||
|
|
||||||
@ -85,6 +95,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
|||||||
*
|
*
|
||||||
* @ORM\Column(name="title", type="text")
|
* @ORM\Column(name="title", type="text")
|
||||||
* @Assert\NotBlank
|
* @Assert\NotBlank
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $title = '';
|
private $title = '';
|
||||||
|
|
||||||
@ -92,6 +103,7 @@ abstract class AbstractTask implements HasCenterInterface, HasScopeInterface
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(name="type", type="string", length=255)
|
* @ORM\Column(name="type", type="string", length=255)
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user