19 declare(strict_types=1);
54 private readonly
string $id,
57 private readonly array $content_as_component,
65 fn($criterion) => $this->
toCondition($criterion)->asComponent(),
66 $this->document_repository,
69 $this->container->ui(),
70 $this->container->language()
75 $this->container->http()->request(),
77 $this->container->ctrl(),
78 $this->container->ui()->renderer(),
79 $this->container->user()
87 $this->document_repository->all()
101 return $this->document_repository;
106 return bin2hex(openssl_random_pseudo_bytes((
int) floor(255 / 2)));
111 return $this->conditions->choices()[$content->
type()]->withCriterion($content);
119 $selected = $criterion ? [
120 $criterion->type() => $criterion->arguments()
123 $choices = $this->conditions->
choices();
124 $groups = array_combine(array_keys($choices),
array_map(
126 array_values($choices),
130 return new SelectionMap($groups, $this->conditions->defaultSelection());
147 return $this->content_as_component[$content->
type()]($content);
154 if ($a->equals($b)) {
155 return new Error(self::CRITERION_ALREADY_EXISTS);
158 if ($a->knownToNeverMatchWith($this->toCondition($b))) {
159 return new Error(self::CRITERION_WOULD_NEVER_MATCH);
173 foreach ($array as $x) {
174 if ($predicate($x)) {
179 return new Error(
'Not found.');
189 return $this->
find($predicate, $array)->isOk();
199 return !$this->
any(
static fn($x) => !$predicate($x), $array);
then(callable $f)
Get a new result from the callable or do nothing if this is an error.
formGroup(array $arguments=[])
validateAgainst(Result $b, Criterion $a)
all(Closure $predicate, array $array)
A
__construct(private readonly string $id, private readonly DocumentRepository $document_repository, private readonly SelectionMap $conditions, private readonly array $content_as_component, private readonly Container $container,)
contentAsComponent(DocumentContent $content)
const CRITERION_ALREADY_EXISTS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
documentMatches(Document $document, ilObjUser $user)
Customizing of pimple-DIC for ILIAS.
find(Closure $predicate, array $array)
A
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
conditionGroups(?CriterionContent $criterion=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A result encapsulates a value or an error and simplifies the handling of those.
validateCriteriaContent(array $criteria, CriterionContent $content)
table(object $gui, ?EditLinks $edit_links=null)
any(Closure $predicate, array $array)
A
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
toCondition(CriterionContent $content)
chooseDocumentFor(ilObjUser $user)
const CRITERION_WOULD_NEVER_MATCH