From 7b70ee111f7024a4fa739fcee477aaca0fde7fe5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 4 Oct 2023 18:00:54 +0900 Subject: [PATCH] refactor: delete duplicate codes for Composer loading --- system/Autoloader/Autoloader.php | 14 +++++++++----- system/bootstrap.php | 14 -------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index dcddec1d2976..ecfd92b5ef8b 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -124,17 +124,21 @@ public function initialize(Autoload $config, Modules $modules) } if (is_file(COMPOSER_PATH)) { - $this->loadComposerInfo($modules); + $this->loadComposerAutoloader($modules); } return $this; } - private function loadComposerInfo(Modules $modules): void + private function loadComposerAutoloader(Modules $modules): void { - /** - * @var ClassLoader $composer - */ + // The path to the vendor directory. + // We do not want to enforce this, so set the constant if Composer was used. + if (! defined('VENDORPATH')) { + define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR); + } + + /** @var ClassLoader $composer */ $composer = include COMPOSER_PATH; $this->loadComposerClassmap($composer); diff --git a/system/bootstrap.php b/system/bootstrap.php index 41736590a927..5d2ca0b225c3 100644 --- a/system/bootstrap.php +++ b/system/bootstrap.php @@ -104,17 +104,3 @@ // Initialize and register the loader with the SPL autoloader stack. Services::autoloader()->initialize(new Autoload(), new Modules())->register(); Services::autoloader()->loadHelpers(); - -// Now load Composer's if it's available -if (is_file(COMPOSER_PATH)) { - /* - * The path to the vendor directory. - * - * We do not want to enforce this, so set the constant if Composer was used. - */ - if (! defined('VENDORPATH')) { - define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR); - } - - require_once COMPOSER_PATH; -}