fix nullsafe warnings

This commit is contained in:
Jean-Christian Denis 2023-04-23 21:33:37 +02:00
parent efe8358c78
commit 9a2848128f
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
4 changed files with 13 additions and 3 deletions

View file

@ -10,7 +10,7 @@
* @copyright Jean-Christian Denis
* @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;
}
@ -22,7 +22,7 @@ $this->registerModule(
[
'requires' => [['core', '2.26']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
dcCore::app()->auth::PERMISSION_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),

View file

@ -43,6 +43,11 @@ class Backend extends dcNsProcess
dcCore::app()->addBehaviors([
'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void {
// nullsafe
if (is_null(dcCore::app()->blog)) {
return;
}
$exists = [];
$path = Path::fullFromRoot((string) $blog_settings->get('system')->get('public_path'), DC_ROOT);
foreach (['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'] as $ext) {

View file

@ -34,7 +34,7 @@ class Frontend extends dcNsProcess
}
dcCore::app()->addBehavior('publicHeadContent', function (): void {
if (!dcCore::app()->blog->settings->get('system')->get('simply_favicon')) {
if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get('system')->get('simply_favicon')) {
return;
}

View file

@ -31,6 +31,11 @@ class UrlHandler extends dcUrlHandlers
public static function simplyFaviconUrl(string $arg): void
{
// nullsafe
if (is_null(dcCore::app()->blog)) {
return;
}
$public_path = Path::fullFromRoot(dcCore::app()->blog->settings->get('system')->get('public_path'), DC_ROOT);
if (dcCore::app()->blog->settings->get('system')->get('simply_favicon')