mirror of
https://github.com/flarum/core.git
synced 2025-07-23 17:51:24 +02:00
Initial refactor of client actions, data preloading, SEO
An initial stab at flarum/core#126. Still WIP. Preliminary implementation of flarum/core#128 and flarum/core#13.
This commit is contained in:
@@ -33,6 +33,6 @@ class Client
|
||||
|
||||
$response = $action->handle(new Request($input, $actor));
|
||||
|
||||
return json_decode($response->getBody());
|
||||
return new Response($response);
|
||||
}
|
||||
}
|
||||
|
16
framework/core/src/Api/Response.php
Normal file
16
framework/core/src/Api/Response.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php namespace Flarum\Api;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class Response
|
||||
{
|
||||
public function __construct(ResponseInterface $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return json_decode($this->response->getBody());
|
||||
}
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core;
|
||||
|
||||
class ForumSerializer extends Serializer
|
||||
{
|
||||
/**
|
||||
@@ -21,7 +23,12 @@ class ForumSerializer extends Serializer
|
||||
protected function getDefaultAttributes($forum)
|
||||
{
|
||||
return [
|
||||
'title' => $forum->title
|
||||
'title' => $forum->title,
|
||||
'baseUrl' => Core::config('base_url'),
|
||||
'apiUrl' => Core::config('api_url'),
|
||||
'welcomeTitle' => Core::config('welcome_title'),
|
||||
'welcomeMessage' => Core::config('welcome_message'),
|
||||
'themePrimaryColor' => Core::config('theme_primary_color')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user