Added backend:info & backend:version commands.
This commit is contained in:
51
src/Backends/Plex/Action/GetVersion.php
Normal file
51
src/Backends/Plex/Action/GetVersion.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Backends\Plex\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Response;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
final class GetVersion
|
||||
{
|
||||
use CommonTrait;
|
||||
|
||||
private string $action = 'get version';
|
||||
|
||||
public function __construct(
|
||||
protected HttpClientInterface $http,
|
||||
protected LoggerInterface $logger,
|
||||
protected CacheInterface $cache
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Backend unique identifier.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param array $opts optional options.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __invoke(Context $context, array $opts = []): Response
|
||||
{
|
||||
return $this->tryResponse(
|
||||
context: $context,
|
||||
fn: function () use ($context, $opts) {
|
||||
$info = (new GetInfo($this->http, $this->logger, $this->cache))(context: $context, opts: $opts);
|
||||
|
||||
if (false === $info->status) {
|
||||
return $info;
|
||||
}
|
||||
|
||||
return new Response(status: true, response: ag($info->response, 'version'));
|
||||
},
|
||||
action: $this->action
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user