Skip to content

Commit

Permalink
Update EngineInterface error message
Browse files Browse the repository at this point in the history
  • Loading branch information
XWB committed Oct 30, 2019
1 parent ab328c7 commit b02dc24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Tests/View/ViewHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public function exceptionWrapperSerializeResponseContentProvider()

/**
* @expectedException \LogicException
* @expectedExceptionMessage An instance of Symfony\Component\Templating\EngineInterface must be injected in FOS\RestBundle\View\ViewHandler to render templates.
* @expectedExceptionMessage An instance of Symfony\Component\Templating\EngineInterface or Twig\Environment must be injected in FOS\RestBundle\View\ViewHandler to render templates.
*/
public function testTemplatingNotInjected()
{
Expand Down
29 changes: 17 additions & 12 deletions View/ViewHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ class ViewHandler implements ConfigurableViewHandlerInterface
/**
* Constructor.
*
* @param UrlGeneratorInterface $urlGenerator The URL generator
* @param Serializer $serializer
* @param EngineInterface $templating The configured templating engine
* @param RequestStack $requestStack The request stack
* @param array $formats the supported formats as keys and if the given formats uses templating is denoted by a true value
* @param int $failedValidationCode The HTTP response status code for a failed validation
* @param int $emptyContentCode HTTP response status code when the view data is null
* @param bool $serializeNull Whether or not to serialize null view data
* @param array $forceRedirects If to force a redirect for the given key format, with value being the status code to use
* @param string $defaultEngine default engine (twig, php ..)
* @param array $options config options
* @param UrlGeneratorInterface $urlGenerator The URL generator
* @param Serializer $serializer
* @param EngineInterface|Environment $templating The configured templating engine
* @param RequestStack $requestStack The request stack
* @param array $formats the supported formats as keys and if the given formats uses templating is denoted by a true value
* @param int $failedValidationCode The HTTP response status code for a failed validation
* @param int $emptyContentCode HTTP response status code when the view data is null
* @param bool $serializeNull Whether or not to serialize null view data
* @param array $forceRedirects If to force a redirect for the given key format, with value being the status code to use
* @param string $defaultEngine default engine (twig, php ..)
* @param array $options config options
*/
public function __construct(
UrlGeneratorInterface $urlGenerator,
Expand Down Expand Up @@ -363,7 +363,12 @@ public function createRedirectResponse(View $view, $location, $format)
public function renderTemplate(View $view, $format)
{
if (null === $this->templating) {
throw new \LogicException(sprintf('An instance of %s must be injected in %s to render templates.', EngineInterface::class, __CLASS__));
throw new \LogicException(sprintf(
'An instance of %s or %s must be injected in %s to render templates.',
EngineInterface::class,
Environment::class,
__CLASS__
));
}

$data = $this->prepareTemplateParameters($view);
Expand Down

0 comments on commit b02dc24

Please sign in to comment.