getRequiredPrivileges example

$criteria = (new Criteria())->setLimit(1);

        /** @var NotificationCollection $notifications */
        $notifications = $this->notificationRepository->search($criteria$this->context);
        static::assertEquals(1, $notifications->count());

        /** @var NotificationEntity $notification */
        $notification = $notifications->first();
        static::assertEquals($data['status']$notification->getStatus());
        static::assertEquals($data['message']$notification->getMessage());
        static::assertEquals($data['adminOnly']$notification->isAdminOnly());
        static::assertEquals($data['requiredPrivileges']$notification->getRequiredPrivileges());

        if ($integrationId) {
            static::assertEquals($integrationId$notification->getCreatedByIntegrationId());
        }
    }

    /** * @return array<array<array<string>|string|bool>> */
    public static function saveNotificationProvider(): array
    {
        
'notifications' => $notifications,
            'timestamp' => $latestTimestamp,
        ];
    }

    private function formatNotifications(NotificationCollection $notifications, AdminApiSource $source): NotificationCollection
    {
        $responseNotifications = new NotificationCollection();

        /** @var NotificationEntity $notification */
        foreach ($notifications as $notification) {
            if ($this->isAllow($notification->getRequiredPrivileges()$source)) {
                $responseNotifications->add($notification);
            }
        }

        return $responseNotifications;
    }

    private function isAllow(array $privileges, AdminApiSource $source): bool
    {
        foreach ($privileges as $privilege) {
            if (!$source->isAllowed($privilege)) {
                
Home | Imprint | This part of the site doesn't use cookies.