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. |
createConditionRule() | Creates a condition rule instance. |
getBuilderConfig() | Returns configuration that should be maintained for the builder. |
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. |
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
createConditionRule()
​
Creates a condition rule instance.
Arguments ​
Returns ​
craft\base\conditions\ConditionRuleInterface
Throws ​
- yii\base\InvalidArgumentException
if the condition rule does not implement craft\base\conditions\ConditionRuleInterface
getBuilderConfig()
​
- Since
- 5.1.0
Returns configuration that should be maintained for the builder.
Returns ​
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 ​
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