mirror of
https://github.com/flarum/core.git
synced 2025-10-12 15:34:26 +02:00
Massive refactor
- Use contextual namespaces within Flarum\Core - Clean up and docblock everything - Refactor Activity/Notification blueprint stuff - Refactor Formatter stuff - Refactor Search stuff - Upgrade to JSON-API 1.0 - Removed “addedPosts” and “removedPosts” relationships from discussion API. This was used for adding/removing event posts after renaming a discussion etc. Instead we should make an additional request to get all new posts Todo: - Fix Extenders and extensions - Get rid of repository interfaces - Fix other bugs I’ve inevitably introduced
This commit is contained in:
@@ -1,35 +1,37 @@
|
||||
<?php
|
||||
<?php namespace Flarum\Api;
|
||||
|
||||
namespace Flarum\Api;
|
||||
|
||||
use Flarum\Support\Actor;
|
||||
use Flarum\Core\Users\User;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class Client
|
||||
{
|
||||
/**
|
||||
* @var Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
protected $actor;
|
||||
|
||||
public function __construct(Container $container, Actor $actor)
|
||||
/**
|
||||
* @param Container $container
|
||||
*/
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->actor = $actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given API action class, pass the input and return its response.
|
||||
*
|
||||
* @param User $actor
|
||||
* @param string $actionClass
|
||||
* @param array $input
|
||||
* @return object
|
||||
*/
|
||||
public function send($actionClass, array $input = [])
|
||||
public function send(User $actor, $actionClass, array $input = [])
|
||||
{
|
||||
/** @var \Flarum\Api\Actions\JsonApiAction $action */
|
||||
$action = $this->container->make($actionClass);
|
||||
|
||||
$response = $action->handle(new Request($input, $this->actor));
|
||||
$response = $action->handle(new Request($input, $actor));
|
||||
|
||||
return json_decode($response->getBody());
|
||||
}
|
||||
|
Reference in New Issue
Block a user