2023-08-06 00:42:34 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\State;
|
|
|
|
|
|
|
|
use ApiPlatform\Metadata\Operation;
|
|
|
|
use ApiPlatform\State\ProviderInterface;
|
|
|
|
use App\ApiResource\PartDBInfo;
|
|
|
|
use App\Services\Misc\GitVersionInfo;
|
|
|
|
use App\Services\System\BannerHelper;
|
|
|
|
use Shivas\VersioningBundle\Service\VersionManagerInterface;
|
|
|
|
|
|
|
|
class PartDBInfoProvider implements ProviderInterface
|
|
|
|
{
|
|
|
|
|
|
|
|
public function __construct(private readonly VersionManagerInterface $versionManager,
|
|
|
|
private readonly GitVersionInfo $gitVersionInfo,
|
|
|
|
private readonly string $partdb_title,
|
2024-03-03 19:57:31 +01:00
|
|
|
private readonly string $base_currency,
|
2023-08-06 00:42:34 +02:00
|
|
|
private readonly BannerHelper $bannerHelper,
|
|
|
|
private readonly string $default_uri,
|
|
|
|
private readonly string $global_timezone,
|
|
|
|
private readonly string $global_locale
|
|
|
|
)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
|
|
|
{
|
|
|
|
return new PartDBInfo(
|
|
|
|
version: $this->versionManager->getVersion()->toString(),
|
|
|
|
git_branch: $this->gitVersionInfo->getGitBranchName(),
|
|
|
|
git_commit: $this->gitVersionInfo->getGitCommitHash(),
|
|
|
|
title: $this->partdb_title,
|
|
|
|
banner: $this->bannerHelper->getBanner(),
|
|
|
|
default_uri: $this->default_uri,
|
|
|
|
global_timezone: $this->global_timezone,
|
|
|
|
base_currency: $this->base_currency,
|
|
|
|
global_locale: $this->global_locale,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|