ConditionInterface ​
- Type
- Interface
- Namespace
- craft\base\conditions
- Implemented by
- craft\base\conditions\BaseCondition, craft\elements\conditions\ElementCondition, craft\elements\conditions\ElementConditionInterface, craft\elements\conditions\addresses\AddressCondition, craft\elements\conditions\assets\AssetCondition, craft\elements\conditions\categories\CategoryCondition, craft\elements\conditions\entries\EntryCondition, craft\elements\conditions\tags\TagCondition, craft\elements\conditions\users\UserCondition
- Since
- 4.0.0
ConditionInterface defines the common interface to be implemented by condition classes.
A base implementation is provided by craft\base\conditions\BaseCondition.
Public Methods ​
Method | Description |
---|---|
addConditionRule() | Adds a rule to the condition. |
getBuilderHtml() | Renders the HTML for the condition builder, including its outer container element. |
getBuilderInnerHtml() | Renders the inner HTML for the condition builder, excluding its outer container element. |
getConditionRuleTypes() | Returns the available rule types for this condition. |
getConditionRules() | Returns the rules this condition is configured with. |
getConfig() | Returns the condition’s portable config. |
getSelectableConditionRules() | Returns the selectable rules for the condition, indexed by type. |
setConditionRules() | Sets the rules this condition should be configured with. |
addConditionRule()
​
Adds a rule to the condition.
Arguments ​
Throws ​
- yii\base\InvalidArgumentException
if the rule is not selectable
getBuilderHtml()
​
Renders the HTML for the condition builder, including its outer container element.
Returns ​
getBuilderInnerHtml()
​
Renders the inner HTML for the condition builder, excluding its outer container element.
Arguments ​
$autofocusAddButton
(boolean) – Whether the Add Rule button should be autofocused
Returns ​
getConditionRuleTypes()
​
Returns the available rule types for this condition.
Rule types should be defined as either the class name or an array with a class
key set to the class name.
Returns ​
getConditionRules()
​
Returns the rules this condition is configured with.
Returns ​
craft\base\conditions\ConditionRuleInterface[]
getConfig()
​
Returns the condition’s portable config.
Returns ​
getSelectableConditionRules()
​
Returns the selectable rules for the condition, indexed by type.
Returns ​
craft\base\conditions\ConditionRuleInterface[]
setConditionRules()
​
Sets the rules this condition should be configured with.
Arguments ​
$rules
(craft\base\conditions\ConditionRuleInterface[], array[])
Throws ​
- yii\base\InvalidArgumentException
if any of the rules are not selectable