-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow extending solution search query, limit. setting to display disc…
…ussion tag in search results
- Loading branch information
Showing
5 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace FoF\BestAnswer; | ||
|
||
use Flarum\Api\Serializer\ForumSerializer; | ||
use Flarum\Settings\SettingsRepositoryInterface; | ||
|
||
class ForumAttributes | ||
{ | ||
/** | ||
* @var SettingsRepositoryInterface | ||
*/ | ||
protected $settings; | ||
|
||
public function __construct(SettingsRepositoryInterface $settings) | ||
{ | ||
$this->settings = $settings; | ||
} | ||
|
||
public function __invoke(ForumSerializer $serializer, $model, array $attributes): array | ||
{ | ||
if ($value = $this->getBooleanSetting('fof-best-answer.search.solution_search')) { | ||
$attributes['showTagsInSearchResults'] = $this->getBooleanSetting('fof-best-answer.search.display_tags'); | ||
} | ||
|
||
$attributes['solutionSearchEnabled'] = $value; | ||
$attributes['canSelectBestAnswerOwnPost'] = $this->getBooleanSetting('fof-best-answer.allow_select_own_post'); | ||
$attributes['useAlternativeBestAnswerUi'] = $this->getBooleanSetting('fof-best-answer.use_alternative_ui'); | ||
$attributes['showBestAnswerFilterUi'] = $this->getBooleanSetting('fof-best-answer.show_filter_dropdown'); | ||
$attributes['bestAnswerDiscussionSidebarJumpButton'] = $this->getBooleanSetting('fof-best-answer.discussion_sidebar_jump_button'); | ||
|
||
return $attributes; | ||
} | ||
|
||
protected function getBooleanSetting(string $key): bool | ||
{ | ||
return (bool) $this->settings->get($key); | ||
} | ||
} |