PHP Класс 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.
С версии: 3.1.1
Автор: Qiang Xue ([email protected])
Наследование: extends Prado\Web\UI\TControl
Показать файл Открыть проект

Открытые методы

Метод Описание
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 )

Описание методов

addParsedObject() публичный Метод

This method overrides the parent implementation by removing all contents enclosed in the template tag.
См. также: createdOnTemplate
public addParsedObject ( $object )

createChildControls() публичный Метод

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

getCondition() публичный Метод

public getCondition ( ) : string
Результат string the PHP expression used for determining which template to use. Defaults to 'true', meaning using TrueTemplate.

getFalseTemplate() публичный Метод

public getFalseTemplate ( ) : Prado\Web\UI\ITemplate
Результат Prado\Web\UI\ITemplate the template applied when {@link getCondition Condition} is false.

getTrueTemplate() публичный Метод

public getTrueTemplate ( ) : Prado\Web\UI\ITemplate
Результат Prado\Web\UI\ITemplate the template applied when {@link getCondition Condition} is true.

setCondition() публичный Метод

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

setFalseTemplate() публичный Метод

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

setTrueTemplate() публичный Метод

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