public function send(NotificationInterface $notification) { if ($notification->canBeSent()) { $handler = $this->getNotificationHandler(); $serializer = $this->container->get('jms_serializer'); $context = SerializationContext::create()->setGroups('form'); $array = json_decode($serializer->serialize($notification, 'json', $context), true); $handler->patch($notification, array()); } else { $translator = $this->container->get('translator'); throw new AccessDeniedException($translator->trans("This notification cannot be sent to this user. Check the notification level and whether the user has authorized the application.")); } }