From b0055e57e4777362d4576aa01ecb3b26caca2e83 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 2 Jul 2023 17:25:58 +0000 Subject: [PATCH] fix #46 --- models/Category.php | 12 ++++++++++++ models/Post.php | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/models/Category.php b/models/Category.php index 5c4070e..42f2d22 100644 --- a/models/Category.php +++ b/models/Category.php @@ -104,6 +104,14 @@ public static function getMenuTypeInfo(string $type): array { $result = []; + if (!class_exists(Theme::class)) { + return $result; + } + + if (!class_exists(CmsPage::class)) { + return $result; + } + if ($type == 'blog-category') { $result = [ 'references' => self::listSubCategoryOptions(), @@ -189,6 +197,10 @@ public static function resolveMenuItem(object $item, string $currentUrl, Theme $ { $result = null; + if (!class_exists(CmsPage::class)) { + return $result; + } + // Items must have a reference to a CMS page if (!$item->cmsPage) { return null; diff --git a/models/Post.php b/models/Post.php index ce1acd7..26da6d7 100644 --- a/models/Post.php +++ b/models/Post.php @@ -391,6 +391,14 @@ public function getCmsPageOptions(): array { $result = []; + if (!class_exists(Theme::class)) { + return $result; + } + + if (!class_exists(CmsPage::class)) { + return $result; + } + $theme = Theme::getActiveTheme(); $pages = CmsPage::listInTheme($theme, true)->withComponent('blogPost', function ($component) { if (!preg_match('/{{\s*:/', $component->property('slug'))) { @@ -562,6 +570,15 @@ public static function getMenuTypeInfo(string $type): array } if ($result) { + + if (!class_exists(Theme::class)) { + return $result; + } + + if (!class_exists(CmsPage::class)) { + return $result; + } + $theme = Theme::getActiveTheme(); $pages = CmsPage::listInTheme($theme, true); @@ -608,6 +625,10 @@ public static function resolveMenuItem(object $item, string $currentUrl, Theme $ { $result = null; + if (!class_exists(CmsPage::class)) { + return $result; + } + // Items must have a reference to a CMS page if (!$item->cmsPage) { return null;