Fosrestbundle: Symfony Flex(3.3) - Twigμ™€μ˜ 쒅속성

에 λ§Œλ“  2017λ…„ 10μ›” 12일  Β·  7μ½”λ©˜νŠΈ  Β·  좜처: FriendsOfSymfony/FOSRestBundle

μ˜ˆμ™Έ 처리기λ₯Ό ν™œμ„±ν™”ν•˜λ €κ³  ν•  λ•Œ λ‹€μŒ μ˜ˆμ™Έκ°€ λ°œμƒν•©λ‹ˆλ‹€.

"fos_rest.exception.twig_controller" μ„œλΉ„μŠ€λŠ” μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” "templating.engine.twig" μ„œλΉ„μŠ€μ— μ’…μ†λ©λ‹ˆλ‹€.

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

λ²ˆλ“€ 등둝 μˆœμ„œλ₯Ό ν™•μΈν•˜μ‹­μ‹œμ˜€. 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

λͺ¨λ“  7 λŒ“κΈ€

ꡬ성에 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μ—μ„œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 합쳐지면 쒋을텐데 말이죠.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰