Skip to content

Commit

Permalink
IBX-2: Specified action path for search form for easier reuse (#1719)
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Mar 8, 2021
1 parent dbe3852 commit 7dad629
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/services/views.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ services:
$contentTypeService: '@ezpublish.api.service.content_type'
$siteAccessGroups: '%ezpublish.siteaccess.groups%'
$innerFilter: '@EzSystems\EzPlatformAdminUi\View\Filter\AdminSearchViewFilter.inner'
$urlGenerator: '@router'
tags:
- { name: kernel.event_subscriber }
9 changes: 8 additions & 1 deletion src/lib/View/Filter/AdminSearchViewFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class AdminSearchViewFilter implements EventSubscriberInterface
{
Expand All @@ -42,20 +43,25 @@ class AdminSearchViewFilter implements EventSubscriberInterface
/** @var \Ibexa\Platform\Search\View\SearchViewFilter */
private $innerFilter;

/** @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface */
private $urlGenerator;

public function __construct(
ConfigResolverInterface $configResolver,
FormFactoryInterface $formFactory,
SectionService $sectionService,
ContentTypeService $contentTypeService,
array $siteAccessGroups,
SearchViewFilter $innerFilter
SearchViewFilter $innerFilter,
UrlGeneratorInterface $urlGenerator
) {
$this->configResolver = $configResolver;
$this->formFactory = $formFactory;
$this->sectionService = $sectionService;
$this->contentTypeService = $contentTypeService;
$this->siteAccessGroups = $siteAccessGroups;
$this->innerFilter = $innerFilter;
$this->urlGenerator = $urlGenerator;
}

public static function getSubscribedEvents()
Expand Down Expand Up @@ -134,6 +140,7 @@ public function handleSearchForm(FilterViewBuilderParametersEvent $event): void
[
'method' => Request::METHOD_GET,
'csrf_protection' => false,
'action' => $this->urlGenerator->generate('ezplatform.search'),
]
);

Expand Down

0 comments on commit 7dad629

Please sign in to comment.