From d9286efdb270a937ee43e8e9db53f3e1d97c8184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Parafi=C5=84ski?= Date: Fri, 5 Mar 2021 13:34:34 +0100 Subject: [PATCH] IBX-2: Specified action path for search form for easier reuse --- 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..8a1df6a 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' + $router: '@router' tags: - { name: kernel.event_subscriber } diff --git a/src/lib/View/SearchViewFilter.php b/src/lib/View/SearchViewFilter.php index 74ae181..969a537 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\RouterInterface; class SearchViewFilter implements EventSubscriberInterface { @@ -33,16 +34,21 @@ class SearchViewFilter implements EventSubscriberInterface /** @var \eZ\Publish\API\Repository\ContentTypeService */ private $contentTypeService; + /** @var \Symfony\Component\Routing\RouterInterface */ + private $router; + public function __construct( ConfigResolverInterface $configResolver, FormFactoryInterface $formFactory, SectionService $sectionService, - ContentTypeService $contentTypeService + ContentTypeService $contentTypeService, + RouterInterface $router ) { $this->configResolver = $configResolver; $this->formFactory = $formFactory; $this->sectionService = $sectionService; $this->contentTypeService = $contentTypeService; + $this->router = $router; } public static function getSubscribedEvents() @@ -110,6 +116,7 @@ public function handleSearchForm(FilterViewBuilderParametersEvent $event): void [ 'method' => Request::METHOD_GET, 'csrf_protection' => false, + 'action' => $this->router->generate('ezplatform.search') ] );