getContainer()->getPermissionsService()->currentUserCanRead(Entities::NOTIFICATIONS)) { throw new AccessDeniedException('You are not allowed to read notifications'); } $result = new CommandResult(); /** @var NotificationRepository $notificationRepo */ $notificationRepo = $this->container->get('domain.notification.repository'); $notifications = $notificationRepo->getAll(); if (!$notifications instanceof AbstractCollection) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Could not get notifications'); return $result; } $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully retrieved notifications.'); $result->setData([ Entities::NOTIFICATIONS => $notifications->toArray() ]); return $result; } }