Added backend:info & backend:version commands.

This commit is contained in:
abdulmohsen
2023-11-24 14:33:26 +03:00
parent 4c5237c8a3
commit 1f74775b28
15 changed files with 602 additions and 111 deletions

View 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
);
}
}