ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilHelpBuildScreenIdMapObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26use ILIAS\Setup;
31
33{
34 public const ARTIFACT = "./Services/Help/artifacts/screen_id_map.php";
35
36 public function getArtifactPath(): string
37 {
38 return self::ARTIFACT;
39 }
40
41 public function getArtifactName(): string
42 {
43 return "screen_id_map";
44 }
45
46
47 public function build(): Setup\Artifact
48 {
49 $finder = new Setup\UsageOfAttributeFinder();
50 $map = [];
51 $get_name = function (string $class_name, string $attribute_name): ?string {
52 $reflection = new \ReflectionClass($class_name);
53 $attributes = $reflection->getAttributes($attribute_name);
54 if (empty($attributes) || !isset($attributes[0])) {
55 return null;
56 }
58 $attribute = $attributes[0]->newInstance();
59 return $attribute->getScreenId();
60 };
61
62 // Silent
63 foreach ($finder->getMatchingClassNames(SilentHelpScreenId::class) as $matching_class_name) {
64 $map[$matching_class_name] = null;
65 }
66 // Recurring
67 foreach ($finder->getMatchingClassNames(RecurringHelpScreenId::class) as $matching_class_name) {
68 $map[$matching_class_name] = '*' . $get_name($matching_class_name, RecurringHelpScreenId::class);
69 }
70 // Normal
71 foreach ($finder->getMatchingClassNames(HelpScreenId::class) as $matching_class_name) {
72 $map[$matching_class_name] = $get_name($matching_class_name, HelpScreenId::class);
73 }
74
75 // Check for duplicates
76 $check = array_filter(array_diff_assoc($map, array_unique($map)), function ($v): bool {
77 return !is_null($v);
78 });
79 if ($check !== []) {
80 throw new Setup\UnachievableException("Duplicate screen ids found: " . implode(', ', $check));
81 }
82
83 return new Setup\Artifact\ArrayArtifact($map);
84 }
85}
$check
Definition: buildRTE.php:81
An artifact is some file that is build on demand per installation and is not shipped with the ILIAS s...
Definition: Artifact.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...