mirror of
https://github.com/jbcr/SyliusCmsPlugin.git
synced 2026-04-29 19:43:10 +02:00
WIP
This commit is contained in:
@@ -17,25 +17,34 @@ use FOS\RestBundle\View\ViewHandler;
|
||||
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Sylius\Component\Locale\Context\LocaleContextInterface;
|
||||
|
||||
final class TaxonSearchAction
|
||||
{
|
||||
/** @var TaxonRepositoryInterface */
|
||||
private $taxonRepository;
|
||||
|
||||
/** @var LocaleContextInterface */
|
||||
private $localeContext;
|
||||
|
||||
/** @var ViewHandler */
|
||||
private $viewHandler;
|
||||
|
||||
public function __construct(TaxonRepositoryInterface $taxonRepository, ViewHandler $viewHandler)
|
||||
public function __construct(
|
||||
TaxonRepositoryInterface $taxonRepository,
|
||||
LocaleContextInterface $localeContext,
|
||||
ViewHandler $viewHandler
|
||||
)
|
||||
{
|
||||
$this->taxonRepository = $taxonRepository;
|
||||
$this->localeContext = $localeContext;
|
||||
$this->viewHandler = $viewHandler;
|
||||
}
|
||||
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
$product = $this->taxonRepository->findByNamePart($request->get('phrase', ''));
|
||||
$view = View::create($product);
|
||||
$taxon = $this->taxonRepository->findByNamePart($request->get('phrase', ''), $this->localeContext->getLocaleCode());
|
||||
$view = View::create($taxon);
|
||||
|
||||
$this->viewHandler->setExclusionStrategyGroups(['Autocomplete']);
|
||||
$view->getContext()->enableMaxDepth();
|
||||
|
||||
@@ -17,7 +17,8 @@ services:
|
||||
class: BitBag\SyliusCmsPlugin\Controller\Action\Admin\TaxonSearchAction
|
||||
public: true
|
||||
arguments:
|
||||
- "@bitbag_sylius_cms_plugin.repository.taxon"
|
||||
- "@sylius.repository.taxon"
|
||||
- "@sylius.context.locale"
|
||||
- "@fos_rest.view_handler.default"
|
||||
|
||||
bitbag_sylius_cms_plugin.controller.action.admin.import_data:
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
services:
|
||||
bitbag_sylius_cms_plugin.repository.product:
|
||||
class: BitBag\SyliusCmsPlugin\Repository\ProductRepository
|
||||
parent: sylius.repository.taxon
|
||||
|
||||
bitbag_sylius_cms_plugin.repository.taxon:
|
||||
class: BitBag\SyliusCmsPlugin\Repository\TaxonRepository
|
||||
parent: sylius.repository.taxon
|
||||
Reference in New Issue
Block a user