Skip to content

Commit

Permalink
Автолоад, если используется namespace с префиксом icms,
Browse files Browse the repository at this point in the history
мелкий рефакторинг.
  • Loading branch information
fuzegit committed Jun 28, 2022
1 parent c76e85f commit 2f048c3
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 95 deletions.
15 changes: 14 additions & 1 deletion system/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ function autoLoadCoreClass($_class_name){
)
);
$class_file = 'system/controllers/' . $controller . $path . '/model.php';

} else

if (strpos($class_name, 'icms\\') === 0) {

$paths = explode('\\', $class_name);

// Удаляем префикс icms
// он для отделения namespace-ов от других
unset($paths[0]);

$file_name = array_pop($paths);

$class_file = 'system/' . implode('/', $paths) . '/' . $file_name . '.php';
}

if (!$class_file){ return false; }
Expand All @@ -44,5 +58,4 @@ function autoLoadCoreClass($_class_name){
include_once PATH . '/' . $class_file;

return true;

}
1 change: 1 addition & 0 deletions system/controllers/content/widgets/author/widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function run() {

return [
'sys_fields' => $this->getSystemFields($profile, $ctype),
'item' => $item,
'jsonld' => $jsonld,
'ctype' => $ctype,
'profile' => $profile,
Expand Down
Loading

0 comments on commit 2f048c3

Please sign in to comment.