improve/inc/Utils.php

62 lines
1.4 KiB
PHP
Raw Normal View History

2021-09-01 23:35:23 +00:00
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
2021-09-01 23:35:23 +00:00
* @package Dotclear
2021-09-06 21:36:50 +00:00
* @subpackage Plugin
*
2021-09-01 23:35:23 +00:00
* @author Jean-Christian Denis and contributors
*
2021-09-01 23:35:23 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
2022-12-21 14:41:27 +00:00
namespace Dotclear\Plugin\improve;
use Clearbricks;
/**
* Improve prepend class
*
* Manage autoload and some action module helpers.
*/
2022-12-21 14:51:43 +00:00
class Prepend
{
2023-01-16 22:49:39 +00:00
protected static $init = false;
2022-12-21 14:41:27 +00:00
public static function init(): bool
{
self::$init = defined('DC_RC_PATH') && defined('DC_CONTEXT_ADMIN');
return self::$init;
}
public static function process()
{
2022-12-21 14:41:27 +00:00
if (!self::$init) {
return false;
}
// Core plugin class
foreach (['Core', 'Action', 'Module'] as $class) {
2023-01-07 15:27:46 +00:00
Clearbricks::lib()->autoload([__NAMESPACE__ . '\\' . $class => implode(DIRECTORY_SEPARATOR, [__DIR__, 'core', $class . '.php'])]);
2022-12-21 14:41:27 +00:00
}
// Dotclear plugin class
foreach (['Admin', 'Config', 'Install', 'Manage', 'Prepend', 'Uninstall'] as $class) {
2023-01-07 15:27:46 +00:00
Clearbricks::lib()->autoload([__NAMESPACE__ . '\\' . $class => implode(DIRECTORY_SEPARATOR, [__DIR__, $class . '.php'])]);
}
}
public static function getActionsDir(): string
{
2022-12-21 14:41:27 +00:00
return __DIR__ . '/module/';
}
2021-09-01 23:35:23 +00:00
public static function getActionsNS(): string
{
2023-01-07 15:27:46 +00:00
return __NAMESPACE__ . '\\Module\\';
}
}