public function setTemplate($template)
    {
        if (!(is_string($template) || $template instanceof TemplateReferenceInterface)) {
            throw new \InvalidArgumentException('The template should be a string or implement TemplateReferenceInterface');
        }
        $this->template = $template;

        return $this;
    }