μμΈ μ²λ¦¬κΈ°λ₯Ό νμ±ννλ €κ³ ν λ λ€μ μμΈκ° λ°μν©λλ€.
"fos_rest.exception.twig_controller" μλΉμ€λ μ‘΄μ¬νμ§ μλ "templating.engine.twig" μλΉμ€μ μ’ μλ©λλ€.
ꡬμ±μ exception_controller: 'fos_rest.exception.controller:showAction'
νμ μΆκ°ν΄ 보μμμ€.
fos_rest:
exception:
enabled: true
exception_controller: 'fos_rest.exception.controller:showAction'
μμΈ μ»¨νΈλ‘€λ¬λ₯Ό μ μνμ§ μκ³ TwigBundleμ νμ±ννλ©΄ fos_rest.exception.twig_controller:showAction
κ° μ¬μ©λ©λλ€`
https://github.com/FriendsOfSymfony/FOSRestBundle/blob/80a41f571250ad4c14f7e36c267eb968575884d8/DependencyInjection/FOSRestExtension.php#L331
@ramoshka λ€μ ꡬμ±μμ μ΄ μ€λ₯κ° νμλ©λλ€.
exception:
enabled: true
exception_controller: 'AppBundle\Port\Rest\RequestValidation\RequestValidationExceptionListener::render'
κ·Έλλ 3.4μΈλ° μ λ¬Έμ λ₯Ό μ΄μ΄μΌ νλμ?
λ λ¬Έμ μ μμΈμ΄ κ°λ€κ³ μκ°ν©λλ€. λ°λΌμ μλ‘μ΄ λ¬Έμ IMOκ° νμνμ§ μμ΅λλ€.
Symfony 4 λ° Flexμ λμΌν λ¬Έμ κ° μμ΅λλ€.
λ²λ€ λ±λ‘ μμλ₯Ό νμΈνμμμ€. TwigBundle
λ€μμ FOSRestBundle
λ‘λ μλ:
<?php
// bundles.php
return [
// ...
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
FOS\RestBundle\FOSRestBundle::class => ['all' => true],
];
μ»΄νμΌλ¬ ν¨μ€μ κ΄λ ¨μ΄ μμ΅λλ€.
namespace FOS\RestBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Remove the 'fos_rest.exception.twig_controller' service if twig is enabled.
*
* <strong i="11">@internal</strong>
*/
final class TwigExceptionPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->has('templating.engine.twig')) {
$container->removeDefinition('fos_rest.exception.twig_controller');
}
}
}
λΉμ μ μ λ§ μ¬μ©ν΄μΌ ν κ²½μ° fos_rest.exception.twig_controller
μ€μΉνλ κ²λ³΄λ€, symfony/templating
νλ μμν¬ κ΅¬μ±μμ twig
μμ§μ νμ±νν©λλ€.
framework:
templating:
engines: twig
ν νλ¦Ώ μμ§μ΄ λ μ΄μ κΈ°λ³Έμ μΌλ‘ μ€μΉ λ° νμ±νλμ΄ μμ§ μλ€λ μ μ κ°μν λ templating.engine.twig λμ twig μλΉμ€λ§ νμΈνλλ‘ TwigExceptionPassλ₯Ό μμ νμ§ μλ μ΄μ λ 무μμ λκΉ? μ¬μ ν μλν΄μΌ ν κ² κ°μ΅λλ€. μ΄μ μ€νμΌμ λλκ°μ§ ν νλ¦Ώ κ²½λ‘ μ§μμ μκ² λμ§λ§ λ¬Έμ κ° λμ§λ μμ΅λλ€.
λλ κ°μ λ¬Έμ λ₯Ό μκ³ μμ΄. μμ μ¬νμ #1945μμ μ¬μ©ν μ μμ΅λλ€. ν©μ³μ§λ©΄ μ’μν λ° λ§μ΄μ£ .
κ°μ₯ μ μ©ν λκΈ
λ²λ€ λ±λ‘ μμλ₯Ό νμΈνμμμ€.
TwigBundle
λ€μμFOSRestBundle
λ‘λ μλ:μ»΄νμΌλ¬ ν¨μ€μ κ΄λ ¨μ΄ μμ΅λλ€.
λΉμ μ μ λ§ μ¬μ©ν΄μΌ ν κ²½μ°
fos_rest.exception.twig_controller
μ€μΉνλ κ²λ³΄λ€,symfony/templating
νλ μμν¬ κ΅¬μ±μμ
twig
μμ§μ νμ±νν©λλ€.