Skip to content

Commit 330793d

Browse files
authored
IBX-2: Specified action path for search form for easier reuse (#14)
1 parent 763808e commit 330793d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/bundle/Resources/config/views.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ services:
2626
$formFactory: '@Symfony\Component\Form\FormFactoryInterface'
2727
$sectionService: '@ezpublish.api.service.section'
2828
$contentTypeService: '@ezpublish.api.service.content_type'
29+
$urlGenerator: '@router'
2930
tags:
3031
- { name: kernel.event_subscriber }
3132

src/lib/View/SearchViewFilter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1919
use Symfony\Component\Form\FormFactoryInterface;
2020
use Symfony\Component\HttpFoundation\Request;
21+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2122

2223
class SearchViewFilter implements EventSubscriberInterface
2324
{
@@ -33,16 +34,21 @@ class SearchViewFilter implements EventSubscriberInterface
3334
/** @var \eZ\Publish\API\Repository\ContentTypeService */
3435
private $contentTypeService;
3536

37+
/** @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface */
38+
private $urlGenerator;
39+
3640
public function __construct(
3741
ConfigResolverInterface $configResolver,
3842
FormFactoryInterface $formFactory,
3943
SectionService $sectionService,
40-
ContentTypeService $contentTypeService
44+
ContentTypeService $contentTypeService,
45+
UrlGeneratorInterface $urlGenerator
4146
) {
4247
$this->configResolver = $configResolver;
4348
$this->formFactory = $formFactory;
4449
$this->sectionService = $sectionService;
4550
$this->contentTypeService = $contentTypeService;
51+
$this->urlGenerator = $urlGenerator;
4652
}
4753

4854
public static function getSubscribedEvents()
@@ -110,6 +116,7 @@ public function handleSearchForm(FilterViewBuilderParametersEvent $event): void
110116
[
111117
'method' => Request::METHOD_GET,
112118
'csrf_protection' => false,
119+
'action' => $this->urlGenerator->generate('ezplatform.search'),
113120
]
114121
);
115122

0 commit comments

Comments
 (0)