mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Upgrade to sylius/theme-bundle ^2.1 and remove Twig templating
This commit is contained in:
parent
92667254ba
commit
cd452a4bcb
28 changed files with 97 additions and 71 deletions
|
|
@ -64,7 +64,7 @@
|
|||
"sylius/registry": "^1.5",
|
||||
"sylius/resource": "^1.7",
|
||||
"sylius/resource-bundle": "^1.7",
|
||||
"sylius/theme-bundle": "^1.5",
|
||||
"sylius/theme-bundle": "^2.1",
|
||||
"symfony/asset": "^4.4",
|
||||
"symfony/config": "^4.4",
|
||||
"symfony/console": "^4.4",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,5 @@ framework:
|
|||
secret: '%env(APP_SECRET)%'
|
||||
form: true
|
||||
csrf_protection: true
|
||||
templating: { engines: ["twig"] }
|
||||
session:
|
||||
handler_id: ~
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@
|
|||
<referencedClass name="Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface" />
|
||||
<referencedClass name="Symfony\Component\Intl\ResourceBundle\RegionBundleInterface" />
|
||||
<referencedClass name="Symfony\Component\Security\Core\Role\Role" />
|
||||
<referencedClass name="Symfony\Component\Translation\TranslatorInterface" />
|
||||
<referencedClass name="Symfony\Bundle\WebServerBundle\WebServerBundle" />
|
||||
</errorLevel>
|
||||
</DeprecatedClass>
|
||||
|
|
@ -109,8 +108,6 @@
|
|||
</DeprecatedInterface>
|
||||
<DeprecatedMethod>
|
||||
<errorLevel type="info">
|
||||
<referencedMethod name="FOS\RestBundle\View\View::setTemplate" />
|
||||
<referencedMethod name="FOS\RestBundle\View\View::setTemplateVar" />
|
||||
<referencedMethod name="Payum\Core\Model\GatewayConfigInterface::setFactoryName" />
|
||||
<referencedMethod name="Symfony\Component\EventDispatcher\Event::stopPropagation" />
|
||||
<referencedMethod name="Symfony\Component\HttpKernel\Kernel::getRootDir" />
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Sylius\Behat\Context\Ui\Admin;
|
|||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Behat\Page\Admin\DashboardPageInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class LocaleContext implements Context
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
</service>
|
||||
|
||||
<service id="sylius.behat.context.hook.test_theme" class="Sylius\Behat\Context\Hook\TestThemeContext">
|
||||
<argument type="service" id="sylius.theme.test_theme_configuration_manager" />
|
||||
<argument type="service" id="Sylius\Bundle\ThemeBundle\Configuration\Test\TestThemeConfigurationManagerInterface" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.hook.email_spool" class="Sylius\Behat\Context\Hook\EmailSpoolContext">
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@
|
|||
<argument type="service" id="sylius.behat.shared_storage" />
|
||||
<argument type="service" id="sylius.repository.theme" />
|
||||
<argument type="service" id="sylius.manager.channel" />
|
||||
<argument type="service" id="sylius.theme.test_theme_configuration_manager" />
|
||||
<argument type="service" id="Sylius\Bundle\ThemeBundle\Configuration\Test\TestThemeConfigurationManagerInterface" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.setup.user" class="Sylius\Behat\Context\Setup\UserContext">
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Twig\Environment;
|
||||
|
||||
final class CustomerStatisticsController
|
||||
{
|
||||
|
|
@ -29,13 +30,16 @@ final class CustomerStatisticsController
|
|||
/** @var RepositoryInterface */
|
||||
private $customerRepository;
|
||||
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(
|
||||
CustomerStatisticsProviderInterface $statisticsProvider,
|
||||
RepositoryInterface $customerRepository,
|
||||
EngineInterface $templatingEngine
|
||||
object $templatingEngine
|
||||
) {
|
||||
$this->statisticsProvider = $statisticsProvider;
|
||||
$this->customerRepository = $customerRepository;
|
||||
|
|
@ -60,9 +64,9 @@ final class CustomerStatisticsController
|
|||
|
||||
$customerStatistics = $this->statisticsProvider->getCustomerStatistics($customer);
|
||||
|
||||
return $this->templatingEngine->renderResponse(
|
||||
return new Response($this->templatingEngine->render(
|
||||
'@SyliusAdmin/Customer/Show/Statistics/index.html.twig',
|
||||
['statistics' => $customerStatistics]
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,21 @@ use Sylius\Bundle\AdminBundle\Provider\StatisticsDataProviderInterface;
|
|||
use Sylius\Component\Core\Model\ChannelInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Twig\Environment;
|
||||
|
||||
final class StatisticsController
|
||||
{
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
/** @var StatisticsDataProviderInterface */
|
||||
private $statisticsDataProvider;
|
||||
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(
|
||||
EngineInterface $templatingEngine,
|
||||
object $templatingEngine,
|
||||
StatisticsDataProviderInterface $statisticsDataProvider
|
||||
) {
|
||||
$this->templatingEngine = $templatingEngine;
|
||||
|
|
@ -36,7 +40,7 @@ final class StatisticsController
|
|||
|
||||
public function renderStatistics(ChannelInterface $channel): Response
|
||||
{
|
||||
return $this->templatingEngine->renderResponse(
|
||||
return new Response($this->templatingEngine->render(
|
||||
'@SyliusAdmin/Dashboard/Statistics/_template.html.twig',
|
||||
$this->statisticsDataProvider->getRawData(
|
||||
$channel,
|
||||
|
|
@ -44,6 +48,6 @@ final class StatisticsController
|
|||
(new \DateTime('first day of january next year')),
|
||||
'month'
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
final class DashboardController
|
||||
{
|
||||
/** @var ChannelRepositoryInterface */
|
||||
private $channelRepository;
|
||||
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
/** @var RouterInterface */
|
||||
|
|
@ -41,9 +42,12 @@ final class DashboardController
|
|||
/** @var StatisticsDataProviderInterface */
|
||||
private $statisticsDataProvider;
|
||||
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(
|
||||
ChannelRepositoryInterface $channelRepository,
|
||||
EngineInterface $templatingEngine,
|
||||
object $templatingEngine,
|
||||
RouterInterface $router,
|
||||
?SalesDataProviderInterface $salesDataProvider = null,
|
||||
?StatisticsDataProviderInterface $statisticsDataProvider = null
|
||||
|
|
@ -64,9 +68,9 @@ final class DashboardController
|
|||
return new RedirectResponse($this->router->generate('sylius_admin_channel_create'));
|
||||
}
|
||||
|
||||
return $this->templatingEngine->renderResponse('@SyliusAdmin/Dashboard/index.html.twig', [
|
||||
return new Response($this->templatingEngine->render('@SyliusAdmin/Dashboard/index.html.twig', [
|
||||
'channel' => $channel,
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
public function getRawData(Request $request): Response
|
||||
|
|
|
|||
|
|
@ -41,21 +41,21 @@
|
|||
|
||||
<service id="sylius.controller.admin.dashboard" class="Sylius\Bundle\AdminBundle\Controller\DashboardController" public="true">
|
||||
<argument type="service" id="sylius.repository.channel" />
|
||||
<argument type="service" id="templating" />
|
||||
<argument type="service" id="twig" />
|
||||
<argument type="service" id="router" />
|
||||
<argument type="service" id="Sylius\Component\Core\Dashboard\SalesDataProviderInterface" />
|
||||
<argument type="service" id="Sylius\Bundle\AdminBundle\Provider\StatisticsDataProviderInterface" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.controller.admin.dashboard.statistics" class="Sylius\Bundle\AdminBundle\Controller\Dashboard\StatisticsController">
|
||||
<argument type="service" id="templating" />
|
||||
<argument type="service" id="twig" />
|
||||
<argument type="service" id="Sylius\Bundle\AdminBundle\Provider\StatisticsDataProviderInterface" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.controller.customer_statistics" class="Sylius\Bundle\AdminBundle\Controller\CustomerStatisticsController" public="true">
|
||||
<argument type='service' id="sylius.customer_statistics_provider" />
|
||||
<argument type='service' id="sylius.repository.customer" />
|
||||
<argument type='service' id="templating" />
|
||||
<argument type='service' id="twig" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.controller.admin.notification" class="Sylius\Bundle\AdminBundle\Controller\NotificationController" public="true">
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\CoreBundle\Installer\Requirement;
|
||||
|
||||
use ReflectionExtension;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class ExtensionsRequirements extends RequirementCollection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Installer\Requirement;
|
||||
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class FilesystemRequirements extends RequirementCollection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Installer\Requirement;
|
||||
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class SettingsRequirements extends RequirementCollection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -124,9 +124,6 @@ final class TestKernel extends BaseKernel
|
|||
'session' => [
|
||||
'handler_id' => null,
|
||||
],
|
||||
'templating' => [
|
||||
'engines' => ['twig'],
|
||||
],
|
||||
'default_locale' => '%locale%',
|
||||
'translator' => [
|
||||
'fallbacks' => [
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
"sylius/shipping-bundle": "^1.6",
|
||||
"sylius/taxation-bundle": "^1.6",
|
||||
"sylius/taxonomy-bundle": "^1.6",
|
||||
"sylius/theme-bundle": "^1.5",
|
||||
"sylius/theme-bundle": "^2.1",
|
||||
"sylius/ui-bundle": "^1.6",
|
||||
"sylius/user-bundle": "^1.6",
|
||||
"symfony/framework-bundle": "^4.4",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Sylius\Bundle\PayumBundle\Provider;
|
|||
|
||||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Sylius\Component\Core\Model\PaymentInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class PaymentDescriptionProvider implements PaymentDescriptionProviderInterface
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use PhpSpec\ObjectBehavior;
|
|||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Sylius\Component\Core\Model\OrderItem;
|
||||
use Sylius\Component\Core\Model\PaymentInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class PaymentDescriptionProviderSpec extends ObjectBehavior
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Twig\Environment;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class ContactController
|
||||
|
|
@ -36,7 +37,7 @@ final class ContactController
|
|||
/** @var FormFactoryInterface */
|
||||
private $formFactory;
|
||||
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
/** @var ChannelContextInterface */
|
||||
|
|
@ -51,10 +52,13 @@ final class ContactController
|
|||
/** @var ContactEmailManagerInterface */
|
||||
private $contactEmailManager;
|
||||
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(
|
||||
RouterInterface $router,
|
||||
FormFactoryInterface $formFactory,
|
||||
EngineInterface $templatingEngine,
|
||||
object $templatingEngine,
|
||||
ChannelContextInterface $channelContext,
|
||||
CustomerContextInterface $customerContext,
|
||||
LocaleContextInterface $localeContext,
|
||||
|
|
@ -118,7 +122,7 @@ final class ContactController
|
|||
|
||||
$template = $this->getSyliusAttribute($request, 'template', '@SyliusShop/Contact/request.html.twig');
|
||||
|
||||
return $this->templatingEngine->renderResponse($template, ['form' => $form->createView()]);
|
||||
return new Response($this->templatingEngine->render($template, ['form' => $form->createView()]));
|
||||
}
|
||||
|
||||
private function getSyliusAttribute(Request $request, string $attributeName, ?string $default): ?string
|
||||
|
|
|
|||
|
|
@ -22,10 +22,11 @@ use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
|||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Twig\Environment;
|
||||
|
||||
final class CurrencySwitchController
|
||||
{
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
/** @var CurrencyContextInterface */
|
||||
|
|
@ -37,8 +38,11 @@ final class CurrencySwitchController
|
|||
/** @var ChannelContextInterface */
|
||||
private $channelContext;
|
||||
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(
|
||||
EngineInterface $templatingEngine,
|
||||
object $templatingEngine,
|
||||
CurrencyContextInterface $currencyContext,
|
||||
CurrencyStorageInterface $currencyStorage,
|
||||
ChannelContextInterface $channelContext
|
||||
|
|
@ -61,10 +65,10 @@ final class CurrencySwitchController
|
|||
$channel->getCurrencies()->toArray()
|
||||
);
|
||||
|
||||
return $this->templatingEngine->renderResponse('@SyliusShop/Menu/_currencySwitch.html.twig', [
|
||||
return new Response($this->templatingEngine->render('@SyliusShop/Menu/_currencySwitch.html.twig', [
|
||||
'active' => $this->currencyContext->getCurrencyCode(),
|
||||
'currencies' => $availableCurrencies,
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
public function switchAction(Request $request, string $code): Response
|
||||
|
|
|
|||
|
|
@ -16,19 +16,23 @@ namespace Sylius\Bundle\ShopBundle\Controller;
|
|||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Twig\Environment;
|
||||
|
||||
final class HomepageController
|
||||
{
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
public function __construct(EngineInterface $templatingEngine)
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(object $templatingEngine)
|
||||
{
|
||||
$this->templatingEngine = $templatingEngine;
|
||||
}
|
||||
|
||||
public function indexAction(Request $request): Response
|
||||
{
|
||||
return $this->templatingEngine->renderResponse('@SyliusShop/Homepage/index.html.twig');
|
||||
return new Response($this->templatingEngine->render('@SyliusShop/Homepage/index.html.twig'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,11 @@ use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Twig\Environment;
|
||||
|
||||
final class LocaleSwitchController
|
||||
{
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
/** @var LocaleContextInterface */
|
||||
|
|
@ -35,8 +36,11 @@ final class LocaleSwitchController
|
|||
/** @var LocaleSwitcherInterface */
|
||||
private $localeSwitcher;
|
||||
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(
|
||||
EngineInterface $templatingEngine,
|
||||
object $templatingEngine,
|
||||
LocaleContextInterface $localeContext,
|
||||
LocaleProviderInterface $localeProvider,
|
||||
LocaleSwitcherInterface $localeSwitcher
|
||||
|
|
@ -49,10 +53,10 @@ final class LocaleSwitchController
|
|||
|
||||
public function renderAction(): Response
|
||||
{
|
||||
return $this->templatingEngine->renderResponse('@SyliusShop/Menu/_localeSwitch.html.twig', [
|
||||
return new Response($this->templatingEngine->render('@SyliusShop/Menu/_localeSwitch.html.twig', [
|
||||
'active' => $this->localeContext->getLocaleCode(),
|
||||
'locales' => $this->localeProvider->getAvailableLocalesCodes(),
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
public function switchAction(Request $request, ?string $code = null): Response
|
||||
|
|
|
|||
|
|
@ -15,19 +15,23 @@ namespace Sylius\Bundle\ShopBundle\Controller;
|
|||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Twig\Environment;
|
||||
|
||||
final class SecurityWidgetController
|
||||
{
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
public function __construct(EngineInterface $templatingEngine)
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(object $templatingEngine)
|
||||
{
|
||||
$this->templatingEngine = $templatingEngine;
|
||||
}
|
||||
|
||||
public function renderAction(): Response
|
||||
{
|
||||
return $this->templatingEngine->renderResponse('@SyliusShop/Menu/_security.html.twig');
|
||||
return new Response($this->templatingEngine->render('@SyliusShop/Menu/_security.html.twig'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<service id="sylius.controller.shop.contact" class="Sylius\Bundle\ShopBundle\Controller\ContactController">
|
||||
<argument type="service" id="router" />
|
||||
<argument type="service" id="form.factory" />
|
||||
<argument type="service" id="templating" />
|
||||
<argument type="service" id="twig" />
|
||||
<argument type="service" id="sylius.context.channel" />
|
||||
<argument type="service" id="sylius.context.customer" />
|
||||
<argument type="service" id="sylius.context.locale" />
|
||||
|
|
@ -26,25 +26,25 @@
|
|||
</service>
|
||||
|
||||
<service id="sylius.controller.shop.homepage" class="Sylius\Bundle\ShopBundle\Controller\HomepageController">
|
||||
<argument type="service" id="templating" />
|
||||
<argument type="service" id="twig" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.controller.shop.currency_switch" class="Sylius\Bundle\ShopBundle\Controller\CurrencySwitchController">
|
||||
<argument type="service" id="templating" />
|
||||
<argument type="service" id="twig" />
|
||||
<argument type="service" id="sylius.context.currency" />
|
||||
<argument type="service" id="sylius.storage.currency" />
|
||||
<argument type="service" id="sylius.context.channel" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.controller.shop.locale_switch" class="Sylius\Bundle\ShopBundle\Controller\LocaleSwitchController">
|
||||
<argument type="service" id="templating" />
|
||||
<argument type="service" id="twig" />
|
||||
<argument type="service" id="sylius.context.locale" />
|
||||
<argument type="service" id="sylius.locale_provider" />
|
||||
<argument type="service" id="sylius.shop.locale_switcher" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.controller.shop.security_widget" class="Sylius\Bundle\ShopBundle\Controller\SecurityWidgetController">
|
||||
<argument type="service" id="templating" />
|
||||
<argument type="service" id="twig" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Twig\Environment;
|
||||
|
||||
final class SecurityController
|
||||
{
|
||||
|
|
@ -31,7 +32,7 @@ final class SecurityController
|
|||
/** @var FormFactoryInterface */
|
||||
private $formFactory;
|
||||
|
||||
/** @var EngineInterface */
|
||||
/** @var EngineInterface|Environment */
|
||||
private $templatingEngine;
|
||||
|
||||
/** @var AuthorizationCheckerInterface */
|
||||
|
|
@ -40,10 +41,13 @@ final class SecurityController
|
|||
/** @var RouterInterface */
|
||||
private $router;
|
||||
|
||||
/**
|
||||
* @param EngineInterface|Environment $templatingEngine
|
||||
*/
|
||||
public function __construct(
|
||||
AuthenticationUtils $authenticationUtils,
|
||||
FormFactoryInterface $formFactory,
|
||||
EngineInterface $templatingEngine,
|
||||
object $templatingEngine,
|
||||
AuthorizationCheckerInterface $authorizationChecker,
|
||||
RouterInterface $router
|
||||
) {
|
||||
|
|
@ -71,11 +75,11 @@ final class SecurityController
|
|||
$formType = $options['form'] ?? SecurityLoginType::class;
|
||||
$form = $this->formFactory->createNamed('', $formType);
|
||||
|
||||
return $this->templatingEngine->renderResponse($template, [
|
||||
return new Response($this->templatingEngine->render($template, [
|
||||
'form' => $form->createView(),
|
||||
'last_username' => $lastUsername,
|
||||
'last_error' => $lastError,
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
public function checkAction(Request $request): void
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<service id="sylius.controller.security" class="Sylius\Bundle\UiBundle\Controller\SecurityController" public="true">
|
||||
<argument type="service" id="security.authentication_utils" />
|
||||
<argument type="service" id="form.factory" />
|
||||
<argument type="service" id="templating" />
|
||||
<argument type="service" id="twig" />
|
||||
<argument type="service" id="security.authorization_checker" />
|
||||
<argument type="service" id="router" />
|
||||
</service>
|
||||
|
|
|
|||
|
|
@ -38,9 +38,6 @@ final class Kernel extends HttpKernel
|
|||
{
|
||||
$containerBuilder->loadFromExtension('framework', [
|
||||
'secret' => 'S0ME_SECRET',
|
||||
'templating' => [
|
||||
'engines' => ['twig'],
|
||||
],
|
||||
]);
|
||||
|
||||
$containerBuilder->loadFromExtension('security', ['firewalls' => ['main' => ['anonymous' => null]]]);
|
||||
|
|
|
|||
|
|
@ -64,15 +64,15 @@ final class SecurityControllerSpec extends ObjectBehavior
|
|||
$form->createView()->willReturn($formView);
|
||||
|
||||
$templatingEngine
|
||||
->renderResponse('CustomTemplateName', [
|
||||
->render('CustomTemplateName', [
|
||||
'form' => $formView,
|
||||
'last_username' => 'john.doe',
|
||||
'last_error' => 'Bad credentials.',
|
||||
])
|
||||
->willReturn($response)
|
||||
->willReturn('content')
|
||||
;
|
||||
|
||||
$this->loginAction($request)->shouldReturn($response);
|
||||
$this->loginAction($request)->getContent()->shouldReturn('content');
|
||||
}
|
||||
|
||||
function it_redirects_when_user_is_logged_in(
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ class UserController extends ResourceController
|
|||
return $this->viewHandler->handle($configuration, View::create($form, Response::HTTP_BAD_REQUEST));
|
||||
}
|
||||
|
||||
return $this->container->get('templating')->renderResponse(
|
||||
return new Response($this->container->get('twig')->render(
|
||||
$configuration->getTemplate('changePassword.html'),
|
||||
['form' => $form->createView()]
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
public function requestPasswordResetTokenAction(Request $request): Response
|
||||
|
|
@ -108,13 +108,13 @@ class UserController extends ResourceController
|
|||
return $this->viewHandler->handle($configuration, View::create($form, Response::HTTP_BAD_REQUEST));
|
||||
}
|
||||
|
||||
return $this->container->get('templating')->renderResponse(
|
||||
return new Response($this->container->get('twig')->render(
|
||||
$configuration->getTemplate('resetPassword.html'),
|
||||
[
|
||||
'form' => $form->createView(),
|
||||
'user' => $user,
|
||||
]
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
public function verifyAction(Request $request, string $token): Response
|
||||
|
|
@ -247,12 +247,12 @@ class UserController extends ResourceController
|
|||
return $this->viewHandler->handle($configuration, View::create($form, Response::HTTP_BAD_REQUEST));
|
||||
}
|
||||
|
||||
return $this->container->get('templating')->renderResponse(
|
||||
return new Response($this->container->get('twig')->render(
|
||||
$template,
|
||||
[
|
||||
'form' => $form->createView(),
|
||||
]
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
protected function addTranslatedFlash(string $type, string $message): void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue