Skip to content

Commit

Permalink
Merge pull request #162 from xabbuh/patch-1
Browse files Browse the repository at this point in the history
compatibility of FilesystemLoader with Twig 2.0
  • Loading branch information
lsmith77 authored Jan 9, 2017
2 parents a02c6fb + 4a647d3 commit 685e4f3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Twig/Loader/FilesystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ public function setActiveTheme(ActiveTheme $activeTheme = null)
* Otherwise the template is located using the locator from the twig library.
*
* @param string|TemplateReferenceInterface $template The template
* @param bool $throw When true, a \Twig_Error_Loader exception will be thrown if a template could not be found
*
* @return string The path to the template file
*
* @throws \Twig_Error_Loader if the template could not be found
*/
protected function findTemplate($template)
protected function findTemplate($template, $throw = true)
{
$logicalName = (string) $template;

Expand Down Expand Up @@ -85,7 +86,11 @@ protected function findTemplate($template)
}

if (false === $file || null === $file) {
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $logicalName), -1, null, $previous);
if ($throw) {
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $logicalName), -1, null, $previous);
}

return false;
}

return $this->cache[$logicalName] = $file;
Expand Down

0 comments on commit 685e4f3

Please sign in to comment.