Skip to content

Commit

Permalink
IBX-2: Specified action path for search form for easier reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Mar 5, 2021
1 parent 763808e commit 5434b9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bundle/Resources/config/views.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
9 changes: 8 additions & 1 deletion src/lib/View/SearchViewFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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()
Expand Down Expand Up @@ -110,6 +116,7 @@ public function handleSearchForm(FilterViewBuilderParametersEvent $event): void
[
'method' => Request::METHOD_GET,
'csrf_protection' => false,
'action' => $this->router->generate('ezplatform.search'),
]
);

Expand Down

0 comments on commit 5434b9e

Please sign in to comment.