19declare(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()
72 new DocumentModal($this->container->ui(), $this->contentAsComponent(...)),
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);
157 $a = $this->toCondition(
$a);
158 if (
$a->knownToNeverMatchWith($this->toCondition(
$b))) {
159 return new Error(self::CRITERION_WOULD_NEVER_MATCH);
171 private function find(Closure $predicate, array $array):
Result
173 foreach ($array as $x) {
174 if ($predicate($x)) {
179 return new Error(
'Not found.');
187 private function any(Closure $predicate, array $array): bool
189 return $this->
find($predicate, $array)->isOk();
197 private function all(Closure $predicate, array $array): bool
199 return !$this->
any(
static fn($x) => !$predicate($x), $array);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Customizing of pimple-DIC for ILIAS.
A result encapsulates a value or an error and simplifies the handling of those.
validateAgainst(Result $b, Criterion $a)
const CRITERION_ALREADY_EXISTS
conditionGroups(?CriterionContent $criterion=null)
validateCriteriaContent(array $criteria, CriterionContent $content)
chooseDocumentFor(ilObjUser $user)
all(Closure $predicate, array $array)
@template A
find(Closure $predicate, array $array)
@template A
documentMatches(Document $document, ilObjUser $user)
contentAsComponent(DocumentContent $content)
__construct(private readonly string $id, private readonly DocumentRepository $document_repository, private readonly SelectionMap $conditions, private readonly array $content_as_component, private readonly Container $container,)
any(Closure $predicate, array $array)
@template A
table(object $gui, ?EditLinks $edit_links=null)
toCondition(CriterionContent $content)
const CRITERION_WOULD_NEVER_MATCH
A result encapsulates a value or an error and simplifies the handling of those.
formGroup(array $arguments=[])
A component is the most general form of an entity in the UI.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
if(!file_exists('../ilias.ini.php'))