harmonize My class

This commit is contained in:
Jean-Christian Paul Denis 2023-05-08 10:18:43 +02:00
parent 4c01df6338
commit a4cfc8a29a
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
3 changed files with 22 additions and 20 deletions

View File

@ -10,7 +10,7 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
return null; return null;
} }
@ -22,9 +22,9 @@ $this->registerModule(
[ [
'requires' => [['core', '2.26']], 'requires' => [['core', '2.26']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_USAGE, dcCore::app()->auth::PERMISSION_USAGE,
dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
dcAuth::PERMISSION_ADMIN, dcCore::app()->auth::PERMISSION_ADMIN,
]), ]),
'priority' => 2, 'priority' => 2,
'type' => 'plugin', 'type' => 'plugin',

View File

@ -37,7 +37,7 @@ class Frontend extends dcNsProcess
return false; return false;
} }
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::root(), 'default-templates', 'tpl'])); dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', 'tpl']));
dcCore::app()->tpl->addBlock('activityReports', [Template::class, 'activityReports']); dcCore::app()->tpl->addBlock('activityReports', [Template::class, 'activityReports']);
dcCore::app()->tpl->addValue('activityReportFeedID', [Template::class, 'activityReportFeedID']); dcCore::app()->tpl->addValue('activityReportFeedID', [Template::class, 'activityReportFeedID']);

View File

@ -17,13 +17,10 @@ namespace Dotclear\Plugin\activityReport;
use dcCore; use dcCore;
/** /**
* Module definitions * This module definitions.
*/ */
class My class My
{ {
/** @var string Required php version */
public const PHP_MIN = '8.1';
/** @var string Activity database table name */ /** @var string Activity database table name */
public const ACTIVITY_TABLE_NAME = 'activity'; public const ACTIVITY_TABLE_NAME = 'activity';
@ -33,6 +30,9 @@ class My
/** @var int Incremental version by breaking changes */ /** @var int Incremental version by breaking changes */
public const COMPATIBILITY_VERSION = 3; public const COMPATIBILITY_VERSION = 3;
/** @var string Required php version */
public const PHP_MIN = '7.4';
/** /**
* This module id. * This module id.
*/ */
@ -46,17 +46,27 @@ class My
*/ */
public static function name(): string public static function name(): string
{ {
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name')); $name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
return __(is_string($name) ? $name : self::id());
} }
/** /**
* This module root. * This module path.
*/ */
public static function root(): string public static function path(): string
{ {
return dirname(__DIR__); return dirname(__DIR__);
} }
/**
* Check this module PHP version compliant.
*/
public static function phpCompliant(): bool
{
return version_compare(phpversion(), self::PHP_MIN, '>=');
}
/** /**
* Check is module is trully installed. * Check is module is trully installed.
* *
@ -66,12 +76,4 @@ class My
{ {
return dcCore::app()->getVersion(self::id()) == dcCore::app()->plugins->moduleInfo(self::id(), 'version'); return dcCore::app()->getVersion(self::id()) == dcCore::app()->plugins->moduleInfo(self::id(), 'version');
} }
/**
* Check php version.
*/
public static function phpCompliant(): bool
{
return version_compare(phpversion(), self::PHP_MIN, '>=');
}
} }