Skip to content

Commit

Permalink
Merge branch '6.x' into ref/ts
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 authored Dec 16, 2024
2 parents 15f9b3a + cd97ee6 commit df8ae9a
Show file tree
Hide file tree
Showing 217 changed files with 1,351 additions and 1,299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class HealthCheckCommand extends AbstractCommand
public function __construct(
private readonly EnvironmentHelper $environmentHelper,
private readonly ElasticaService $elasticaService,
private readonly ?StorageManager $storageManager = null
private readonly ?StorageManager $storageManager = null,
) {
parent::__construct();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$hash = match ($this->archiveType) {
self::ARCHIVE_ZIP => $this->uploadZipArchive(),
self::ARCHIVE_EMS => $this->uploadEmsArchive(),
default => false
default => false,
};

if (!$hash) {
Expand Down
2 changes: 1 addition & 1 deletion EMS/client-helper-bundle/src/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class ApiController
{
public function __construct(
private readonly ApiService $service,
private readonly HashcashHelper $hashcashHelper
private readonly HashcashHelper $hashcashHelper,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LoginController
public function __construct(
private readonly Handler $handler,
private readonly Environment $templating,
private readonly FormFactory $formFactory
private readonly FormFactory $formFactory,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class OAuth2Controller
{
public function __construct(
private readonly OAuth2Service $oAuth2Service
private readonly OAuth2Service $oAuth2Service,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class SamlController
{
public function __construct(
private readonly SamlService $samlService
private readonly SamlService $samlService,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ private function addSecuritySection(ArrayNodeDefinition $rootNode): void
OAuth2Property::SCOPES => $oAuth2
->variableNode($oAuth2Property->value)
->defaultValue(AzureOAuth2Provider::DEFAULT_SCOPES),
default => $oAuth2->scalarNode($oAuth2Property->value)
default => $oAuth2->scalarNode($oAuth2Property->value),
};
}

$saml = $sso->arrayNode('saml')->canBeEnabled()->children();
foreach (SamlProperty::cases() as $samlProperty) {
match ($samlProperty) {
SamlProperty::SECURITY => $saml->variableNode($samlProperty->value)->end(),
default => $saml->scalarNode($samlProperty->value)->end()
default => $saml->scalarNode($samlProperty->value)->end(),
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthenticatedListener implements EventSubscriberInterface
public function __construct(
private readonly AuthorizationCheckerInterface $authorizationChecker,
private readonly TokenStorageInterface $tokenStorage,
private readonly OAuth2Service $oAuth2Service
private readonly OAuth2Service $oAuth2Service,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion EMS/client-helper-bundle/src/Helper/Api/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
private readonly UrlGeneratorInterface $urlGenerator,
private readonly Security $security,
private readonly iterable $clientRequests = [],
private readonly iterable $apiClients = []
private readonly iterable $apiClients = [],
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ public function getTemplateContentType(string $contentTypeName): ContentType
return $this->templateContentTypes[$contentTypeName];
}

public function hasTemplateContentType(string $contentTypeName): bool
{
if (empty($this->templateContentTypes)) {
throw new \RuntimeException('Missing config EMSCH_TEMPLATES');
}

return isset($this->templateContentTypes[$contentTypeName]);
}

/**
* @return ContentType[]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
private readonly EnvironmentFactory $environmentFactory,
private readonly RequestStack $requestStack,
private readonly string $emschEnv,
array $environments
array $environments,
) {
foreach ($environments as $name => $config) {
$this->addEnvironment($name, $config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class LocalEnvironment

public function __construct(
private readonly Environment $environment,
private readonly string $directory
private readonly string $directory,
) {
$this->fileSystem = new Filesystem();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class LocalEnvironmentFactory
{
public function __construct(
private readonly string $projectDir,
private readonly ?string $localPath = null
private readonly ?string $localPath = null,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion EMS/client-helper-bundle/src/Helper/Local/LocalHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
private readonly Builders $builders,
private readonly EnvironmentApi $environmentApi,
private LoggerInterface $logger,
private readonly string $projectDir
private readonly string $projectDir,
) {
$this->clientRequest = $clientRequestManager->getDefault();
}
Expand Down
2 changes: 1 addition & 1 deletion EMS/client-helper-bundle/src/Helper/Request/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Handler implements HandlerInterface
public function __construct(
ClientRequestManager $manager,
private readonly RouterInterface $router,
private readonly ?Profiler $profiler
private readonly ?Profiler $profiler,
) {
$this->clientRequest = $manager->getDefault();
}
Expand Down
2 changes: 1 addition & 1 deletion EMS/client-helper-bundle/src/Helper/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class Router extends BaseRouter
{
public function __construct(
private readonly EnvironmentHelper $environmentHelper,
private readonly RoutingBuilder $builder
private readonly RoutingBuilder $builder,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class QueryBuilder
{
public function __construct(
private readonly ClientRequest $clientRequest,
private readonly Search $search
private readonly Search $search,
) {
}

Expand Down
3 changes: 0 additions & 3 deletions EMS/client-helper-bundle/src/Helper/Search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ public function getFields(): array
return $this->fields;
}

/**
* @return ?BoolQuery
*/
public function getQuerySearch(string $queryString): ?BoolQuery
{
if (null === $this->querySearch) {
Expand Down
20 changes: 20 additions & 0 deletions EMS/client-helper-bundle/src/Helper/Templating/TemplateBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace EMS\ClientHelperBundle\Helper\Templating;

use EMS\ClientHelperBundle\Exception\SingleResultException;
use EMS\ClientHelperBundle\Helper\Builder\AbstractBuilder;
use EMS\ClientHelperBundle\Helper\Environment\Environment;

Expand Down Expand Up @@ -71,4 +72,23 @@ public function isFresh(Environment $environment, TemplateName $templateName, in

return $contentType->isLastPublishedAfterTime($time);
}

public function exists(Environment $environment, TemplateName $templateName): bool
{
$settings = $this->settings($environment);
if ($environment->isLocalPulled()) {
return null !== $environment->getLocal()->getTemplates($settings)->find($templateName);
}
if (!$settings->hasTemplateContentType($templateName->getContentType())) {
return false;
}

try {
$this->buildTemplate($environment, $templateName);
} catch (SingleResultException) {
return false;
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ public function exists($name): bool
if (null === $this->environmentHelper->getCurrentEnvironment()) {
return false;
}
if (!TemplateName::validate($name)) {
return false;
}
$environment = $this->getEnvironment();
$templateName = new TemplateName($name);

return TemplateName::validate($name);
return $this->builder->exists($environment, $templateName);
}

private function getEnvironment(): Environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@ public function getName(): string
*/
public function getDataSource(): array
{
$source = ['key' => $this->source['key']];

foreach ($this->locales as $locale) {
if (isset($this->source['label_'.$locale])) {
$source['label_'.$locale] = $this->source['label_'.$locale];
}
}

return $source;
return \array_filter($this->source, fn ($key) => 'key' === $key || \str_starts_with($key, 'label_'), ARRAY_FILTER_USE_KEY);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public function __construct(string $directory)
{
$path = $directory.\DIRECTORY_SEPARATOR.self::DIRECTORY;

if (\file_exists($path)) {
foreach (Finder::create()->in($path)->files()->name('*.yaml') as $file) {
$this->files[] = new TranslationFile($file);
}
if (!\file_exists($path)) {
return;
}
foreach (Finder::create()->in($path)->files()->name('*.yaml') as $file) {
$this->files[] = new TranslationFile($file);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CoreApiFactory
{
public function __construct(
private readonly ClientRequestManager $clientRequestManager,
private readonly EnvironmentApi $environmentApi
private readonly EnvironmentApi $environmentApi,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CoreApiUser implements UserInterface

public function __construct(
public readonly ProfileInterface $profile,
private readonly string $token
private readonly string $token,
) {
$this->displayName = $this->profile->getDisplayName();
$this->username = $this->profile->getUsername();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CoreApiUserProvider implements UserProviderInterface
{
public function __construct(
private readonly CoreApiFactory $coreApiFactory,
private readonly LoggerInterface $logger
private readonly LoggerInterface $logger,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions EMS/client-helper-bundle/src/Security/FirewallEntryPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
private readonly HttpUtils $httpUtils,
private readonly RouterInterface $router,
private readonly SsoService $ssoService,
private readonly string $routeLoginName
private readonly string $routeLoginName,
) {
}

Expand All @@ -30,7 +30,7 @@ public function start(Request $request, ?AuthenticationException $authException
return match (true) {
null !== $routeLogin => $this->httpUtils->createRedirectResponse($request, $this->routeLoginName),
$this->ssoService->enabled() => $this->ssoService->start($request),
default => throw new NotAnEntryPointException()
default => throw new NotAnEntryPointException(),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private function createProvider(): ProviderInterface
encryptionAlgorithm: $this->optionalProperty(OAuth2Property::ENCRYPTION_ALGORITHM),
encryptionKey: $this->optionalProperty(OAuth2Property::ENCRYPTION_KEY)
),
default => throw new \RuntimeException('invalid provider type')
default => throw new \RuntimeException('invalid provider type'),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(
private readonly AccessTokenInterface $accessToken,
UserInterface $user,
string $firewallName,
array $roles
array $roles,
) {
parent::__construct($user, $firewallName, $roles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
string $clientSecret,
string $redirectUri,
?array $scopes,
?string $version
?string $version,
) {
$scopes = $scopes ?? self::DEFAULT_SCOPES;
$serviceScopes = \array_filter($scopes, static fn (string $s) => u($s)->startsWith('http'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SamlService
public function __construct(
private readonly RequestStack $requestStack,
private readonly HttpUtils $httpUtils,
private readonly array $config
private readonly array $config,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion EMS/client-helper-bundle/src/Security/Sso/SsoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function start(Request $request): RedirectResponse
return match (true) {
$this->oAuth2Service->isEnabled() => $this->oAuth2Service->login($request),
$this->samlService->isEnabled() => $this->samlService->login($request),
default => throw new \RuntimeException('Could not start sso, nothing enabled')
default => throw new \RuntimeException('Could not start sso, nothing enabled'),
};
}

Expand Down
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Command/BatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private function getTemplate(string $name): TemplateWrapper
$source = match (true) {
u($name)->startsWith('@EMSCH') => $this->twig->getLoader()->getSourceContext($name)->getCode(),
\file_exists($name) => File::fromFilename($name)->getContents(),
default => $name
default => $name,
};

return $this->twig->createTemplate($source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FileStructurePublishCommand extends AbstractCommand

public function __construct(
private readonly AdminHelper $adminHelper,
private readonly StorageManager $storageManager
private readonly StorageManager $storageManager,
) {
parent::__construct();
}
Expand Down
4 changes: 2 additions & 2 deletions EMS/common-bundle/src/Common/CoreApi/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Result

public function __construct(
public readonly ResponseInterface $response,
LoggerInterface $logger
LoggerInterface $logger,
) {
$data = Json::decode($response->getContent());
$this->data = $data;
Expand All @@ -39,7 +39,7 @@ public function getFirstErrorWarning(): ?string
return match (true) {
(\count($errors) > 0) => \array_shift($errors),
(\count($warnings) > 0) => \array_shift($warnings),
default => null
default => null,
};
}

Expand Down
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Common/Log/LocalizedLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LocalizedLogger extends AbstractLogger implements LocalizedLoggerInterface
public function __construct(
private readonly LoggerInterface $logger,
private readonly TranslatorInterface $translator,
private readonly string $translationDomain
private readonly string $translationDomain,
) {
}

Expand Down
Loading

0 comments on commit df8ae9a

Please sign in to comment.