Skip to content

Commit

Permalink
Названия деволтных контейнеров вынесены в параметры для возможности п…
Browse files Browse the repository at this point in the history
…ереопределения
  • Loading branch information
butschster committed Oct 31, 2015
1 parent 2a467bc commit 11508d7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/ModulesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ class ModulesLoader
*/
protected $shutdownCallbacks = [ ];

/**
* @var string
*/
protected $defaultContainerClass = '\\App\\DefaultModuleContainer';

/**
* @var string
*/
protected $applicationContainerClass = '\\App\\ModuleContainer';


/**
* @param array $modulesList
Expand Down Expand Up @@ -85,20 +95,20 @@ public function addModule($moduleName, $modulePath = null, $namespace = null, $m

$namespace = trim($namespace, '\\');

$defaultModuleClass = '\\App\\DefaultModuleContainer';

$customModuleClass = "\\$namespace\\ModuleContainer";

if ($moduleName == 'App') {
$customModuleClass = "\\App\\ModuleContainer";
$customModuleClass = $this->applicationContainerClass;
}

if (is_null($moduleContainerClass) or class_exists($customModuleClass)) {
$moduleContainerClass = $customModuleClass;
}

if ( ! class_exists($moduleContainerClass)) {
$moduleContainerClass = class_exists($defaultModuleClass) ? $defaultModuleClass : \KodiCMS\ModulesLoader\ModuleContainer::class;
$moduleContainerClass = class_exists($this->defaultContainerClass)
? $this->defaultContainerClass
: \KodiCMS\ModulesLoader\ModuleContainer::class;
}

$moduleContainer = new $moduleContainerClass($moduleName, $modulePath, $namespace);
Expand Down

0 comments on commit 11508d7

Please sign in to comment.