forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
!/component/ILIAS | ||
|
||
# Generated Files | ||
/artifacts | ||
/ilias.ini.php | ||
/ilias.log | ||
/db_template_writer.php | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php"); | ||
|
||
echo <<<INFO | ||
Hello there. | ||
This builds the bootstrap of ILIAS by reading all components and resolving the | ||
dependencies. If you want to use custom directives to resolve ambiguous dependencies, | ||
call this script with a parameter pointing a file defining the resolution. | ||
INFO; | ||
|
||
if (isset($argv[1])) { | ||
$resolution_file = $argv[1]; | ||
} else { | ||
$resolution_file = realpath(__DIR__ . "/../dependency_resolution.php"); | ||
} | ||
|
||
if (!file_exists($resolution_file)) { | ||
die("Cannot find resolution file at {$resolution_file}.\n"); | ||
} | ||
|
||
$reader = new ILIAS\Component\Dependencies\Reader(); | ||
$resolver = new ILIAS\Component\Dependencies\Resolver(); | ||
$renderer = new ILIAS\Component\Dependencies\Renderer(); | ||
|
||
$component_info = []; | ||
|
||
$vendors = new \DirectoryIterator(realpath(__DIR__ . "/../components")); | ||
echo "Reading Vendors from \"./components\"...\n"; | ||
foreach ($vendors as $vendor) { | ||
if (str_starts_with($vendor->getFilename(), ".")) { | ||
continue; | ||
} | ||
if (!$vendor->isDir()) { | ||
echo " unexpected non-directory: {$vendor->getPathName()}\n"; | ||
continue; | ||
} | ||
echo " Reading Components from Vendor \"{$vendor->getFilename()}\"...\n"; | ||
$components = new \DirectoryIterator($vendor->getPathName()); | ||
foreach ($components as $component) { | ||
if (str_starts_with($component->getFilename(), ".")) { | ||
continue; | ||
} | ||
if (!$vendor->isDir()) { | ||
echo " unexpected non-directory: {$component->getPathName()}\n"; | ||
continue; | ||
} | ||
if (!file_exists($component->getPathName() . "/Component.php")) { | ||
echo " expected \"Component.php\" in {$component->getPathName()}\n"; | ||
continue; | ||
} | ||
require_once($component->getPathName() . "/Component.php"); | ||
$component_name = $vendor->getFilename() . "\\" . $component->getFileName(); | ||
echo " Reading Component \"$component_name\"...\n"; | ||
$component_info[] = $reader->read(new $component_name()); | ||
} | ||
} | ||
|
||
echo "Resolving Dependency using {$resolution_file}...\n"; | ||
$disambiguation = require_once($resolution_file); | ||
|
||
$component_info = $resolver->resolveDependencies($disambiguation, ...$component_info); | ||
|
||
echo "Writing bootstrap to artifacts/bootstrap.php\n"; | ||
|
||
$bootstrap = $renderer->render(...$component_info); | ||
if (!is_dir(__DIR__ . "/../artifacts")) { | ||
mkdir(__DIR__ . "/../artifacts", 0755, true); | ||
} | ||
file_put_contents(__DIR__ . "/../artifacts/bootstrap.php", $bootstrap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
// This is the default resolution for ambiguous dependencies of components in | ||
// Standard ILIAS. | ||
// | ||
// The structure is as such: keys are components that use services ("dependant") | ||
// that need disambiguation, the value for each dependant is an array where the key | ||
// is the definition ("dependency") and the value is the implementation | ||
// ("implementation") to be used. | ||
// | ||
// The entry "*" for the dependant will define fallbacks to be used for all components | ||
// that have no explicit disambiguation. | ||
|
||
return [ | ||
"*" => [] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters