diff --git a/Controller/TimelinePersonController.php b/Controller/TimelinePersonController.php index 35935163d..14ee0ccbb 100644 --- a/Controller/TimelinePersonController.php +++ b/Controller/TimelinePersonController.php @@ -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(), diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 363969b68..59413327f 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -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: