Skip to content

Commit

Permalink
fix: error when seo installed but not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Oct 31, 2023
1 parent d80e542 commit cf20c92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@
"branch-alias": {
"dev-master": "0.6.x-dev"
}
},
"require-dev": {
"v17development/flarum-seo": "*"
}
}
17 changes: 16 additions & 1 deletion src/Controller/BlogOverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@

class BlogOverviewController
{
/**
* @var Client
*/
protected $api;

/**
* @var TranslatorInterface
*/
protected $translator;

/**
* @var ExtensionManager
*/
protected $extensionManager;

public function __construct(Client $api, TranslatorInterface $translator, ExtensionManager $extensionManager)
{
$this->api = $api;
Expand All @@ -26,7 +41,7 @@ public function __invoke(Document $document, ServerRequestInterface $request)
$queryParams = $request->getQueryParams();

// Set meta tags
if(class_exists("V17Development\FlarumSeo\Extend")) {
if($this->extensionManager->isEnabled('v17development-seo') && class_exists("V17Development\FlarumSeo\Extend")) {
// Get category
if(Arr::get($queryParams, 'category')) {
$category = Tag::where('slug', Arr::get($queryParams, 'category'))->firstOrFail();
Expand Down

0 comments on commit cf20c92

Please sign in to comment.