ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
DefaultMappings.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\LegalDocuments;
22 
29 
31 {
32  public function __construct(
33  private readonly string $id,
34  private readonly Container $container
35  ) {
36  }
37 
42  {
43  $ui = new UI(
44  $this->id,
45  $this->container->ui(),
46  $this->container->language()
47  );
48 
49  $this->container->language()->loadLanguageModule('rbac');
50  $this->container->language()->loadLanguageModule('meta');
51 
52  $required = fn(array $options): Constraint => $this->container->refinery()->custom()->constraint(
53  static fn(?string $s): bool => $s !== null && isset($options[$s]),
54  static fn(): string => $ui->txt('msg_input_is_required')
55  );
56 
57  return new SelectionMap([
58  'usr_global_role' => new RoleDefinition($ui, $this->container['ilObjDataCache'], $this->container->rbac()->review(), $required),
59  'usr_language' => new UserLanguageDefinition($ui, $this->container->language()->getInstalledLanguages(), $required),
60  'usr_country' => new UserCountryDefinition($ui, $required),
61  ], 'usr_country');
62  }
63 
64  public function contentAsComponent(): array
65  {
66  return [
67  'html' => fn($x) => $this->container->ui()->factory()->legacy($x->value()),
68  ];
69  }
70 }
A constraint encodes some resrtictions on values.
Definition: Constraint.php:31
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$container
Definition: wac.php:14
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(private readonly string $id, private readonly Container $container)