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


PHP Signal::detectAction方法代码示例

本文整理汇总了PHP中Signal::detectAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Signal::detectAction方法的具体用法?PHP Signal::detectAction怎么用?PHP Signal::detectAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Signal的用法示例。


在下文中一共展示了Signal::detectAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fromJson

 /**
  * Create a signal collection from JSON string.
  *
  * @param  string $json
  * @return GraphCommons\Graph\SignalCollection
  * @throws GraphCommons\Util\JsonException, \InvalidArgumentException
  */
 public static final function fromJson(string $json) : SignalCollection
 {
     $json = new Json($json);
     if ($json->hasError()) {
         $jsonError = $json->getError();
         throw new JsonException(sprintf('JSON error: code(%d) message(%s)', $jsonError['code'], $jsonError['message']), $jsonError['code']);
     }
     $data = $json->decode(true);
     if (!isset($data['signals'])) {
         throw new \InvalidArgumentException("'signals' field is required!");
     }
     $array = array();
     foreach ($data['signals'] as $i => $signal) {
         if (!isset($signal['action'])) {
             throw new \InvalidArgumentException("Signal 'action' and 'parameters' fields are required!");
         }
         $array[$i]['action'] = Signal::detectAction(Util::arrayPick($signal, 'action'));
         foreach ($signal as $key => $value) {
             $array[$i]['parameters'][$key] = $value;
         }
     }
     return self::fromArray($array);
 }
开发者ID:graphcommons,项目名称:graphcommons-php7,代码行数:30,代码来源:SignalCollection.php

示例2: fillGraph

 /**
  * Fill a lib's graph object.
  *
  * @param  GraphCommons\Graph\Graph $graph
  * @param  array|object $g
  * @return GraphCommons\Graph\Graph
  */
 private final function fillGraph(Graph $graph, $g) : Graph
 {
     // force input being an object
     $g = Util::toObject($g);
     if (isset($g->id)) {
         $graph->setId($g->id)->setName($g->name)->setDescription($g->description)->setSubtitle($g->subtitle)->setStatus($g->status)->setCreatedAt($g->created_at);
         // add signals if exists
         if (isset($g->signals)) {
             $array = [];
             foreach ($g->signals as $i => $signal) {
                 $action = $signal->action;
                 unset($signal->action);
                 $array[$i]['action'] = Signal::detectAction($action);
                 $array[$i]['parameters'] = Util::toArray($signal);
             }
             $graph->setSignals(SignalCollection::fromArray($array));
         }
     }
     return $graph;
 }
开发者ID:graphcommons,项目名称:graphcommons-php7,代码行数:27,代码来源:GraphCommonsApi.php


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