Skip to content

Commit

Permalink
Merge pull request #53 from v17development/dev
Browse files Browse the repository at this point in the history
Update PageListener.php
  • Loading branch information
jaspervriends authored Mar 20, 2021
2 parents c919184 + c3d22ad commit 5800c05
Showing 1 changed file with 6 additions and 46 deletions.
52 changes: 6 additions & 46 deletions src/Listeners/PageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,6 @@ class PageListener
// Config
protected $applicationUrl;

/**
* @var Profile
*/
protected $profileManager;

/**
* @var Tag
*/
protected $tagManager;

/**
* @var Discussion
*/
protected $discussionManager;

/**
* @var QADiscussion
*/
protected $discussionQAManager;

/**
* @var SettingsRepositoryInterface
*/
Expand Down Expand Up @@ -83,31 +63,11 @@ class PageListener
*/
public function __construct(
SettingsRepositoryInterface $settings,
UrlGenerator $url,
Profile $profileManager,
Tag $tagManager,
Discussion $discussionManager,
QADiscussion $discussionQAManager,
Page $pageManager
UrlGenerator $url
) {
// Get Flarum settings
$this->settings = $settings;

// Set profile page manager
$this->profileManager = $profileManager;

// Set tag page manager
$this->tagManager = $tagManager;

// Set discussion page manager
$this->discussionManager = $discussionManager;

// Set discussionQA manager
$this->discussionQAManager = $discussionQAManager;

// Set Page manager
$this->pageManager = $pageManager;

// Set forum base URL
$this->applicationUrl = $url->to('forum')->base();

Expand Down Expand Up @@ -164,27 +124,27 @@ private function determine($serverRequest)

// User profile page
if($routeName === 'user') {
$this->profileManager->handle($this, isset($queryParams['username']) ? $queryParams['username'] : false);
resolve(Profile::class)->handle($this, isset($queryParams['username']) ? $queryParams['username'] : false);
}

// Tag page
else if($routeName === 'tag') {
$this->tagManager->handle($this, isset($queryParams['slug']) ? $queryParams['slug'] : false);
resolve(Tag::class)->handle($this, isset($queryParams['slug']) ? $queryParams['slug'] : false);
}

// Friends Of Flarum pages
else if($routeName === 'pages.home') {
$this->pageManager->handle($this, isset($queryParams['id']) ? $queryParams['id'] : false);
resolve(Page::class)->handle($this, isset($queryParams['id']) ? $queryParams['id'] : false);
}

// Default SEO (no fancy QA layout)
else if($routeName === 'discussion' && $this->discussionType === 1) {
$this->discussionManager->handle($this, isset($queryParams['id']) ? $queryParams['id'] : false);
resolve(Discussion::class)->handle($this, isset($queryParams['id']) ? $queryParams['id'] : false);
}

// QuestionAnswer page
else if($routeName === 'discussion' && $this->discussionType === 2) {
$this->discussionQAManager->handle($this, isset($queryParams['id']) ? $queryParams['id'] : false);
resolve(QADiscussion::class)->handle($this, isset($queryParams['id']) ? $queryParams['id'] : false);
}

// Home page/discussion overview page
Expand Down

0 comments on commit 5800c05

Please sign in to comment.