当前位置: 首页>>代码示例>>PHP>>正文


PHP Engine::evaluate方法代码示例

本文整理汇总了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);
 }
开发者ID:icybee,项目名称:patron,代码行数:7,代码来源:EvaluateNode.php

示例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;
 }
开发者ID:icybee,项目名称:patron,代码行数:78,代码来源:ControlNode.php


注:本文中的Engine::evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。