lithium\template\View::_conditions()
Evaluates a step condition to determine if the step should be executed.
Parameters
-
array
$step
The array of instructions that define a rendering step.
-
array
$params
The parameters associated with this rendering operation, as passed to
render()
(filtered from the$options
parameter). -
array
$data
The associative array of template variables passed to
render()
. -
array
$options
The
$options
parameter, as passed torender()
.
Returns
booleanReturns 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.
Source
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;
}