From 1c98dbbbcf372f9417ef96c0d23f925ef974d1eb Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 31 Dec 2015 18:04:59 +0100 Subject: [PATCH] Restructure --- ApplicationAbstract.php | 8 ++++++++ Log/FileLogger.php | 2 -- Message/RequestDestination.php | 32 ++++++++++++++++---------------- Module/ModuleAbstract.php | 6 +++--- Module/ModuleManager.php | 12 +++++++----- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/ApplicationAbstract.php b/ApplicationAbstract.php index 5505e8c4d..d99810590 100644 --- a/ApplicationAbstract.php +++ b/ApplicationAbstract.php @@ -29,6 +29,14 @@ namespace phpOMS; class ApplicationAbstract { + /** + * App name. + * + * @var \phpOMS\DataStorage\Database\Pool + * @since 1.0.0 + */ + public $appName = ''; + /** * Database object. * diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 760eec463..52bbdb1e4 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -16,8 +16,6 @@ namespace phpOMS\Log; use phpOMS\Datatypes\Exception\InvalidEnumValue; -use phpOMS\Message\Http\Rest; -use phpOMS\Message\RequestMethod; use phpOMS\System\FilePathException; use phpOMS\Validation\Validator; diff --git a/Message/RequestDestination.php b/Message/RequestDestination.php index ea0b2ec3c..7b39125ae 100644 --- a/Message/RequestDestination.php +++ b/Message/RequestDestination.php @@ -32,21 +32,21 @@ use phpOMS\Datatypes\Enum; */ abstract class RequestDestination extends Enum { - const WEBSITE = 'website'; /* Website */ - const API = 'api'; /* API */ - const SHOP = 'shop'; /* Shop */ - const BACKEND = 'backend'; /* Backend */ - const STATICP = 'static'; /* Static content */ - const FORUM = 'forum'; /* Forum */ - const TICKET = 'ticket'; /* ???? */ - const SUPPORT = 'support'; /* Support center */ - const SURVEY = 'survey'; /* Survey page */ - const BLOG = 'blog'; /* Blog */ - const CHART = 'chart'; /* Chart view */ - const CALENDAR = 'calendar'; /* Calendar */ - const PROFILE = 'profile'; /* User profile page */ - const CHAT = 'chat'; /* Chat page */ - const GALLERY = 'gallery'; /* Chat page */ - const REPORTER = 'reporter'; /* Reporter page */ + const WEBSITE = 'Website'; /* Website */ + const API = 'Api'; /* API */ + const SHOP = 'Shop'; /* Shop */ + const BACKEND = 'Backend'; /* Backend */ + const STATICP = 'Static'; /* Static content */ + const FORUM = 'Forum'; /* Forum */ + const TICKET = 'Ticket'; /* ???? */ + const SUPPORT = 'Support'; /* Support center */ + const SURVEY = 'Survey'; /* Survey page */ + const BLOG = 'Blog'; /* Blog */ + const CHART = 'Chart'; /* Chart view */ + const CALENDAR = 'Calendar'; /* Calendar */ + const PROFILE = 'Profile'; /* User profile page */ + const CHAT = 'Chat'; /* Chat page */ + const GALLERY = 'Gallery'; /* Chat page */ + const REPORTER = 'Reporter'; /* Reporter page */ // This or let api handle this const GUI = 'gui'; /* Request GUI elements */ } diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index 3cd20c42b..8526eaf7f 100644 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -53,7 +53,7 @@ abstract class ModuleAbstract * @var \string * @since 1.0.0 */ - protected static $module = ''; + const MODULE_NAME = ''; /** * Localization files. @@ -133,7 +133,7 @@ abstract class ModuleAbstract $lang = []; if (isset(static::$localization[$destination])) { foreach (static::$localization[$destination] as $file) { - if(($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php')) === false) { + if(($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) === false) { throw new FilePathException($oldPath); } @@ -170,7 +170,7 @@ abstract class ModuleAbstract public function getName() : \string { /** @noinspection PhpUndefinedFieldInspection */ - return static::$module; + return static::MODULE_NAME; } /** diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 46190e387..783e0de9f 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -55,7 +55,7 @@ class ModuleManager private $running = []; /** - * FileCache instance. + * Application instance. * * @var ApplicationAbstract * @since 1.0.0 @@ -200,7 +200,7 @@ class ModuleManager $lang = []; if (isset($files[5])) { foreach ($files[5] as $module) { - $lang[] = '/Modules/' . $module['module_load_from'] . '/Theme/lang/' . $module['module_load_file']; + $lang[] = '/Modules/' . $module['module_load_from'] . '/Theme/' . $this->app->appName . '/Lang/' . $module['module_load_file']; } } @@ -353,6 +353,7 @@ class ModuleManager } $class = '\\Modules\\' . $module . '\\Admin\\Installer'; + /** @var $class InstallerAbstract */ $class::install($this->app->dbPool, $info); // TODO: change this @@ -409,6 +410,7 @@ class ModuleManager { if (file_exists(self::MODULE_PATH . '/' . $from . '/Admin/Install/' . $for . '.php')) { $class = '\\Modules\\' . $from . '\\Admin\\Install\\' . $for; + /** @var $class InstallerAbstract */ $class::install($this->app->dbPool, null); } } @@ -465,9 +467,9 @@ class ModuleManager */ public function loadLanguage(\string $language, \string $destination) { - foreach ($this->running as $name => $m) { - /** @var ModuleAbstract $m */ - $file = $m->getLocalization($language, $destination); + foreach ($this->running as $name => $module) { + /** @var ModuleAbstract $module */ + $file = $module->getLocalization($language, $destination); if (!empty($file)) { $this->app->l11nManager->loadLanguage($language, $name, $file); }