Skip to content

Kirby 5.0.0

$structure->when()

The when method only executes the given Closure when the first parameter is true. If the first parameter is false, the Closure will not be executed. You may pass another Closure as the third parameter to the when method. This Closure will execute if the first parameter evaluates as false

$structure->when(mixed $condition, Closure $callback, Closure|null $fallback = null)

Parameters

Name Type Default Description
$conditionrequired mixed no default value a truthy or falsy value
$callbackrequired Closure no default value
$fallback Closureornull null

Parent class

Kirby\Cms\Structure inherited from Kirby\Toolkit\Collection