/**
  * Remove a notification
  *
  * @param integer $id
  *
  * @return JsonResponse
  */
 public function removeAction($id)
 {
     $user = $this->userContext->getUser();
     if (null !== $user) {
         $this->manager->remove($user, $id);
     }
     return new JsonResponse();
 }
 /**
  * Return the number of unread notifications for the currently logged in user
  *
  * @return int
  */
 public function countNotifications()
 {
     $user = $this->userContext->getUser();
     if (null === $user) {
         return 0;
     }
     return $this->manager->countUnreadForUser($user);
 }
 /**
  * Notify a user of the end of the job
  *
  * @param JobExecutionEvent $event
  *
  * @return null
  */
 public function afterJobExecution(JobExecutionEvent $event)
 {
     $jobExecution = $event->getJobExecution();
     $user = $jobExecution->getUser();
     if (null === $user) {
         return;
     }
     if ($jobExecution->getStatus()->isUnsuccessful()) {
         $status = 'error';
     } else {
         $status = 'success';
         foreach ($jobExecution->getStepExecutions() as $stepExecution) {
             if ($stepExecution->getWarnings()->count()) {
                 $status = 'warning';
                 break;
             }
         }
     }
     $type = $jobExecution->getJobInstance()->getType();
     $this->manager->notify([$user], sprintf('pim_import_export.notification.%s.%s', $type, $status), $status, ['route' => sprintf('pim_importexport_%s_execution_show', $type), 'routeParams' => ['id' => $jobExecution->getId()], 'messageParams' => ['%label%' => $jobExecution->getJobInstance()->getLabel()]]);
 }
 /**
  * @param JobExecution         $jobExecution
  * @param string|UserInterface $user
  * @param string               $type
  * @param string               $status
  */
 protected function generateMassEditNotify(JobExecution $jobExecution, $user, $type, $status)
 {
     $this->manager->notify([$user], sprintf('pim_mass_edit.notification.%s.%s', $type, $status), $status, ['route' => 'pim_enrich_job_tracker_show', 'routeParams' => ['id' => $jobExecution->getId()], 'messageParams' => ['%label%' => $jobExecution->getJobInstance()->getLabel()]]);
 }