Skip to content

Commit e56fd6c

Browse files
committed
FFWEB-2690: fix problem with new map due to SecurityExtension
1 parent b721182 commit e56fd6c

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Changelog
22
## Unreleased
3+
### Fix
34
- SSR
45
- Cache field roles
6+
- fix problem with new map due to SecurityExtension
57

68
## [v4.2.2] - 2023.03.16
79
### Add

spec/Subscriber/ConfigurationSubscriberSpec.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
use Shopware\Storefront\Event\StorefrontRenderEvent;
2323
use Shopware\Storefront\Page\GenericPageLoadedEvent;
2424
use Shopware\Storefront\Page\Page;
25+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
2526
use Symfony\Component\HttpFoundation\Request;
2627
use Symfony\Component\Routing\RouterInterface;
2728

2829
class ConfigurationSubscriberSpec extends ObjectBehavior
2930
{
3031
public function let(
32+
ParameterBagInterface $params,
3133
Communication $communication,
3234
ExtensionConfig $extensionConfig,
3335
RouterInterface $router
@@ -43,7 +45,7 @@ public function let(
4345
]
4446
);
4547
$extensionConfig->getRedirectMapping()->willReturn(new RedirectMapping(''));
46-
$this->beConstructedWith($communication, $extensionConfig, $router, $fieldRoles, $communicationParameters);
48+
$this->beConstructedWith($params, $communication, $extensionConfig, $router, $fieldRoles, $communicationParameters);
4749
}
4850

4951
public function it_will_return_factfinderchannel_for_specific_sales_channel_id(

src/Resources/views/storefront/base.html.twig

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
{% block base_body_inner %}
44
{% block base_body_inner_factfinder_communication %}
5-
<ff-communication
6-
{{ page.extensions.factfinder.communication|default([])|filter(val => val)|map((val, key) => key ~ '="' ~ (val|e('html_attr')) ~ '"')|join(' ')|raw }}
7-
only-search-params="true"
8-
disable-single-hit-redirect="true"></ff-communication>
5+
{% if page.extensions.factfinder.shopwareVersion < 64200 %}
6+
<ff-communication
7+
{{ page.extensions.factfinder.communication|default([])|filter(val => val)|map((val, key) => key ~ '="' ~ (val|e('html_attr')) ~ '"')|join(' ')|raw }}
8+
only-search-params="true"
9+
disable-single-hit-redirect="true"></ff-communication>
10+
{% else %}
11+
<ff-communication
12+
{{ page.extensions.factfinder.communication|default([])|filter(val => val)|map((val) => val, (val, key) => key ~ '="' ~ (val|e('html_attr')) ~ '"')|join(' ')|raw }}
13+
only-search-params="true"
14+
disable-single-hit-redirect="true"></ff-communication>
15+
{% endif %}
916
{% endblock %}
1017

1118
{{ parent() }}

src/Subscriber/ConfigurationSubscriber.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Shopware\Core\Framework\Struct\Struct;
1313
use Shopware\Storefront\Event\StorefrontRenderEvent;
1414
use Shopware\Storefront\Page\GenericPageLoadedEvent;
15+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
1516
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1617
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1718
use Symfony\Component\Routing\RouterInterface;
@@ -23,8 +24,10 @@ class ConfigurationSubscriber implements EventSubscriberInterface
2324
private array $fieldRoles;
2425
private array $communicationParameters;
2526
private array $addParams;
27+
private ParameterBagInterface $params;
2628

2729
public function __construct(
30+
ParameterBagInterface $params,
2831
Communication $config,
2932
ExtensionConfig $extensionConfig,
3033
RouterInterface $router,
@@ -38,6 +41,7 @@ public function __construct(
3841
$this->fieldRoles = $fieldRoles;
3942
$this->communicationParameters = $communicationParameters;
4043
$this->addParams = $configurationAddParams;
44+
$this->params = $params;
4145
}
4246

4347
public static function getSubscribedEvents()
@@ -80,6 +84,7 @@ public function onPageLoaded(ShopwareSalesChannelEvent $event): void
8084
'searchImmediate' => $this->isSearchImmediate($event) ? 'true' : 'false',
8185
'userId' => $customer ? $customer->getId() : null,
8286
'ssr' => $this->config->isSsrActive(),
87+
'shopwareVersion' => $this->getShopwareVersion(),
8388
]));
8489
}
8590
}
@@ -135,4 +140,11 @@ private function getServerUrl(): string
135140

136141
return $this->config->getServerUrl();
137142
}
143+
144+
private function getShopwareVersion(): int
145+
{
146+
$version = str_replace('.', '', $this->params->get('kernel.shopware_version'));
147+
148+
return (int) $version;
149+
}
138150
}

0 commit comments

Comments
 (0)