Options=$options; $this->Parent=$parent; } public function GetParent() { return $this->Parent; } public abstract function IsEmpty(); public function GetLoader(){ return $this->GetEmailRenderer()->Loader; } /** * @return EmailRenderer */ public function GetEmailRenderer(){ if($this instanceof EmailRenderer) return $this; return $this->Parent->GetEmailRenderer(); } public function Initialize(){ $this->InternalInitialize(); } protected abstract function InternalInitialize(); public function GetTwigManager(){ return $this->GetLoader()->GetTwigManager(); } protected abstract function GetTemplateName(); public function Render(){ return $this->RenderTemplate($this->GetTemplateName(),$this); } public function RenderTemplate($templateName,$model) { if($templateName=='') throw new \Exception('Template not found'); return new Markup($this->GetTwigManager()->Render($templateName,$model),'UTF-8'); } /** * @return RendererBase[] */ public function GetChildren(){ return []; } /** * Whether this element should be rendered based on its conditions. * Override in subclasses to implement conditional visibility. * @return bool */ public function ShouldRender(){ return true; } public function RenderChildren(){ $markups=''; foreach($this->GetChildren() as $currentChildren) { if($currentChildren->IsEmpty()) continue; if(!$currentChildren->ShouldRender()) continue; $markups.=strval($currentChildren->Render()); } return new Markup($markups,'UTF-8'); } }