Skip to content

Commit

Permalink
Merge pull request #8004 from kenjis/refactor-composer-loading
Browse files Browse the repository at this point in the history
refactor: delete duplicate code for Composer loading
  • Loading branch information
kenjis authored Oct 10, 2023
2 parents ff5185a + 7b70ee1 commit 815b802
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
14 changes: 9 additions & 5 deletions system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 0 additions & 14 deletions system/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 815b802

Please sign in to comment.