protected _conditions ( array $step, array $params, array $data, array $options ) : boolean | ||
$step | array | The array of instructions that define a rendering step. |
$params | array | The parameters associated with this rendering operation, as passed to `render()` (filtered from the `$options` parameter). |
$data | array | The associative array of template variables passed to `render()`. |
$options | array | The `$options` parameter, as passed to `render()`. |
return | boolean | Returns `true` if the step should be executed, or `false` if the step should be skipped. If the step array has a `'conditions'` key which is a string, it checks to see if the rendering options (`$options`) contain a key of the same name, and if that key evaluates to `true`. If `'conditions'` is a closure, that closure is executed with the rendering parameters (`$params`, `$data`, and `$options`), and the result is determined by the return value of the closure. If a step definition has no `'conditions'` key, it is always executed. |
protected function _conditions(array $step, array $params, array $data, array $options)
{
if (!($conditions = $step['conditions'])) {
return true;
}
$isCallable = is_callable($conditions) && !is_string($conditions);
if ($isCallable && !$conditions($params, $data, $options)) {
return false;
}
if (is_string($conditions) && !(isset($options[$conditions]) && $options[$conditions])) {
return false;
}
return true;
}