PHP Class Prado\Web\UI\WebControls\TConditional

TConditional displays appropriate content based on the evaluation result of a PHP expression specified via {@link setCondition Condition}. If the result is true, it instantiates the template {@link getTrueTemplate TrueTemplate}; otherwise, the template {@link getFalseTemplate FalseTemplate} is instantiated. The PHP expression is evaluated right before {@link onInit} stage of the control lifecycle. Since {@link setCondition Condition} is evaluated at a very early stage, it is recommended you set {@link setCondition Condition} in template and the expression should not refer to objects that are available on or after {@link onInit} lifecycle. A typical usage of TConditional is shown as following: Login Logout TConditional is very light. It instantiates either {@link getTrueTemplate TrueTemplate} or {@link getFalseTemplate FalseTemplate}, but never both. And the condition is evaluated only once.
Since: 3.1.1
Author: Qiang Xue ([email protected])
Inheritance: extends Prado\Web\UI\TControl
Exibir arquivo Open project: pradosoft/prado

Public Methods

Method Description
addParsedObject ( $object ) Processes an object that is created during parsing template.
createChildControls ( ) Creates child controls.
getCondition ( ) : string
getFalseTemplate ( ) : Prado\Web\UI\ITemplate
getTrueTemplate ( ) : Prado\Web\UI\ITemplate
setCondition ( $value ) Sets the PHP expression to be evaluated for conditionally displaying content.
setFalseTemplate ( Prado\Web\UI\ITemplate $value )
setTrueTemplate ( Prado\Web\UI\ITemplate $value )

Method Details

addParsedObject() public method

This method overrides the parent implementation by removing all contents enclosed in the template tag.
See also: createdOnTemplate
public addParsedObject ( $object )

createChildControls() public method

This method overrides the parent implementation. It evaluates {@link getCondition Condition} and instantiate the corresponding template.
public createChildControls ( )

getCondition() public method

public getCondition ( ) : string
return string the PHP expression used for determining which template to use. Defaults to 'true', meaning using TrueTemplate.

getFalseTemplate() public method

public getFalseTemplate ( ) : Prado\Web\UI\ITemplate
return Prado\Web\UI\ITemplate the template applied when {@link getCondition Condition} is false.

getTrueTemplate() public method

public getTrueTemplate ( ) : Prado\Web\UI\ITemplate
return Prado\Web\UI\ITemplate the template applied when {@link getCondition Condition} is true.

setCondition() public method

The context of the expression is the template control containing TConditional.
public setCondition ( $value )

setFalseTemplate() public method

public setFalseTemplate ( Prado\Web\UI\ITemplate $value )
$value Prado\Web\UI\ITemplate

setTrueTemplate() public method

public setTrueTemplate ( Prado\Web\UI\ITemplate $value )
$value Prado\Web\UI\ITemplate