Skip to content

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.

View source

Public Methods ​

MethodDescription
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.

View source

Arguments ​

Throws ​

createConditionRule() ​

Creates a condition rule instance.

View source

Arguments ​

  • $config (array, string) – The condition class or configuration array

Returns ​

craft\base\conditions\ConditionRuleInterface

Throws ​

getBuilderConfig() ​

Since
5.1.0

Returns configuration that should be maintained for the builder.

View source

Returns ​

array

getBuilderHtml() ​

Renders the HTML for the condition builder, including its outer container element.

View source

Returns ​

string

getBuilderInnerHtml() ​

Renders the inner HTML for the condition builder, excluding its outer container element.

View source

Arguments ​

  • $autofocusAddButton (boolean) – Whether the Add Rule button should be autofocused

Returns ​

string

getConditionRules() ​

Returns the rules this condition is configured with.

View source

Returns ​

craft\base\conditions\ConditionRuleInterface[]

getConfig() ​

Returns the condition’s portable config.

View source

Returns ​

array

getSelectableConditionRules() ​

Returns the selectable rules for the condition, indexed by type.

View source

Returns ​

craft\base\conditions\ConditionRuleInterface[]

setConditionRules() ​

Sets the rules this condition should be configured with.

View source

Arguments ​

Throws ​