Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benwalch committed Oct 8, 2023
1 parent 828b9f3 commit ba9dfd0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/Adapter/Redirector/AbstractRedirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public function getConfig(): array
public function setConfig(array $config): void
{
$configResolver = $this->getConfigResolver();
if (null === $configResolver && !empty($config)) {
throw new \Exception(sprintf('redirector adapter "%s" has a config, but no config resolver was provided.', $this->getName()));
if (null === $configResolver) {
if (!empty($config)) {
throw new \Exception(sprintf('redirector adapter "%s" has a config, but no config resolver was provided.', $this->getName()));
}
} else {
$this->config = $configResolver->resolve($config);
}
Expand Down
10 changes: 3 additions & 7 deletions src/Adapter/Redirector/CookieRedirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@

class CookieRedirector extends AbstractRedirector
{
protected CookieHelper $cookieHelper;

public function __construct()
{
$this->cookieHelper = new CookieHelper($this->config['cookie']);
}

public function makeDecision(RedirectorBag $redirectorBag): void
{
$cookieHelper = new CookieHelper($this->config['cookie']);

if ($this->lastRedirectorWasSuccessful($redirectorBag) === true) {
return;
}
Expand All @@ -28,7 +24,7 @@ public function makeDecision(RedirectorBag $redirectorBag): void
$language = null;

$request = $redirectorBag->getRequest();
$redirectCookie = $this->cookieHelper->get($request);
$redirectCookie = $cookieHelper->get($request);

//if no cookie available the validation fails.
if (is_array($redirectCookie) && !empty($redirectCookie['url'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/RedirectorAdapterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function process(ContainerBuilder $container): void
$definition = $container->getDefinition(RedirectorRegistry::class);
$registry = $container->getParameter('i18n.registry');

$redirectorRegistry = $registry['redirector'] ?? [];
$redirectorRegistry = $registry['redirector'];

foreach ($container->findTaggedServiceIds('i18n.adapter.redirector', true) as $serviceId => $attributes) {
$priority = $attributes[0]['priority'] ?? 0;
Expand Down

0 comments on commit ba9dfd0

Please sign in to comment.