ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
StaticUrlHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29
30class StaticUrlHandler extends BaseHandler implements Handler
31{
32 public const string NAMESPACE = 'badge';
33
34 public function getNamespace(): string
35 {
36 return self::NAMESPACE;
37 }
38
39 public function handle(Request $request, Context $context, Factory $response_factory): Response
40 {
41 if (!$context->isUserLoggedIn()) {
42 return $response_factory->loginFirst();
43 }
44
45 if (!\ilBadgeHandler::getInstance()->isActive()) {
46 return $response_factory->cannot();
47 }
48
49 $params = implode('/', $request->getAdditionalParameters() ?? []);
50 $path = parse_url($params, PHP_URL_PATH);
51
52 return match ($path) {
53 'profile' => $response_factory->can($context->ctrl()->getLinkTargetByClass(
54 [
55 \ilDashboardGUI::class,
56 \ilAchievementsGUI::class,
57 \ilBadgeProfileGUI::class
58 ]
59 )),
60 default => $response_factory->cannot(),
61 };
62 }
63}
handle(Request $request, Context $context, Factory $response_factory)
can(string $uri_path, bool $shift=false)
Definition: Factory.php:47
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
$path
Definition: ltiservices.php:30