Skip to content

Commit 7b70ee1

Browse files
committed
refactor: delete duplicate codes for Composer loading
1 parent efb12a8 commit 7b70ee1

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

system/Autoloader/Autoloader.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,21 @@ public function initialize(Autoload $config, Modules $modules)
124124
}
125125

126126
if (is_file(COMPOSER_PATH)) {
127-
$this->loadComposerInfo($modules);
127+
$this->loadComposerAutoloader($modules);
128128
}
129129

130130
return $this;
131131
}
132132

133-
private function loadComposerInfo(Modules $modules): void
133+
private function loadComposerAutoloader(Modules $modules): void
134134
{
135-
/**
136-
* @var ClassLoader $composer
137-
*/
135+
// The path to the vendor directory.
136+
// We do not want to enforce this, so set the constant if Composer was used.
137+
if (! defined('VENDORPATH')) {
138+
define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR);
139+
}
140+
141+
/** @var ClassLoader $composer */
138142
$composer = include COMPOSER_PATH;
139143

140144
$this->loadComposerClassmap($composer);

system/bootstrap.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,3 @@
104104
// Initialize and register the loader with the SPL autoloader stack.
105105
Services::autoloader()->initialize(new Autoload(), new Modules())->register();
106106
Services::autoloader()->loadHelpers();
107-
108-
// Now load Composer's if it's available
109-
if (is_file(COMPOSER_PATH)) {
110-
/*
111-
* The path to the vendor directory.
112-
*
113-
* We do not want to enforce this, so set the constant if Composer was used.
114-
*/
115-
if (! defined('VENDORPATH')) {
116-
define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR);
117-
}
118-
119-
require_once COMPOSER_PATH;
120-
}

0 commit comments

Comments
 (0)