fix nullsafe warnings
This commit is contained in:
parent
b6df3f2553
commit
93ec64c3ba
4 changed files with 31 additions and 12 deletions
|
@ -21,8 +21,9 @@ class Backend extends dcNsProcess
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = My::phpCompliant()
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
&& defined('DC_CONTEXT_ADMIN')
|
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
|
||||||
|
&& My::phpCompliant()
|
||||||
&& dcCore::app()->auth->isSuperAdmin()
|
&& dcCore::app()->auth->isSuperAdmin()
|
||||||
&& dcCore::app()->blog->settings->get(My::id())->get('active');
|
&& dcCore::app()->blog->settings->get(My::id())->get('active');
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class BackendBehaviors
|
||||||
|
|
||||||
public static function packmanBeforeCreatePackage(array $module): void
|
public static function packmanBeforeCreatePackage(array $module): void
|
||||||
{
|
{
|
||||||
if (!dcCore::app()->blog->settings->get(My::id())->get('packman')) {
|
if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get(My::id())->get('packman')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,10 @@ class BackendBehaviors
|
||||||
|
|
||||||
public static function modulesToolsHeaders(bool $is_plugin): string
|
public static function modulesToolsHeaders(bool $is_plugin): string
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
dcPage::jsJson('ts_copied', ['alert' => __('Copied to clipboard')]) .
|
dcPage::jsJson('ts_copied', ['alert' => __('Copied to clipboard')]) .
|
||||||
dcPage::jsModuleLoad(My::id() . '/js/backend.js') .
|
dcPage::jsModuleLoad(My::id() . '/js/backend.js') .
|
||||||
|
@ -68,16 +72,20 @@ class BackendBehaviors
|
||||||
|
|
||||||
public static function pluginsToolsTabsV2(): void
|
public static function pluginsToolsTabsV2(): void
|
||||||
{
|
{
|
||||||
self::modulesToolsTabs(dcCore::app()->plugins, explode(',', DC_DISTRIB_PLUGINS), dcCore::app()->adminurl->get('admin.plugins'));
|
self::modulesToolsTabs(dcCore::app()->plugins, explode(',', DC_DISTRIB_PLUGINS), (string) dcCore::app()->adminurl?->get('admin.plugins'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function themesToolsTabsV2(): void
|
public static function themesToolsTabsV2(): void
|
||||||
{
|
{
|
||||||
self::modulesToolsTabs(dcCore::app()->themes, explode(',', DC_DISTRIB_THEMES), dcCore::app()->adminurl->get('admin.blog.theme'));
|
self::modulesToolsTabs(dcCore::app()->themes, explode(',', DC_DISTRIB_THEMES), (string) dcCore::app()->adminurl?->get('admin.blog.theme'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function modulesToolsTabs(dcModules $modules, array $excludes, string $page_url): void
|
private static function modulesToolsTabs(dcModules $modules, array $excludes, string $page_url): void
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->adminurl) || is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$page_url .= '#' . My::id();
|
$page_url .= '#' . My::id();
|
||||||
$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
||||||
$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||||
|
@ -303,31 +311,31 @@ class BackendBehaviors
|
||||||
if (!$module->isDefined()) {
|
if (!$module->isDefined()) {
|
||||||
self::$failed[] = 'unknow module';
|
self::$failed[] = 'unknow module';
|
||||||
}
|
}
|
||||||
$rsp->id = $module->get('id');
|
$rsp->insertAttr('id', $module->get('id'));
|
||||||
|
|
||||||
# name
|
# name
|
||||||
if (empty($module->get('name'))) {
|
if (empty($module->get('name'))) {
|
||||||
self::$failed[] = 'no module name set in _define.php';
|
self::$failed[] = 'no module name set in _define.php';
|
||||||
}
|
}
|
||||||
$rsp->name($module->get('name'));
|
$rsp->insertNode(new XmlTag('name', $module->get('name')));
|
||||||
|
|
||||||
# version
|
# version
|
||||||
if (empty($module->get('version'))) {
|
if (empty($module->get('version'))) {
|
||||||
self::$failed[] = 'no module version set in _define.php';
|
self::$failed[] = 'no module version set in _define.php';
|
||||||
}
|
}
|
||||||
$rsp->version($module->get('version'));
|
$rsp->insertNode(new XmlTag('version', $module->get('version')));
|
||||||
|
|
||||||
# author
|
# author
|
||||||
if (empty($module->get('author'))) {
|
if (empty($module->get('author'))) {
|
||||||
self::$failed[] = 'no module author set in _define.php';
|
self::$failed[] = 'no module author set in _define.php';
|
||||||
}
|
}
|
||||||
$rsp->author($module->get('author'));
|
$rsp->insertNode(new XmlTag('author', $module->get('author')));
|
||||||
|
|
||||||
# desc
|
# desc
|
||||||
if (empty($module->get('desc'))) {
|
if (empty($module->get('desc'))) {
|
||||||
self::$failed[] = 'no module description set in _define.php';
|
self::$failed[] = 'no module description set in _define.php';
|
||||||
}
|
}
|
||||||
$rsp->desc($module->get('desc'));
|
$rsp->insertNode(new XmlTag('desc', $module->get('desc')));
|
||||||
|
|
||||||
# repository
|
# repository
|
||||||
if (empty($module->get('repository'))) {
|
if (empty($module->get('repository'))) {
|
||||||
|
@ -339,7 +347,7 @@ class BackendBehaviors
|
||||||
if (empty($file_pattern)) {
|
if (empty($file_pattern)) {
|
||||||
self::$failed[] = 'no zip file pattern set in Tweak Store configuration';
|
self::$failed[] = 'no zip file pattern set in Tweak Store configuration';
|
||||||
}
|
}
|
||||||
$rsp->file($file_pattern);
|
$rsp->insertNode(new XmlTag('file', $file_pattern));
|
||||||
|
|
||||||
# da dc_min or requires core
|
# da dc_min or requires core
|
||||||
if (!empty($module->get('requires')) && is_array($module->get('requires'))) {
|
if (!empty($module->get('requires')) && is_array($module->get('requires'))) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Config extends dcNsProcess
|
||||||
static::$init = My::phpCompliant()
|
static::$init = My::phpCompliant()
|
||||||
&& defined('DC_CONTEXT_ADMIN')
|
&& defined('DC_CONTEXT_ADMIN')
|
||||||
&& defined('DC_CONTEXT_MODULE')
|
&& defined('DC_CONTEXT_MODULE')
|
||||||
|
&& !is_null(dcCore::app()->auth)
|
||||||
&& dcCore::app()->auth->isSuperAdmin();
|
&& dcCore::app()->auth->isSuperAdmin();
|
||||||
|
|
||||||
return static::$init;
|
return static::$init;
|
||||||
|
@ -61,7 +62,7 @@ class Config extends dcNsProcess
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
__('Configuration successfully updated')
|
__('Configuration successfully updated')
|
||||||
);
|
);
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl?->redirect(
|
||||||
'admin.plugins',
|
'admin.plugins',
|
||||||
['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\tweakStores;
|
namespace Dotclear\Plugin\tweakStores;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
|
@ -32,6 +33,10 @@ class Settings
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
throw new Exception('blog is not set');
|
||||||
|
}
|
||||||
|
|
||||||
$s = dcCore::app()->blog->settings->get(My::id());
|
$s = dcCore::app()->blog->settings->get(My::id());
|
||||||
|
|
||||||
$this->active = (bool) ($s->get('active') ?? false);
|
$this->active = (bool) ($s->get('active') ?? false);
|
||||||
|
@ -54,6 +59,10 @@ class Settings
|
||||||
*/
|
*/
|
||||||
public function writeSetting(string $key, mixed $value): bool
|
public function writeSetting(string $key, mixed $value): bool
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
throw new Exception('blog is not set');
|
||||||
|
}
|
||||||
|
|
||||||
if (property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
|
if (property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
|
||||||
dcCore::app()->blog->settings->get(My::id())->drop($key);
|
dcCore::app()->blog->settings->get(My::id())->drop($key);
|
||||||
dcCore::app()->blog->settings->get(My::id())->put($key, $value, gettype($this->{$key}), '', true, true);
|
dcCore::app()->blog->settings->get(My::id())->put($key, $value, gettype($this->{$key}), '', true, true);
|
||||||
|
|
Loading…
Reference in a new issue