mirror of
https://github.com/flarum/core.git
synced 2025-10-12 15:34:26 +02:00
An initial stab at flarum/core#126. Still WIP. Preliminary implementation of flarum/core#128 and flarum/core#13.
39 lines
867 B
PHP
39 lines
867 B
PHP
<?php namespace Flarum\Api;
|
|
|
|
use Flarum\Core\Users\User;
|
|
use Illuminate\Contracts\Container\Container;
|
|
|
|
class Client
|
|
{
|
|
/**
|
|
* @var Container
|
|
*/
|
|
protected $container;
|
|
|
|
/**
|
|
* @param Container $container
|
|
*/
|
|
public function __construct(Container $container)
|
|
{
|
|
$this->container = $container;
|
|
}
|
|
|
|
/**
|
|
* 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(User $actor, $actionClass, array $input = [])
|
|
{
|
|
/** @var \Flarum\Api\Actions\JsonApiAction $action */
|
|
$action = $this->container->make($actionClass);
|
|
|
|
$response = $action->handle(new Request($input, $actor));
|
|
|
|
return new Response($response);
|
|
}
|
|
}
|