19 declare(strict_types=1);
64 private readonly
string $id,
67 private readonly array $content_as_component,
69 ?
Closure $create_table_gui = null
71 $this->create_table_gui = $create_table_gui ?? fn($gui, $command, $t) =>
new Table($gui, $command, $t);
77 fn($criterion) => $this->
toCondition($criterion)->asComponent(),
78 $this->document_repository,
79 new UI($this->
id, $this->container->ui(), $this->container->language()),
83 if ($edit_links !== null) {
89 return $this->container->ui()->factory()->legacy($table->getHTML());
96 $this->document_repository->all()
110 return $this->document_repository;
115 return bin2hex(openssl_random_pseudo_bytes((
int) floor(255 / 2)));
120 return $this->conditions->choices()[$content->
type()]->withCriterion($content);
128 $selected = $criterion ? [
129 $criterion->type() => $criterion->arguments()
132 $choices = $this->conditions->
choices();
133 $groups = array_combine(array_keys($choices), array_map(
135 array_values($choices),
139 return new SelectionMap($groups, $this->conditions->defaultSelection());
156 return $this->content_as_component[$content->
type()]($content);
163 if ($a->equals($b)) {
164 return new Error(self::CRITERION_ALREADY_EXISTS);
167 if ($a->knownToNeverMatchWith($this->toCondition($b))) {
168 return new Error(self::CRITERION_WOULD_NEVER_MATCH);
182 foreach ($array as $x) {
183 if ($predicate($x)) {
188 return new Error(
'Not found.');
198 return $this->
find($predicate, $array)->isOk();
208 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
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...
A result encapsulates a value or an error and simplifies the handling of those.
documentMatches(Document $document, ilObjUser $user)
readonly Closure $create_table_gui
Customizing of pimple-DIC for ILIAS.
find(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, ?Closure $create_table_gui=null)
conditionGroups(?CriterionContent $criterion=null)
A result encapsulates a value or an error and simplifies the handling of those.
validateCriteriaContent(array $criteria, CriterionContent $content)
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)
table(object $gui, string $command, ?EditLinks $edit_links=null)
const CRITERION_WOULD_NEVER_MATCH