Skip to main content

GravityKit\GravityMigrate\Schema\UniversalConditionalLogic

The rules deciding whether a field appears, or a notification sends, or a confirmation runs.

Three things: what happens when the rules match, whether every rule must match or only one, and the rules. Every platform expresses that, and every platform spells it differently. Fluent nests it under conditional_logics with a status flag and a type of any or all; Gravity Forms uses actionType and logicType; Formidable spreads it across four keys on the field.

A partial rule set is never valid. Dropping a rule from an "all" relation widens when the thing appears, and dropping one from an "any" relation narrows it; either way the form behaves differently from the one somebody built, silently. A set that lost a rule in translation is refused whole rather than trimmed, so all_of()/any_of() return null when handed one.

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:25

Details

  • Kind: class
  • Namespace: GravityKit\GravityMigrate\Schema

Methods

MethodDescription
all_of()Logic that matches when every rule matches.
any_of()Logic that matches when any rule matches.
to_array()The rule set as plain data.
from_array()Reads a rule set back, or refuses it.
get_action()What happens when the rules match.
set_action()Whether the rules show or hide.
shows()Whether this shows when matched.
matches_all()Whether every rule must match.
get_match()Whether every rule must match, or only one.
get_rules()The rules.
referenced_field_ids()The fields these rules test.

Method Reference

all_of()

public static function all_of( array $rules ): ?self

Logic that matches when every rule matches.

Parameters

NameTypeDefaultDescription
$rulesLogicRule[]The rules. Any null entry refuses the whole set.

Returns

  • self | null

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:105

any_of()

public static function any_of( array $rules ): ?self

Logic that matches when any rule matches.

Parameters

NameTypeDefaultDescription
$rulesLogicRule[]The rules. Any null entry refuses the whole set.

Returns

  • self | null

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:118

to_array()

public function to_array(): array

The rule set as plain data.

Returns

  • array{action: — string, match: string, rules: array[]}

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:154

from_array()

public static function from_array( $logic ): ?self

Reads a rule set back, or refuses it.

Parameters

NameTypeDefaultDescription
$logicmixedCandidate rule set, in the shape to_array() writes.

Returns

  • self | null

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:177

get_action()

public function get_action(): string

What happens when the rules match.

Returns

  • string

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:205

set_action()

public function set_action( string $action ): self

Whether the rules show or hide.

Parameters

NameTypeDefaultDescription
$actionstringOne of ACTION_SHOW or ACTION_HIDE.

Returns

  • self

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:218

shows()

public function shows(): bool

Whether this shows when matched.

Returns

  • bool

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:231

matches_all()

public function matches_all(): bool

Whether every rule must match.

Returns

  • bool

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:242

get_match()

public function get_match(): string

Whether every rule must match, or only one.

Returns

  • string

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:253

get_rules()

public function get_rules(): array

The rules.

Returns

  • LogicRule[]

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:264

referenced_field_ids()

public function referenced_field_ids(): array

The fields these rules test.

Returns

  • array — Field ids, deduplicated, in the order the rules name them.

Since: %ver%

Source: src/Schema/UniversalConditionalLogic.php:275