ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilResourceStorageFlavourArtifact.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29
35{
36 public function getArtifactName(): string
37 {
38 return "flavour_data";
39 }
40
41
42 public function build(): Artifact
43 {
44 $machines = (new DefaultMachines())->get();
45
46 $finder = new ImplementationOfInterfaceFinder();
47
48 foreach ($finder->getMatchingClassNames(FlavourMachine::class) as $machine_name) {
50 $machine = new $machine_name();
51 $machine_id = $machine->getId();
52
53 if ($machine_name === $machine_id) {
54 throw new LogicException(
55 "PLEASE beware that class-related magic constants are not recommended. Altering the implementation-name may result in lost flavours."
56 );
57 }
58
59 if (64 < strlen($machine_id)) {
60 throw new LogicException("ID of machine '$machine_name' exceeds 64 characters.");
61 }
62
63 if (isset($machines[$machine_id]) && $machines[$machine_id] !== $machine_name) {
64 throw new LogicException(
65 "Machine '$default_machine_ids[$machine_id]' and '$machine_name' implement the same ID ($machine_id)."
66 );
67 }
68
69 $machines[$machine_id] = $machine_name;
70 }
71
72 $definitions = (new DefaultDefinitions())->get();
73
74 foreach ($finder->getMatchingClassNames(FlavourDefinition::class) as $definition_name) {
77 // create instance without calling constructor using reflection class
78 try {
79 $reflection = new ReflectionClass($definition_name);
80 $definition = $reflection->newInstanceWithoutConstructor();
81 $definition_id = $definition->getId();
82 } catch (ReflectionException) {
83 continue;
84 }
85
86
87 if ($definition_name === $definition_id) {
88 throw new LogicException(
89 "PLEASE beware that class-related magic constants are not recommended. Altering the implementation-name may result in lost flavours."
90 );
91 }
92
93 if (64 < strlen((string) $definition_id)) {
94 throw new LogicException("ID of definition '$definition_name' exceeds 64 characters.");
95 }
96
97 if (isset($definitions[$definition_id]) && $definitions[$definition_id] !== $definition_name) {
98 throw new LogicException(
99 "Definition '$definitions[$definition_id]' and '$definition_name' implement the same ID ($definition_id)."
100 );
101 }
102
103 $definitions[$definition_id] = $definition_name;
104 }
105
106 return new ArrayArtifact([
107 'machines' => $machines,
108 'definitions' => $definitions
109 ]);
110 }
111}
An array as an artifact.
This is an objective to build some artifact.
getArtifactName()
Get the filename where the builder wants to put its artifact.
An artifact is some file that is build on demand per installation and is not shipped with the ILIAS s...
Definition: Artifact.php:28