/**
  * @param AbstractViewComponent $component
  * @param string $templatePath
  * @param null $templateString
  * @param ResourceRepository $repo
  */
 public function __construct(AbstractViewComponent $component, $templatePath = null, $templateString = null, ResourceRepository $repo = null)
 {
     parent::__construct($component);
     $this->templatePath = $templatePath;
     $this->templateString = $templateString;
     // Optional Puli repo
     $this->repo = $repo;
 }
 /**
  * @param AbstractViewComponent $component
  * @param string $templatePath
  * @param null $templateString
  * @param ResourceRepository $repo
  */
 public function __construct(AbstractViewComponent $component, $templatePath = null, $templateString = null, ResourceRepository $repo = null)
 {
     parent::__construct($component);
     $this->templatePath = $templatePath;
     $this->templateString = $templateString;
     // Optional Puli repo
     $this->repo = $repo;
     Twig_Autoloader::register();
     $this->initTwig($this->getLoader());
 }
 /**
  * Entry point for rendering a component tree. Call updateView() first.
  * @param string|null $execMethodName An optional method on this or a subcomponent to execute before rendering
  * @param array|null $execArgs
  * @throws \Exception
  * @return Response
  */
 public function render($execMethodName = null, array $execArgs = null)
 {
     $this->state->validate();
     // updateState() on any component can call $this->getRootComponent()->forceResponse()
     // to force a particular response, usually a redirect.
     if (null !== $this->forceResponse) {
         return $this->forceResponse;
     }
     $this->initTemplate();
     // If we're called with an 'exec' then run it instead of rendering the whole tree.
     // It may still render the whole tree or it may just render a portion or just return JSON
     if ($execMethodName) {
         // Used to test for null but it could easily be an empty string
         $this->log("Rendering with exec: {$execMethodName}, args:" . var_export($execArgs, true), LogLevel::DEBUG);
         $out = $this->execMethod($execMethodName, $execArgs);
     } else {
         $this->log("Rendering without exec", LogLevel::DEBUG);
         $out = $this->template->render($this->state, $this->props);
         if (!$out instanceof Response) {
             throw new \Exception(get_class($this->template) . " returned invalid response. Should have been an instance of ViewComponentResponse");
         }
     }
     return $out;
 }