Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

IBX-2: Specified action path for search form for easier reuse #14

Merged
merged 2 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
$urlGenerator: '@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\Generator\UrlGeneratorInterface;

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\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()
Expand Down Expand Up @@ -110,6 +116,7 @@ public function handleSearchForm(FilterViewBuilderParametersEvent $event): void
[
'method' => Request::METHOD_GET,
'csrf_protection' => false,
'action' => $this->urlGenerator->generate('ezplatform.search'),
]
);

Expand Down