Skip to content

Commit

Permalink
fix: error when seo installed but not enabled (#169)
Browse files Browse the repository at this point in the history
* fix: error when seo installed but not enabled

* chore: remove unused imports
  • Loading branch information
imorland authored Oct 31, 2023
1 parent d80e542 commit 0d6cdf6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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": "*"
}
}
19 changes: 16 additions & 3 deletions src/Controller/BlogOverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace V17Development\FlarumBlog\Controller;

use Flarum\Frontend\Document;
use Flarum\Api\Controller\ListDiscussionsController;
use Flarum\Api\Client;
use Flarum\User\User;
use Flarum\Extension\ExtensionManager;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -14,6 +12,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 +39,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 0d6cdf6

Please sign in to comment.