本文整理汇总了PHP中Engine::evaluate方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine::evaluate方法的具体用法?PHP Engine::evaluate怎么用?PHP Engine::evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine::evaluate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* @inheritdoc
*/
protected function render($expression)
{
return $this->engine->evaluate($expression, false, $this->engine_context);
}
示例2: __invoke
public function __invoke(Engine $engine, $context)
{
$name = $this->name;
list($callback, $params) = $engine->markups[$name];
$args = $this->args;
$missing = [];
$binding = empty($params['no-binding']);
foreach ($params as $param => $options) {
if (is_array($options)) {
#
# default value
#
if (isset($options['default']) && !array_key_exists($param, $args)) {
$args[$param] = $options['default'];
}
if (array_key_exists($param, $args)) {
$value = $args[$param];
if (isset($options['expression'])) {
$silent = !empty($options['expression']['silent']);
//\ICanBoogie\log('\4:: evaluate expression "\3" with value: \5, params \1 and args \2', array($hook->params, $args, $param, $name, $value));
if ($value[0] == ':') {
$args[$param] = substr($value, 1);
} else {
$args[$param] = $engine->evaluate($value, $silent, $context);
}
}
} else {
if (isset($options['required'])) {
$missing[$param] = true;
}
}
} else {
if (!array_key_exists($param, $args)) {
$args[$param] = $options;
}
}
if (!isset($args[$param])) {
$args[$param] = null;
}
}
if ($missing) {
throw new \Exception(\ICanBoogie\format('The %param parameter is required for the %markup markup, given %args', ['%param' => implode(', ', array_keys($missing)), '%markup' => $name, '%args' => json_encode($args)]));
}
#
# resolve arguments
#
foreach ($args as &$arg) {
if ($arg instanceof ControlNode) {
if (isset($arg->args['select'])) {
$arg = $engine->evaluate($arg->args['select'], false, $context);
} else {
$arg = $engine($arg->nodes);
}
}
}
unset($arg);
#
# call hook
#
$engine->trace_enter(['markup', $name]);
if ($binding) {
array_push($engine->context_markup, [$engine->context['self'], $engine->context['this']]);
$engine->context['self'] = ['name' => $name, 'arguments' => $args];
}
$rc = null;
try {
$rc = call_user_func($callback, $args, $engine, $this->nodes);
} catch (\Exception $e) {
$engine->handle_exception($e);
}
if ($binding) {
$a = array_pop($engine->context_markup);
$engine->context['self'] = $a[0];
$engine->context['this'] = $a[1];
}
$engine->trace_exit();
return $rc;
}