mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
privacyEvent, add event to show and list Actions
This commit is contained in:
parent
e25621ef79
commit
32d5d448e0
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Chill\TaskBundle\Controller;
|
namespace Chill\TaskBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
@ -30,6 +31,22 @@ use Chill\TaskBundle\Event\UI\UIEvent;
|
|||||||
class SingleTaskController extends Controller
|
class SingleTaskController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var EventDispatcherInterface
|
||||||
|
*/
|
||||||
|
protected $eventDispatcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SingleTaskController constructor.
|
||||||
|
*
|
||||||
|
* @param EventDispatcherInterface $eventDispatcher
|
||||||
|
*/
|
||||||
|
public function __construct(EventDispatcherInterface $eventDispatcher)
|
||||||
|
{
|
||||||
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{_locale}/task/single-task/new",
|
* "/{_locale}/task/single-task/new",
|
||||||
@ -38,7 +55,6 @@ class SingleTaskController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function newAction(
|
public function newAction(
|
||||||
Request $request,
|
Request $request,
|
||||||
EventDispatcherInterface $dispatcher,
|
|
||||||
TranslatorInterface $translator
|
TranslatorInterface $translator
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@ -77,7 +93,7 @@ class SingleTaskController extends Controller
|
|||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->persist($task);
|
$em->persist($task);
|
||||||
|
|
||||||
$dispatcher->dispatch(TaskEvent::PERSIST, new TaskEvent($task));
|
$this->eventDispatcher->dispatch(TaskEvent::PERSIST, new TaskEvent($task));
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
@ -137,6 +153,13 @@ class SingleTaskController extends Controller
|
|||||||
$timeline = $this->get('chill.main.timeline_builder')
|
$timeline = $this->get('chill.main.timeline_builder')
|
||||||
->getTimelineHTML('task', array('task' => $task));
|
->getTimelineHTML('task', array('task' => $task));
|
||||||
|
|
||||||
|
$event = new PrivacyEvent($person, array(
|
||||||
|
'element_class' => SingleTask::class,
|
||||||
|
'element_id' => intval($id),
|
||||||
|
'action' => 'show'
|
||||||
|
));
|
||||||
|
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||||
|
|
||||||
return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array(
|
return $this->render('ChillTaskBundle:SingleTask:show.html.twig', array(
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'timeline' => $timeline
|
'timeline' => $timeline
|
||||||
@ -153,8 +176,7 @@ class SingleTaskController extends Controller
|
|||||||
public function editAction(
|
public function editAction(
|
||||||
Request $request,
|
Request $request,
|
||||||
$id,
|
$id,
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator
|
||||||
EventDispatcherInterface $dispatcher
|
|
||||||
) {
|
) {
|
||||||
/* @var $taskRepository SingleTaskRepository */
|
/* @var $taskRepository SingleTaskRepository */
|
||||||
$taskRepository = $this->get('chill_task.single_task_repository');
|
$taskRepository = $this->get('chill_task.single_task_repository');
|
||||||
@ -186,7 +208,7 @@ class SingleTaskController extends Controller
|
|||||||
->setForm($this->setCreateForm($task, new Role(TaskVoter::UPDATE)))
|
->setForm($this->setCreateForm($task, new Role(TaskVoter::UPDATE)))
|
||||||
;
|
;
|
||||||
|
|
||||||
$dispatcher->dispatch(UIEvent::EDIT_FORM, $event);
|
$this->eventDispatcher->dispatch(UIEvent::EDIT_FORM, $event);
|
||||||
|
|
||||||
$form = $event->getForm();
|
$form = $event->getForm();
|
||||||
|
|
||||||
@ -212,7 +234,7 @@ class SingleTaskController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dispatcher->dispatch(UIEvent::EDIT_PAGE, $event);
|
$this->eventDispatcher->dispatch(UIEvent::EDIT_PAGE, $event);
|
||||||
|
|
||||||
if ($event->hasResponse()) {
|
if ($event->hasResponse()) {
|
||||||
return $event->getResponse();
|
return $event->getResponse();
|
||||||
@ -495,6 +517,12 @@ class SingleTaskController extends Controller
|
|||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
$event = new PrivacyEvent($person, array(
|
||||||
|
'element_class' => SingleTask::class,
|
||||||
|
'action' => 'list'
|
||||||
|
));
|
||||||
|
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||||
|
|
||||||
return $this->render('ChillTaskBundle:SingleTask:index.html.twig',
|
return $this->render('ChillTaskBundle:SingleTask:index.html.twig',
|
||||||
\array_merge($viewParams, [ 'form' => $form->createView() ]));
|
\array_merge($viewParams, [ 'form' => $form->createView() ]));
|
||||||
}
|
}
|
||||||
|
@ -2,3 +2,8 @@ services:
|
|||||||
Chill\TaskBundle\Controller\:
|
Chill\TaskBundle\Controller\:
|
||||||
resource: '../../../Controller'
|
resource: '../../../Controller'
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
|
||||||
|
Chill\TaskBundle\Controller\SingleTaskController:
|
||||||
|
arguments:
|
||||||
|
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
||||||
|
tags: ['controller.service_arguments']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user