Grav\Plugin\Admin\AdminController::taskGetNotifications PHP Method

taskGetNotifications() protected method

Get Notifications from cache.
protected taskGetNotifications ( )
    protected function taskGetNotifications()
    {
        $cache = $this->grav['cache'];
        if (!(bool) $this->grav['config']->get('system.cache.enabled') || !($notifications = $cache->fetch('notifications'))) {
            //No notifications cache (first time)
            $this->admin->json_response = ['status' => 'success', 'notifications' => [], 'need_update' => true];
            return;
        }
        $need_update = false;
        if (!($last_checked = $cache->fetch('notifications_last_checked'))) {
            $need_update = true;
        } else {
            if (time() - $last_checked > 86400) {
                $need_update = true;
            }
        }
        try {
            $notifications = $this->admin->processNotifications($notifications);
        } catch (\Exception $e) {
            $this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
            return;
        }
        $this->admin->json_response = ['status' => 'success', 'notifications' => $notifications, 'need_update' => $need_update];
    }