From 403ccaf8022f3b0f43a43e4b90894276fbe7d669 Mon Sep 17 00:00:00 2001 From: Sebastian Kehr <kehr@ub.uni-leipzig.de> Date: Fri, 6 Dec 2019 14:06:03 +0100 Subject: [PATCH] refs #16618 [master-v5] specify additional modules via composer configuration --- composer.local.0.finc.json | 17 +++++++++++--- config/application.config.php | 4 ++++ devops/composer/modules.php | 44 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 devops/composer/modules.php diff --git a/composer.local.0.finc.json b/composer.local.0.finc.json index bba74ca4bd2..92cc3f7bbfa 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 b03a2416f9c..204091ce3d1 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 00000000000..2d2f99618c3 --- /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; + } +} + -- GitLab