Skip to content

Commit

Permalink
Made MAHO_ROOT_DIR constant available globally (OpenMage#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmewes authored Sep 19, 2024
1 parent 06faa32 commit 38cdb38
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/code/core/Mage/Core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ function mahoFindFileInIncludePath(string $relativePath): string|false
function mahoListDirectories($path)
{
list($packages, $packageDirectories) = mahoGetComposerInstallationData();
if (!defined('MAGENTO_ROOT')) {
Mage::throwException('MAGENTO_ROOT constant is not defined.');
if (!defined('MAHO_ROOT_DIR')) {
Mage::throwException('MAHO_ROOT_DIR constant is not defined.');
}

foreach ($packages as $package) {
Expand All @@ -376,7 +376,7 @@ function mahoListDirectories($path)
$path = ltrim($path, '/');

$results = [];
array_unshift($packageDirectories, MAGENTO_ROOT);
array_unshift($packageDirectories, MAHO_ROOT_DIR);
foreach ($packageDirectories as $packageDirectory) {
$tmpList = glob($packageDirectory . DS . $path . '/*', GLOB_ONLYDIR);
foreach ($tmpList as $folder) {
Expand Down
12 changes: 7 additions & 5 deletions public/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/** @deprecated Use MAHO_ROOT_DIR instead. */
define('MAGENTO_ROOT', dirname(__DIR__));
define('MAHO_ROOT_DIR', dirname(__DIR__));

if (file_exists(MAGENTO_ROOT . DIRECTORY_SEPARATOR . 'app/bootstrap.php')) {
require MAGENTO_ROOT . '/app/bootstrap.php';
require MAGENTO_ROOT . '/app/Mage.php';
if (file_exists(MAHO_ROOT_DIR . DIRECTORY_SEPARATOR . 'app/bootstrap.php')) {
require MAHO_ROOT_DIR . '/app/bootstrap.php';
require MAHO_ROOT_DIR . '/app/Mage.php';
} else {
require MAGENTO_ROOT . '/vendor/mahocommerce/maho/app/bootstrap.php';
require MAGENTO_ROOT . '/vendor/mahocommerce/maho/app/Mage.php';
require MAHO_ROOT_DIR . '/vendor/mahocommerce/maho/app/bootstrap.php';
require MAHO_ROOT_DIR . '/vendor/mahocommerce/maho/app/Mage.php';
}

if (!Mage::isInstalled()) {
Expand Down
12 changes: 7 additions & 5 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/** @deprecated Use MAHO_ROOT_DIR instead. */
define('MAGENTO_ROOT', dirname(__DIR__));
define('MAHO_ROOT_DIR', dirname(__DIR__));

if (file_exists(MAGENTO_ROOT . DIRECTORY_SEPARATOR . 'app/bootstrap.php')) {
require MAGENTO_ROOT . '/app/bootstrap.php';
require MAGENTO_ROOT . '/app/Mage.php';
if (file_exists(MAHO_ROOT_DIR . DIRECTORY_SEPARATOR . 'app/bootstrap.php')) {
require MAHO_ROOT_DIR . '/app/bootstrap.php';
require MAHO_ROOT_DIR . '/app/Mage.php';
} else {
require MAGENTO_ROOT . '/vendor/mahocommerce/maho/app/bootstrap.php';
require MAGENTO_ROOT . '/vendor/mahocommerce/maho/app/Mage.php';
require MAHO_ROOT_DIR . '/vendor/mahocommerce/maho/app/bootstrap.php';
require MAHO_ROOT_DIR . '/vendor/mahocommerce/maho/app/Mage.php';
}

#Varien_Profiler::enable();
Expand Down

0 comments on commit 38cdb38

Please sign in to comment.