PHP Class Prado\Web\UI\TTemplateControl

TTemplateControl is the base class for all controls that use templates. By default, a control template is assumed to be in a file under the same directory with the control class file. They have the same file name and different extension name. For template file, the extension name is ".tpl".
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends TCompositeControl
Show file Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
createChildControls ( ) Creates child controls.
getIsSourceTemplateControl ( ) : boolean
getMaster ( ) : TTemplateControl | null
getMasterClass ( ) : string
getTemplate ( ) : Prado\Web\UI\ITemplate | null Returns the template object associated with this control object.
getTemplateDirectory ( ) : string
injectContent ( $id, $content ) Injects all content controls (and their children) to the corresponding content placeholders.
registerContent ( $id, TContent $object ) Registers a content control.
registerContentPlaceHolder ( $id, TContentPlaceHolder $object ) Registers a content placeholder to this template control.
setMasterClass ( $value )
setTemplate ( $value ) Sets the parsed template.
tryToUpdateAR ( TActiveRecord $arObj, boolean $throwExceptions = false ) Function to try to update an AR object with data in view controls.
tryToUpdateView ( TActiveRecord $arObj, boolean $throwExceptions = false ) Function to update view controls with data in a given AR object.

Protected Methods

Method Description
initRecursive ( $namingContainer = null ) Performs the OnInit step for the control and all its child controls.
loadTemplate ( ) : Prado\Web\UI\ITemplate Loads the template associated with this control class.

Method Details

createChildControls() public method

This method is overridden to load and instantiate control template. This method should only be used by framework and control developers.
public createChildControls ( )

getIsSourceTemplateControl() public method

public getIsSourceTemplateControl ( ) : boolean
return boolean whether this control is a source template control. A source template control loads its template from external storage, such as file, db, rather than from within another template.

getMaster() public method

public getMaster ( ) : TTemplateControl | null
return TTemplateControl | null master control associated with this control, null if none

getMasterClass() public method

public getMasterClass ( ) : string
return string master class name (in namespace form)

getTemplate() public method

Returns the template object associated with this control object.
public getTemplate ( ) : Prado\Web\UI\ITemplate | null
return Prado\Web\UI\ITemplate | null the parsed template, null if none

getTemplateDirectory() public method

public getTemplateDirectory ( ) : string
return string the directory containing the template. Empty if no template available.

initRecursive() protected method

This method overrides the parent implementation by ensuring child controls are created first, and if master class is set, master will be applied. Only framework developers should use this method.
protected initRecursive ( $namingContainer = null )

injectContent() public method

This method should only be used by framework and control developers.
public injectContent ( $id, $content )

loadTemplate() protected method

Loads the template associated with this control class.
protected loadTemplate ( ) : Prado\Web\UI\ITemplate
return Prado\Web\UI\ITemplate the parsed template structure

registerContent() public method

Registers a content control.
public registerContent ( $id, TContent $object )
$object Prado\Web\UI\WebControls\TContent

registerContentPlaceHolder() public method

This method should only be used by framework and control developers.
public registerContentPlaceHolder ( $id, TContentPlaceHolder $object )
$object Prado\Web\UI\WebControls\TContentPlaceHolder

setMasterClass() public method

public setMasterClass ( $value )

setTemplate() public method

Note, the template will be applied to the whole control class. This method should only be used by framework and control developers.
public setTemplate ( $value )

tryToUpdateAR() public method

Function to try to update an AR object with data in view controls.
Author: Daniel Sampedro ([email protected])
public tryToUpdateAR ( TActiveRecord $arObj, boolean $throwExceptions = false )
$arObj TActiveRecord
$throwExceptions boolean Wheter or not to throw exceptions

tryToUpdateView() public method

View controls and AR object need to have the same name in IDs and Attrs respectively.
Author: Daniel Sampedro ([email protected])
public tryToUpdateView ( TActiveRecord $arObj, boolean $throwExceptions = false )
$arObj TActiveRecord
$throwExceptions boolean Wheter or not to throw exceptions