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