getQueryParams(); /** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager */ $authorizer = $this->ci->authorizer; /** @var \UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface $currentUser */ $currentUser = $this->ci->currentUser; // Access-controlled page if (!$authorizer->checkAccess($currentUser, 'uri_tasks')) { throw new ForbiddenException(); } /** @var \UserFrosting\Sprinkle\Scheduler\Scheduler $scheduler */ $scheduler = $this->ci->scheduler; $tasks = $scheduler->getTasks(); $tasks = array_map( function($val) { $val['schedule_nice'] = CronTranslator::translate($val['schedule']); return $val; }, $tasks ); // Be careful how you consume this data - it has not been escaped and contains untrusted user-supplied content. // For example, if you plan to insert it into an HTML DOM, you must escape it on the client side (or use client-side templating). return $response->withJson($tasks, 200, JSON_PRETTY_PRINT); } /** * Renders the task listing page. * * This page renders a table of tasks, with dropdown menus for admin actions for each task. * Actions typically include: run task * This page requires authentication. * * Request type: GET * * @param Request $request * @param Response $response * @param array $args * * @throws ForbiddenException If user is not authorized to access page */ public function pageList(Request $request, Response $response, $args) { /** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager */ $authorizer = $this->ci->authorizer; /** @var \UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface $currentUser */ $currentUser = $this->ci->currentUser; // Access-controlled page if (!$authorizer->checkAccess($currentUser, 'uri_tasks')) { throw new ForbiddenException(); } /** @var \UserFrosting\Sprinkle\Scheduler\Scheduler $scheduler */ $scheduler = $this->ci->scheduler; $tasks = $scheduler->getTasks(); return $this->ci->view->render($response, 'pages/tasks.html.twig', [ 'tasks' => $tasks ]); } }