1
0
mirror of https://github.com/flarum/core.git synced 2025-10-11 23:14:29 +02:00

Allow configuring all drivers via frontend (#1169)

This includes an API endpoint for fetching the list of possible
drivers and their configuration fields. In the future, this can
be extended to include more meta information about each field.
This commit is contained in:
Franz Liedke
2019-03-19 09:56:20 +01:00
parent 2bd40b50c7
commit 5154d7e5a6
11 changed files with 196 additions and 32 deletions

View File

@@ -0,0 +1,46 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Api\Controller;
use Flarum\Api\Serializer\MailDriverSerializer;
use Flarum\User\AssertPermissionTrait;
use Illuminate\Contracts\Container\Container;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;
class ListMailDriversController extends AbstractListController
{
use AssertPermissionTrait;
/**
* {@inheritdoc}
*/
public $serializer = MailDriverSerializer::class;
/**
* {@inheritdoc}
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$this->assertAdmin($request->getAttribute('actor'));
$drivers = self::$container->make('mail.supported_drivers');
array_walk($drivers, function (&$driver, $key) {
$driver = [
'id' => $key,
'driver' => self::$container->make($driver),
];
});
return $drivers;
}
}