ILIAS
trunk Revision v11.0_alpha-3011-gc6b235a2e85
◀ ilDoc Overview
AccessQuestionImage.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\Test\Access
;
22
23
use
ILIAS\Data\Result
;
24
use
ILIAS\Data\Result\Ok
;
25
use
ILIAS\Data\Result\Error
;
26
27
class
AccessQuestionImage
implements
SimpleAccess
28
{
29
public
function
__construct
(
private
readonly
Readable
$readable)
30
{
31
}
32
33
public
function
isPermitted
(
string
$path
):
Result
34
{
35
$object_id = $this->
objectId
($path);
36
if
(!$object_id) {
37
return
new
Error
(
'Not a question image path of test questions.'
);
38
}
39
40
return
new
Ok
($this->readable->objectId($object_id));
41
}
42
43
private
function
objectId
(
string
$path
): ?
int
44
{
45
$results
= [];
46
if
(!preg_match(
':/assessment/(\d+)/(\d+)/images/([^/]+)$:'
,
$path
,
$results
)) {
47
return
null
;
48
}
49
50
return
(
int
)
$results
[1];
51
}
52
}
ILIAS\Data\Result\Ok
A result encapsulates a value or an error and simplifies the handling of those.
Definition:
Ok.php:31
ILIAS\Test\Access\AccessQuestionImage
Definition:
AccessQuestionImage.php:28
ILIAS\Test\Access\AccessQuestionImage\__construct
__construct(private readonly Readable $readable)
Definition:
AccessQuestionImage.php:29
ILIAS\Test\Access\AccessQuestionImage\objectId
objectId(string $path)
Definition:
AccessQuestionImage.php:43
ILIAS\Test\Access\AccessQuestionImage\isPermitted
isPermitted(string $path)
Definition:
AccessQuestionImage.php:33
ILIAS\Test\Access\Readable
Definition:
Readable.php:28
ILIAS\Data\Result
A result encapsulates a value or an error and simplifies the handling of those.
Definition:
Result.php:29
ILIAS\Test\Access\SimpleAccess
Definition:
SimpleAccess.php:26
$path
$path
Definition:
ltiservices.php:30
ILIAS\Data\Result
Definition:
Error.php:21
ILIAS\MetaData\OERExposer\OAIPMH\Responses\Error
Error
Definition:
Error.php:24
ILIAS\Repository\int
int(string $key)
Definition:
trait.BaseGUIRequest.php:61
ILIAS\Test\Access
Definition:
AccessFileUploadAnswer.php:21
$results
$results
Definition:
save_question_post_data.php:22
components
ILIAS
Test
src
Access
AccessQuestionImage.php
Generated on Sat Oct 18 2025 23:04:30 for ILIAS by
1.9.4 (using
Doxyfile
)