ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
build_bootstrap.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php");
22 
23 echo <<<INFO
24 Hello there.
25 
26 This builds the bootstrap of ILIAS by reading all components and resolving the
27 dependencies. If you want to use custom directives to resolve ambiguous dependencies,
28 call this script with a parameter pointing a file defining the resolution.
29 
30 
31 INFO;
32 
33 if (count($argv) < 3 || count($argv) % 2 != 1) {
34  die("php cli/build_bootstrap.php \$dependency_resolution \$name [\$another_dependency_resolution \$another_name ...]\n");
35 }
36 
37 array_shift($argv);
38 
40 
41 /******************************************************************************/
42 /* Read information from the Components */
43 /******************************************************************************/
44 
45 $component_info = [];
46 
47 $vendors = new \DirectoryIterator(realpath(__DIR__ . "/../components"));
48 echo "Reading Vendors from \"./components\"...\n";
49 foreach ($vendors as $vendor) {
50  if (str_starts_with($vendor->getFilename(), ".")) {
51  continue;
52  }
53  if (!$vendor->isDir()) {
54  echo " unexpected non-directory: {$vendor->getPathName()}\n";
55  continue;
56  }
57  echo " Reading Components from Vendor \"{$vendor->getFilename()}\"...\n";
58  $components = new \DirectoryIterator($vendor->getPathName());
59  foreach ($components as $component) {
60  if (str_starts_with($component->getFilename(), ".")) {
61  continue;
62  }
63  if (!$vendor->isDir()) {
64  echo " unexpected non-directory: {$component->getPathName()}\n";
65  continue;
66  }
67  if (!file_exists($component->getPathName() . "/" . $component->getFileName() . ".php")) {
68  echo " expected \"Component.php\" in {$component->getPathName()}\n";
69  continue;
70  }
71  require_once($component->getPathName() . "/" . $component->getFileName() . ".php");
72  $component_name = $vendor->getFilename() . "\\" . $component->getFileName();
73  echo " Reading Component \"$component_name\"...\n";
74  $component_info[] = $reader->read(new $component_name());
75  }
76 }
77 
78 /******************************************************************************/
79 /* Resolve and write dependencies for all bootstraps */
80 /******************************************************************************/
81 
84 
85 while (count($argv) > 0) {
86  $resolution_file = array_shift($argv);
87  $name = array_shift($argv);
88 
89  if (!file_exists($resolution_file)) {
90  die("Cannot find resolution file at {$resolution_file}.\n");
91  }
92 
93  echo "Resolving Dependency using {$resolution_file}...\n";
94  $disambiguation = require($resolution_file);
95 
96  foreach ($component_info as $ci) {
97  $ci->resetResolutions();
98  }
99  $component_info = $resolver->resolveDependencies($disambiguation, ...$component_info);
100 
101  echo "Writing bootstrap to artifacts/bootstrap_$name.php\n";
102 
103  $bootstrap = $renderer->render(...$component_info);
104  if (!is_dir(__DIR__ . "/../artifacts")) {
105  mkdir(__DIR__ . "/../artifacts", 0755, true);
106  }
107  file_put_contents(__DIR__ . "/../artifacts/bootstrap_$name.php", $bootstrap);
108 }
$renderer
Interface Observer Contains several chained tasks and infos about them.
$components
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
Definition: custom.php:33
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
to(\GdImage $image, ?int $quality=null)
Currently this is the only way to make a FileStream from a GD image resource.
foreach($components as $component) $resolver