ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
Internal.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\LegalDocuments;
22 
23 use Closure;
24 
25 class Internal
26 {
28  private readonly array $map;
29 
35  public function __construct(Closure $create_provide, Closure $create_wiring, ?array $consumer_classes = null)
36  {
37  $lens = fn($consumer) => $consumer->uses($create_wiring($consumer->id()), new LazyProvide(fn() => $create_provide($consumer->id())));
38  $this->map = array_reduce(
39  $consumer_classes ?? require self::path(),
40  fn($map, $consumer) => $map->append($lens(new $consumer())->map()),
41  new Map()
42  )->value();
43  }
44 
45  public function all(string $name): array
46  {
47  return $this->map[$name] ?? [];
48  }
49 
50  public function get(string $name, string $key)
51  {
52  return $this->map[$name][$key] ?? null;
53  }
54 
55  public static function path(): string
56  {
57  return 'Services/LegalDocuments/artifacts/consumers.php';
58  }
59 }
__construct(Closure $create_provide, Closure $create_wiring, ?array $consumer_classes=null)
Definition: Internal.php:35
string $key
Consumer key/client ID value.
Definition: System.php:193