mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Removing ROOT_PATH
This commit is contained in:
parent
ed909b224c
commit
b1a8e92de7
|
|
@ -62,7 +62,20 @@ class InfoManager
|
|||
*/
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->path = realpath($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn
|
||||
*/
|
||||
public function getPath() : string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ class InstallerAbstract
|
|||
private static function initRoutes(string $routePath, InfoManager $info) /* : void */
|
||||
{
|
||||
// todo: maybe use static::__DIR__ ?
|
||||
$directories = new Directory(ROOT_PATH . '/Modules/' . $info->getDirectory() . '/Admin/Routes');
|
||||
$directories = new Directory(dirname($info->getPath()) . '/Modules/' . $info->getDirectory() . '/Admin/Routes');
|
||||
|
||||
foreach ($directories as $key => $subdir) {
|
||||
if ($subdir instanceof Directory) {
|
||||
|
|
|
|||
|
|
@ -39,14 +39,6 @@ use phpOMS\System\File\PathException;
|
|||
class ModuleManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Module path.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
/* public */ const MODULE_PATH = __DIR__ . '/../../Modules';
|
||||
|
||||
/**
|
||||
* All modules that are running on this uri.
|
||||
*
|
||||
|
|
@ -103,9 +95,10 @@ class ModuleManager
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __construct(ApplicationAbstract $app)
|
||||
public function __construct(ApplicationAbstract $app, string $modulePath = '')
|
||||
{
|
||||
$this->app = $app;
|
||||
$modulePath = $modulePath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -242,12 +235,12 @@ class ModuleManager
|
|||
public static function getAllModules() : array
|
||||
{
|
||||
if (!isset(self::$all)) {
|
||||
chdir(self::MODULE_PATH);
|
||||
chdir($this->modulePath);
|
||||
$files = glob('*', GLOB_ONLYDIR);
|
||||
$c = count($files);
|
||||
|
||||
for ($i = 0; $i < $c; $i++) {
|
||||
$path = self::MODULE_PATH . '/' . $files[$i] . '/info.json';
|
||||
$path = $this->modulePath . '/' . $files[$i] . '/info.json';
|
||||
|
||||
if (!file_exists($path)) {
|
||||
continue;
|
||||
|
|
@ -368,7 +361,7 @@ class ModuleManager
|
|||
throw new \Exception('Module installer does not exist');
|
||||
}
|
||||
|
||||
$class::reInit(ROOT_PATH, $info);
|
||||
$class::reInit($this->modulePath, $info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -389,7 +382,7 @@ class ModuleManager
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!file_exists(self::MODULE_PATH . '/' . $module . '/Admin/Installer.php')) {
|
||||
if (!file_exists($this->modulePath . '/' . $module . '/Admin/Installer.php')) {
|
||||
// todo download;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -463,7 +456,7 @@ class ModuleManager
|
|||
throw new \Exception('Module installer does not exist');
|
||||
}
|
||||
|
||||
$class::install(ROOT_PATH, $this->app->dbPool, $info);
|
||||
$class::install($this->modulePath, $this->app->dbPool, $info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -526,7 +519,7 @@ class ModuleManager
|
|||
*/
|
||||
private function loadInfo(string $module) : InfoManager
|
||||
{
|
||||
$path = realpath($oldPath = self::MODULE_PATH . '/' . $module . '/' . 'info.json');
|
||||
$path = realpath($oldPath = $this->modulePath . '/' . $module . '/' . 'info.json');
|
||||
|
||||
if ($path === false) {
|
||||
throw new PathException($oldPath);
|
||||
|
|
@ -576,10 +569,10 @@ class ModuleManager
|
|||
*/
|
||||
public function installProviding(string $from, string $for) /* : void */
|
||||
{
|
||||
if (file_exists(self::MODULE_PATH . '/' . $from . '/Admin/Install/' . $for . '.php')) {
|
||||
if (file_exists($this->modulePath . '/' . $from . '/Admin/Install/' . $for . '.php')) {
|
||||
$class = '\\Modules\\' . $from . '\\Admin\\Install\\' . $for;
|
||||
/** @var $class InstallerAbstract */
|
||||
$class::install(ROOT_PATH, $this->app->dbPool, null);
|
||||
$class::install($this->modulePath, $this->app->dbPool, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user