diff --git a/composer.local.0.finc.json b/composer.local.0.finc.json index bba74ca4bd2c335ff92d1a673c59efe74b464260..92cc3f7bbfa06e0e9dca062c5bbbae0ab3f1a64c 100644 --- a/composer.local.0.finc.json +++ b/composer.local.0.finc.json @@ -1,13 +1,24 @@ { + "autoload": { + "classmap": ["devops/composer/modules.php"] + }, "require": { "finc/rules-evaluator": "0.0.3", "sabre/vobject": "3.5.3", "symfony/filesystem": "^3.4" }, "scripts": { - "post-install-cmd": "@copy-themes-force", - "post-update-cmd": "@copy-themes-force", + "post-install-cmd": ["@copy-themes-force", "@dump-modules"], + "post-update-cmd": ["@copy-themes-force", "@dump-modules"], "phpcs-finc": "vendor/bin/phpcs --standard=tests/finc/phpcs.xml", - "copy-themes-force": "php devops/composer/themes.php --force" + "copy-themes-force": "php devops/composer/themes.php --force", + "dump-modules": "ComposerEventHandlers\\Modules::dump" + }, + "extra": { + "vufind": { + "modules": [ + "finc" + ] + } } } \ No newline at end of file diff --git a/config/application.config.php b/config/application.config.php index b03a2416f9c369307c570a8e4f31db52cac6197c..204091ce3d179a988235592bc255132f1b698621 100644 --- a/config/application.config.php +++ b/config/application.config.php @@ -1,5 +1,7 @@ <?php +use ComposerEventHandlers\Modules; + // Set up modules: $modules = [ 'Zend\Form', 'Zend\Router', 'ZfcRbac', @@ -22,6 +24,8 @@ if ($localModules = getenv('VUFIND_LOCAL_MODULES')) { } } +array_push($modules, ...Modules::get()); + // Set up cache directory (be sure to keep separate cache for CLI vs. web and // to account for potentially variant environment settings): $baseDir = ($local = getenv('VUFIND_LOCAL_DIR')) ? $local : 'data'; diff --git a/devops/composer/modules.php b/devops/composer/modules.php new file mode 100644 index 0000000000000000000000000000000000000000..2d2f99618c3e7a5dd30b9ec5a186cac51d21530c --- /dev/null +++ b/devops/composer/modules.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright (C) 2019 Leipzig University Library + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license https://opensource.org/licenses/GPL-3.0 GNU GPLv3 + */ + +namespace ComposerEventHandlers; + +use Composer\Script\Event; + +class Modules +{ + private const PATH = __DIR__ . '/../../data/cache/modules.php'; + + public static function dump(Event $event) + { + /** @noinspection PhpUndefinedMethodInspection */ + $extra = $event->getComposer()->getPackage()->getExtra(); + $modules = var_export($extra['vufind']['modules'] ?? [], true); + file_put_contents(self::PATH, "<?php\nreturn $modules;\n"); + } + + public static function get(): array + { + /** @noinspection PhpIncludeInspection */ + return require self::PATH; + } +} +