Prado\Web\UI\WebControls\TWebControlDecorator::ensureTemplateDecoration PHP Method

ensureTemplateDecoration() public method

This method places the templates around the open and close tag. This takes a parameter which is to specify the control to get the outer template decoration. If no outer control is specified
public ensureTemplateDecoration ( $sender = null, $param = null ) : boolean
return boolean returns true if the template decorations have been added
    public function ensureTemplateDecoration($sender = null, $param = null)
    {
        $control = $this->_control;
        $outercontrol = $this->_outercontrol;
        if ($outercontrol === null) {
            $outercontrol = $control;
        }
        if ($this->_addedTemplateDecoration) {
            return $this->_addedTemplateDecoration;
        }
        $this->_addedTemplateDecoration = true;
        if ($this->getPreContentsTemplate()) {
            $precontents = new TCompositeControl();
            $this->getPreContentsTemplate()->instantiateIn($precontents);
            $control->getControls()->insertAt(0, $precontents);
        }
        if ($this->getPostContentsTemplate()) {
            $postcontents = new TCompositeControl();
            $this->getPostContentsTemplate()->instantiateIn($postcontents);
            $control->getControls()->add($postcontents);
        }
        if (!$outercontrol->getParent()) {
            return $this->_addedTemplateDecoration;
        }
        if ($this->getPreTagTemplate()) {
            $pretag = new TCompositeControl();
            $this->getPreTagTemplate()->instantiateIn($pretag);
            $outercontrol->getParent()->getControls()->insertBefore($outercontrol, $pretag);
        }
        if ($this->getPostTagTemplate()) {
            $posttag = new TCompositeControl();
            $this->getPostTagTemplate()->instantiateIn($posttag);
            $outercontrol->getParent()->getControls()->insertAfter($outercontrol, $posttag);
        }
        return true;
    }