make timeline & paginator service private

This commit is contained in:
Julien Fastré 2020-07-28 13:11:12 +02:00
parent 5245d9971e
commit d53e6b57a4
2 changed files with 28 additions and 10 deletions

View File

@ -24,6 +24,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Chill\MainBundle\Timeline\TimelineBuilder;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
/**
*
@ -38,14 +41,31 @@ class TimelinePersonController extends Controller
*/
protected $eventDispatcher;
/**
*
* @var TimelineBuilder
*/
protected $timelineBuilder;
/**
*
* @var PaginatorFactory
*/
protected $paginatorFactory;
/**
* TimelinePersonController constructor.
*
* @param EventDispatcherInterface $eventDispatcher
*/
public function __construct(EventDispatcherInterface $eventDispatcher)
{
public function __construct(
EventDispatcherInterface $eventDispatcher,
TimelineBuilder $timelineBuilder,
PaginatorFactory $paginatorFactory
) {
$this->eventDispatcher = $eventDispatcher;
$this->timelineBuilder = $timelineBuilder;
$this->paginatorFactory = $paginatorFactory;
}
@ -59,24 +79,20 @@ class TimelinePersonController extends Controller
throw $this->createNotFoundException();
}
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
/* @var $timelineBuilder \Chill\MainBundle\Timeline\TimelineBuilder */
$timelineBuilder = $this->get('chill.main.timeline_builder');
$paginatorFactory = $this->get('chill_main.paginator_factory');
$nbItems = $timelineBuilder->countItems('person',
$nbItems = $this->timelineBuilder->countItems('person',
[ 'person' => $person ]
);
$paginator = $paginatorFactory->create($nbItems);
$paginator = $this->paginatorFactory->create($nbItems);
$event = new PrivacyEvent($person, array('action' => 'timeline'));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
return $this->render('ChillPersonBundle:Timeline:index.html.twig', array
(
'timeline' => $timelineBuilder->getTimelineHTML(
'timeline' => $this->timelineBuilder->getTimelineHTML(
'person',
array('person' => $person),
$paginator->getCurrentPage()->getFirstItemNumber(),

View File

@ -11,6 +11,8 @@ services:
Chill\PersonBundle\Controller\TimelinePersonController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$timelineBuilder: '@chill_main.timeline_builder'
$paginatorFactory: '@chill_main.paginator_factory'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingPeriodController: