public function onFilterController(FilterControllerEvent $event)
 {
     if (!$this->shouldCheckTerms($event)) {
         return;
     }
     $request = $event->getRequest();
     if ($this->httpUtils->checkRequestPath($request, 'tos_agree') || $this->httpUtils->checkRequestPath($request, 'tos_terms') || $request->attributes->get('_controller') == 'LoginCidadaoTOSBundle:Agreement' || $request->attributes->get('_controller') == 'LoginCidadaoTOSBundle:TermsOfService:showLatest' || $event->getRequestType() === HttpKernelInterface::SUB_REQUEST) {
         return;
     }
     $user = $this->securityContext->getToken()->getUser();
     if (!$this->termsManager->hasAgreedToLatestTerms($user)) {
         throw new TermsNotAgreedException();
     }
 }
 public function onGetTasks(GetTasksEvent $event)
 {
     if (false === $this->shouldCheckTerms($event)) {
         return;
     }
     $user = $this->tokenStorage->getToken()->getUser();
     if ($this->termsManager->hasAgreedToLatestTerms($user)) {
         return;
     }
     $event->addTask(new ToSAgreementTask());
 }
 public function onRegistrationCompleted(FilterUserResponseEvent $event)
 {
     $user = $event->getUser();
     $this->manager->setUserAgreed($user);
 }