Skip to content

Commit a8fa01b

Browse files
authored
Merge pull request #82 from Zales0123/fix-deprecations
Replace deprecated EngineInterface with Environment
2 parents 9516af0 + cab1fea commit a8fa01b

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

src/Controller/SearchController.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
use Symfony\Component\HttpFoundation\RedirectResponse;
2828
use Symfony\Component\HttpFoundation\Request;
2929
use Symfony\Component\HttpFoundation\Response;
30-
use Symfony\Component\Templating\EngineInterface;
30+
use Twig\Environment;
3131

3232
class SearchController extends AbstractController
3333
{
3434
public const SORT_ASC = 'asc';
3535
public const SORT_DESC = 'desc';
3636

37-
/** @var EngineInterface */
37+
/** @var Environment */
3838
private $templatingEngine;
3939

4040
/** @var Search */
@@ -55,19 +55,8 @@ class SearchController extends AbstractController
5555
/** @var RenderDocumentUrlHelper */
5656
private $renderDocumentUrlHelper;
5757

58-
/**
59-
* SearchController constructor.
60-
*
61-
* @param EngineInterface $templatingEngine
62-
* @param Search $documentSearch
63-
* @param ChannelContextInterface $channelContext
64-
* @param CurrencyContextInterface $currencyContext
65-
* @param TaxonContextInterface $taxonContext
66-
* @param GridConfig $gridConfig
67-
* @param RenderDocumentUrlHelper $renderDocumentUrlHelper
68-
*/
6958
public function __construct(
70-
EngineInterface $templatingEngine,
59+
Environment $templatingEngine,
7160
Search $documentSearch,
7261
ChannelContextInterface $channelContext,
7362
CurrencyContextInterface $currencyContext,
@@ -138,15 +127,15 @@ public function searchAction(Request $request): Response
138127
$formatter = new \NumberFormatter($request->getLocale() . '@currency=' . $currencyCode, \NumberFormatter::CURRENCY);
139128

140129
// Display result list
141-
return $this->templatingEngine->renderResponse('@MonsieurBizSyliusSearchPlugin/Search/result.html.twig', [
130+
return new Response($this->templatingEngine->render('@MonsieurBizSyliusSearchPlugin/Search/result.html.twig', [
142131
'query' => $this->gridConfig->getQuery(),
143132
'limits' => $this->gridConfig->getLimits(),
144133
'resultSet' => $resultSet,
145134
'channel' => $this->channelContext->getChannel(),
146135
'currencyCode' => $this->currencyContext->getCurrencyCode(),
147136
'moneySymbol' => $formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL),
148137
'gridConfig' => $this->gridConfig,
149-
]);
138+
]));
150139
}
151140

152141
/**
@@ -166,13 +155,13 @@ public function instantAction(Request $request): Response
166155
$resultSet = $this->documentSearch->instant($this->gridConfig);
167156

168157
// Display instant result list
169-
return $this->templatingEngine->renderResponse('@MonsieurBizSyliusSearchPlugin/Instant/result.html.twig', [
158+
return new Response($this->templatingEngine->render('@MonsieurBizSyliusSearchPlugin/Instant/result.html.twig', [
170159
'query' => $this->gridConfig->getQuery(),
171160
'resultSet' => $resultSet,
172161
'channel' => $this->channelContext->getChannel(),
173162
'currencyCode' => $this->currencyContext->getCurrencyCode(),
174163
'gridConfig' => $this->gridConfig,
175-
]);
164+
]));
176165
}
177166

178167
/**
@@ -196,14 +185,14 @@ public function taxonAction(Request $request): Response
196185
$formatter = new \NumberFormatter($request->getLocale() . '@currency=' . $currencyCode, \NumberFormatter::CURRENCY);
197186

198187
// Display result list
199-
return $this->templatingEngine->renderResponse('@MonsieurBizSyliusSearchPlugin/Taxon/result.html.twig', [
188+
return new Response($this->templatingEngine->render('@MonsieurBizSyliusSearchPlugin/Taxon/result.html.twig', [
200189
'taxon' => $this->gridConfig->getTaxon(),
201190
'limits' => $this->gridConfig->getLimits(),
202191
'resultSet' => $resultSet,
203192
'channel' => $this->channelContext->getChannel(),
204193
'currencyCode' => $this->currencyContext->getCurrencyCode(),
205194
'moneySymbol' => $formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL),
206195
'gridConfig' => $this->gridConfig,
207-
]);
196+
]));
208197
}
209198
}

src/Twig/Extension/RenderSearchForm.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,27 @@
1616
use MonsieurBiz\SyliusSearchPlugin\Form\Type\SearchType;
1717
use Symfony\Component\Form\FormFactoryInterface;
1818
use Symfony\Component\HttpFoundation\RequestStack;
19-
use Symfony\Component\Templating\EngineInterface;
19+
use Twig\Environment;
2020
use Twig\Extension\AbstractExtension;
2121
use Twig\Markup;
2222
use Twig\TwigFunction;
2323

2424
class RenderSearchForm extends AbstractExtension
2525
{
26+
/** @var FormFactoryInterface */
2627
private $formFactory;
2728

29+
/** @var Environment */
2830
private $templatingEngine;
2931

32+
/** @var RequestStack */
3033
private $requestStack;
3134

32-
public function __construct(FormFactoryInterface $formFactory, EngineInterface $templatingEngine, RequestStack $requestStack)
33-
{
35+
public function __construct(
36+
FormFactoryInterface $formFactory,
37+
Environment $templatingEngine,
38+
RequestStack $requestStack
39+
) {
3440
$this->formFactory = $formFactory;
3541
$this->templatingEngine = $templatingEngine;
3642
$this->requestStack = $requestStack;

0 commit comments

Comments
 (0)