Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Fixed config file loading for phar and non-phar
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjaap committed Jul 12, 2018
1 parent 2f3136d commit e8b8243
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Elgentos/Masquerade/Console/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ private function getFakerInstance($columnName, $columnData)
return $this->fakerInstances[$columnName];
}

/**
* @return bool
*/
private function isPhar() {
return strlen(Phar::running()) > 0 ? true : false;
}

/**
* @param $platformName
* @return array
Expand All @@ -280,16 +287,17 @@ private function getConfigFiles($platformName)
{
// Unfortunately, glob() does not work when using a phar and hassankhan/config relies on glob.
// Therefore, we have to scan the dir ourselves when using the phar
$configDir = 'config/' . $platformName;
if (file_exists($configDir) && is_dir($configDir)) {
$files = array_slice(scandir('config/magento2'), 2);

return array_map(function ($file) {
return 'phar://masquerade.phar/src/' . $file;
}, $files);
if ($this->isPhar()) {
$configDir = 'phar://masquerade.phar/src/config/' . $platformName;
} else {
$configDir = __DIR__ . '/../../../config/' . $platformName;
}

return [];
$files = array_slice(scandir($configDir), 2);

return array_map(function ($file) use ($configDir) {
return $configDir . '/' . $file;
}, $files);
}

private function calculateRedrawFrequency($totalRows)
Expand Down

0 comments on commit e8b8243

Please sign in to comment.