/** * @param string|null $template * * @return \Twig_Template * * @throws WorkflowException * @throws TemplateException */ private function loadTemplate($template = null) { if (null === $this->twigEnvironment) { throw WorkflowException::twigNotDefined(); } $template = $template ?: $this->defaultTemplate; try { return $this->twigEnvironment->loadTemplate($template); } catch (\Exception $e) { throw TemplateException::twigTemplateNotFound($template, $e); } }