From 5aa15f5b271cfcda09ad8e89818e4a30dec9a56a Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 21 Jul 2018 22:09:14 +0930 Subject: [PATCH] Remove file accidentally added in merge --- .../src/Forum/Controller/IndexController.php | 87 ------------------- 1 file changed, 87 deletions(-) delete mode 100644 framework/core/src/Forum/Controller/IndexController.php diff --git a/framework/core/src/Forum/Controller/IndexController.php b/framework/core/src/Forum/Controller/IndexController.php deleted file mode 100644 index 544b68944..000000000 --- a/framework/core/src/Forum/Controller/IndexController.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Forum\Controller; - -use Flarum\Api\Client as ApiClient; -use Flarum\Forum\Frontend; -use Flarum\User\User; -use Illuminate\Contracts\Events\Dispatcher; -use Psr\Http\Message\ServerRequestInterface as Request; - -class IndexController extends FrontendController -{ - /** - * @var ApiClient - */ - protected $api; - - /** - * A map of sort query param values to their API sort param. - * - * @var array - */ - private $sortMap = [ - 'latest' => '-lastPostedAt', - 'top' => '-commentCount', - 'newest' => '-createdAt', - 'oldest' => 'createdAt' - ]; - - /** - * {@inheritdoc} - */ - public function __construct(Frontend $webApp, Dispatcher $events, ApiClient $api) - { - parent::__construct($webApp, $events); - - $this->api = $api; - } - - /** - * {@inheritdoc} - */ - protected function getView(Request $request) - { - $view = parent::getView($request); - - $queryParams = $request->getQueryParams(); - - $sort = array_pull($queryParams, 'sort'); - $q = array_pull($queryParams, 'q'); - $page = array_pull($queryParams, 'page', 1); - - $params = [ - 'sort' => $sort && isset($this->sortMap[$sort]) ? $this->sortMap[$sort] : '', - 'filter' => compact('q'), - 'page' => ['offset' => ($page - 1) * 20, 'limit' => 20] - ]; - - $document = $this->getDocument($request->getAttribute('actor'), $params); - - $view->document = $document; - $view->content = app('view')->make('flarum.forum::frontend.content.index', compact('document', 'page', 'forum')); - - return $view; - } - - /** - * Get the result of an API request to list discussions. - * - * @param User $actor - * @param array $params - * @return object - */ - private function getDocument(User $actor, array $params) - { - return json_decode($this->api->send('Flarum\Api\Controller\ListDiscussionsController', $actor, $params)->getBody()); - } -}