ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Internal.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\LegalDocuments;
22
23use Closure;
25
27{
29 private readonly array $map;
30
36 public function __construct(Closure $create_provide, Closure $create_wiring, ?array $consumer_classes = null)
37 {
38 $lens = fn($consumer) => $consumer->uses($create_wiring($consumer->id()), new LazyProvide(fn() => $create_provide($consumer->id())));
39 $this->map = array_reduce(
40 $consumer_classes ?? require ConsumerObjective::PATH(),
41 fn($map, $consumer) => $map->append($lens(new $consumer())->map()),
42 new Map()
43 )->value();
44 }
45
46 public function all(string $name): array
47 {
48 return $this->map[$name] ?? [];
49 }
50
51 public function get(string $name, string $key)
52 {
53 return $this->map[$name][$key] ?? null;
54 }
55}
__construct(Closure $create_provide, Closure $create_wiring, ?array $consumer_classes=null)
Definition: Internal.php:36