add indexing endpoint
This commit is contained in:
parent
de7f1096a9
commit
d0c4eb615a
|
|
@ -15,7 +15,8 @@ return [
|
|||
(new Flarum\Locales(__DIR__ . '/resources/locale')),
|
||||
|
||||
(new Flarum\Routes('api'))
|
||||
->get('/blomstra/search/{type}', 'blomstra.search', Api\Controllers\SearchController::class),
|
||||
->get('/blomstra/search/{type}', 'blomstra.search', Api\Controllers\SearchController::class)
|
||||
->put('/blomstra/search/index', 'blomstra.search.index', Api\Controllers\IndexController::class),
|
||||
|
||||
(new Flarum\Console)
|
||||
->command(Commands\BuildCommand::class)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Blomstra\Search\Api\Controllers;
|
||||
|
||||
use Blomstra\Search\Commands\BuildCommand;
|
||||
use Laminas\Diactoros\Response\EmptyResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
class IndexController implements RequestHandlerInterface
|
||||
{
|
||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
||||
{
|
||||
/** @var \Flarum\User\User */
|
||||
$actor = $request->getAttribute('actor');
|
||||
$actor->assertAdmin();
|
||||
|
||||
/** @var BuildCommand $command */
|
||||
$command = resolve(BuildCommand::class);
|
||||
|
||||
$command->run(
|
||||
new ArrayInput([]),
|
||||
new ConsoleOutput);
|
||||
|
||||
return new EmptyResponse();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue