Skip to content

Instantly share code, notes, and snippets.

@rlandas
Created November 19, 2012 04:08
Show Gist options
  • Save rlandas/4108893 to your computer and use it in GitHub Desktop.
Save rlandas/4108893 to your computer and use it in GitHub Desktop.
ZF2: how to check if a view template exists from within a controller
$template = 'non/existant/template';
$resolver = $this->getEvent()
->getApplication()
->getServiceManager()
->get('Zend\View\Resolver\TemplatePathStack');
if (false === $resolver->resolve($template)) {
// does not exist
}
// @see http://stackoverflow.com/questions/12224176/how-to-check-if-a-zf2-view-template-exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment