ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AbstractResourceStakeholder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
30{
31 private string $provider_name_cache = '';
32
33 protected int $default_owner;
34 protected int $current_user;
35
36 public function __construct(?int $user_id_of_owner = null)
37 {
38 global $DIC;
39
40 if ($user_id_of_owner === null) {
41 $user_id_of_owner = $DIC instanceof Container && $DIC->isDependencyAvailable('user')
42 ? $DIC->user()->getId()
43 : (defined('SYSTEM_USER_ID') ? (int) SYSTEM_USER_ID : 6);
44 }
45
46 $this->default_owner = $this->current_user = $user_id_of_owner;
47 }
48
49 public function setOwner(int $user_id_of_owner): void
50 {
51 $this->default_owner = $user_id_of_owner;
52 }
53
54 public function getFullyQualifiedClassName(): string
55 {
56 return static::class;
57 }
58
59 public function isResourceInUse(ResourceIdentification $identification): bool
60 {
61 return false;
62 }
63
64 public function canBeAccessedByCurrentUser(ResourceIdentification $identification): bool
65 {
66 return true;
67 }
68
69 public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
70 {
71 return true;
72 }
73
74 public function getOwnerOfResource(ResourceIdentification $identification): int
75 {
76 return 6;
77 }
78
79 public function getConsumerNameForPresentation(): string
80 {
81 if ($this->provider_name_cache !== "" && is_string($this->provider_name_cache)) {
83 }
84
85 $reflector = new \ReflectionClass($this);
86
87 $dirname = dirname($reflector->getFileName());
88 $after_components = substr($dirname, strpos($dirname, '/components/') + strlen('/components/'));
89 $parts = explode(
90 DIRECTORY_SEPARATOR,
91 $after_components
92 );
93
94 $parts = array_filter($parts, static function ($part): bool {
95 $ignore = ['IRSS', 'Storage', 'ResourceStorage', 'classes'];
96 return $part !== '' && !in_array($part, $ignore, true);
97 });
98
99 return $this->provider_name_cache = implode('/', $parts);
100 }
101
102 public function getLocationURIForResourceUsage(ResourceIdentification $identification): ?string
103 {
104 return null;
105 }
106}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
global $DIC
Definition: shib_login.php:26