From 330793d5d4a5762493ed31c9966a6fd446e4099f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Parafi=C5=84ski?= Date: Mon, 8 Mar 2021 12:10:53 +0100 Subject: [PATCH] IBX-2: Specified action path for search form for easier reuse (#14) --- src/bundle/Resources/config/views.yaml | 1 + src/lib/View/SearchViewFilter.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bundle/Resources/config/views.yaml b/src/bundle/Resources/config/views.yaml index a6fac4b..4fc1326 100644 --- a/src/bundle/Resources/config/views.yaml +++ b/src/bundle/Resources/config/views.yaml @@ -26,6 +26,7 @@ services: $formFactory: '@Symfony\Component\Form\FormFactoryInterface' $sectionService: '@ezpublish.api.service.section' $contentTypeService: '@ezpublish.api.service.content_type' + $urlGenerator: '@router' tags: - { name: kernel.event_subscriber } diff --git a/src/lib/View/SearchViewFilter.php b/src/lib/View/SearchViewFilter.php index 74ae181..aa0707a 100644 --- a/src/lib/View/SearchViewFilter.php +++ b/src/lib/View/SearchViewFilter.php @@ -18,6 +18,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class SearchViewFilter implements EventSubscriberInterface { @@ -33,16 +34,21 @@ class SearchViewFilter implements EventSubscriberInterface /** @var \eZ\Publish\API\Repository\ContentTypeService */ private $contentTypeService; + /** @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface */ + private $urlGenerator; + public function __construct( ConfigResolverInterface $configResolver, FormFactoryInterface $formFactory, SectionService $sectionService, - ContentTypeService $contentTypeService + ContentTypeService $contentTypeService, + UrlGeneratorInterface $urlGenerator ) { $this->configResolver = $configResolver; $this->formFactory = $formFactory; $this->sectionService = $sectionService; $this->contentTypeService = $contentTypeService; + $this->urlGenerator = $urlGenerator; } public static function getSubscribedEvents() @@ -110,6 +116,7 @@ public function handleSearchForm(FilterViewBuilderParametersEvent $event): void [ 'method' => Request::METHOD_GET, 'csrf_protection' => false, + 'action' => $this->urlGenerator->generate('ezplatform.search'), ] );