use Dotclear autoloader
parent
dc4980d9aa
commit
52b16c0e3f
|
@ -79,7 +79,7 @@ abstract class Action
|
||||||
*/
|
*/
|
||||||
final public function __construct()
|
final public function __construct()
|
||||||
{
|
{
|
||||||
$this->class_name = str_replace(Utils::getActionsNS(), '', get_called_class());
|
$this->class_name = str_replace(__NAMESPACE__ . '\\Module\\', '', get_called_class());
|
||||||
$this->module = new dcModuleDefine('undefined');
|
$this->module = new dcModuleDefine('undefined');
|
||||||
|
|
||||||
$settings = dcCore::app()->blog->settings->get(My::id())->get('settings_' . $this->class_name);
|
$settings = dcCore::app()->blog->settings->get(My::id())->get('settings_' . $this->class_name);
|
||||||
|
|
|
@ -20,7 +20,6 @@ use dcPage;
|
||||||
use dcFavorites;
|
use dcFavorites;
|
||||||
use dcNsProcess;
|
use dcNsProcess;
|
||||||
use Dotclear\Helper\File\Files;
|
use Dotclear\Helper\File\Files;
|
||||||
use Dotclear\Helper\Clearbricks;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve admin class
|
* Improve admin class
|
||||||
|
@ -65,10 +64,14 @@ class Backend extends dcNsProcess
|
||||||
dcCore::app()->auth->isSuperAdmin()
|
dcCore::app()->auth->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach (Files::scandir(Utils::getActionsDir()) as $file) {
|
$dir = __DIR__ . DIRECTORY_SEPARATOR . 'module' . DIRECTORY_SEPARATOR;
|
||||||
if (is_file(Utils::getActionsDir() . $file) && '.php' == substr($file, -4)) {
|
$ns = __NAMESPACE__ . '\\Module\\';
|
||||||
Clearbricks::lib()->autoload([Utils::getActionsNS() . substr($file, 0, -4) => Utils::getActionsDir() . $file]);
|
|
||||||
dcCore::app()->addBehavior('improveAddAction', [Utils::getActionsNS() . substr($file, 0, -4), 'create']); /* @phpstan-ignore-line */
|
dcCore::app()->autoload->addNamespace($ns, $dir);
|
||||||
|
|
||||||
|
foreach (Files::scandir($dir) as $file) {
|
||||||
|
if (str_ends_with($file, '.php') && is_file($dir . $file)) {
|
||||||
|
dcCore::app()->addBehavior('improveAddAction', [$ns . basename($file, '.php'), 'create']); /* @phpstan-ignore-line */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @brief improve, a plugin for Dotclear 2
|
|
||||||
*
|
|
||||||
* @package Dotclear
|
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis and contributors
|
|
||||||
*
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Dotclear\Plugin\improve;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Improve utils class
|
|
||||||
*/
|
|
||||||
class Utils
|
|
||||||
{
|
|
||||||
public static function getActionsDir(): string
|
|
||||||
{
|
|
||||||
return __DIR__ . '/module/';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getActionsNS(): string
|
|
||||||
{
|
|
||||||
return __NAMESPACE__ . '\\Module\\';
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue