Merge branch 'privacyEvent'

This commit is contained in:
Tchama 2019-01-25 17:53:57 +01:00
commit 73ef9e1f8e
3 changed files with 63 additions and 10 deletions

View File

@ -18,7 +18,13 @@ Version 1.5.5
- Fix error on the "see more" link which was not showed - Fix error on the "see more" link which was not showed
- Layout of the task list - Layout of the task list
Version 1.5.6
=============
- fix: validation error on warning date interval is not shown
- add privacy events to task show / list;
- add privacy events to task edit / update;
branch `master` branch `master`
============== ==============
- fix: validation error on warning date interval is not shown

View File

@ -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,7 +31,23 @@ use Chill\MainBundle\Repository\CenterRepository;
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",
@ -39,7 +56,6 @@ class SingleTaskController extends Controller
*/ */
public function newAction( public function newAction(
Request $request, Request $request,
EventDispatcherInterface $dispatcher,
TranslatorInterface $translator TranslatorInterface $translator
) { ) {
@ -78,7 +94,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,7 +153,14 @@ 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' => $task->getId(),
'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
@ -154,8 +177,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');
@ -187,7 +209,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();
@ -202,6 +224,13 @@ class SingleTaskController extends Controller
$this->addFlash('success', $translator $this->addFlash('success', $translator
->trans("The task has been updated")); ->trans("The task has been updated"));
$event = new PrivacyEvent($person, array(
'element_class' => SingleTask::class,
'element_id' => $task->getId(),
'action' => 'update'
));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
return $this->redirectToRoute( return $this->redirectToRoute(
'chill_task_singletask_list', 'chill_task_singletask_list',
@ -213,12 +242,19 @@ 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();
} }
$event = new PrivacyEvent($person, array(
'element_class' => SingleTask::class,
'element_id' => $task->getId(),
'action' => 'edit'
));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array( return $this->render('ChillTaskBundle:SingleTask:edit.html.twig', array(
'task' => $task, 'task' => $task,
'form' => $form->createView() 'form' => $form->createView()
@ -503,6 +539,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() ]));

View File

@ -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']