Skip to content

Commit

Permalink
add OrderSearchAction
Browse files Browse the repository at this point in the history
  • Loading branch information
songecko committed Jan 25, 2019
1 parent f14ab32 commit 3fc05b0
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Controller/Action/OrderSearchAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Odiseo\SyliusReportPlugin\Controller\Action;

use FOS\RestBundle\View\View;
use FOS\RestBundle\View\ViewHandler;
use Odiseo\SyliusReportPlugin\Repository\OrderRepositoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

final class OrderSearchAction
{
/** @var OrderRepositoryInterface */
private $orderRepository;

/** @var ViewHandler */
private $viewHandler;

public function __construct(OrderRepositoryInterface $productRepository, ViewHandler $viewHandler)
{
$this->orderRepository = $productRepository;
$this->viewHandler = $viewHandler;
}

public function __invoke(Request $request): Response
{
$orders = $this->orderRepository->findByNumberPart($request->get('number', ''));
$view = View::create($orders);

$this->viewHandler->setExclusionStrategyGroups(['Autocomplete']);
$view->getContext()->enableMaxDepth();

return $this->viewHandler->handle($view);
}
}

0 comments on commit 3fc05b0

Please sign in to comment.