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


PHP Gateway::find方法代码示例

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


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

示例1: getDelete

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function getDelete($id)
 {
     $gateway = Gateway::find($id);
     $gateway->delete();
     Event::fire('logger', array(array('gateway_remove', array('id' => $id, 'gateway_name' => $gateway->gateway_name), 2)));
     return Output::push(array('path' => 'gateway', 'messages' => array('success' => _('Gateway has been deleted'))));
 }
开发者ID:digideskio,项目名称:voip-id,代码行数:13,代码来源:GatewayController.php

示例2: updateGatewayStatusFromInflux

 public static function updateGatewayStatusFromInflux($since = null, $interval = '1h')
 {
     $config = DI::getDefault()->getConfig();
     $database = DI::getDefault()->getInfluxdb();
     if (is_null($since)) {
         if (!preg_match('/\\d{1,10}[smhd]{1}/', $interval)) {
             echo 'Malformed interval';
             return false;
         }
         $result = $database->query("SELECT * FROM gateway_status WHERE time > (NOW() - {$interval}) GROUP BY eui;");
     } else {
         $localTimezone = new DateTimeZone($config->monitor->localTimezone);
         $localSince = new DateTime($since, $localTimezone);
         $maxSince = self::getCurrentLocalDateTime();
         $maxSince->modify($config->monitor->maxSinceOffset);
         // make sure we're not querying too much in the past, which would result in many entries returned and either influxdb quitting or php crashing
         if ($localSince < $maxSince) {
             $localSince = $maxSince;
         }
         $influxTimezone = new DateTimeZone($config->monitor->influxTimezone);
         $influxSince = clone $localSince;
         $influxSince = $influxSince->setTimezone($influxTimezone);
         $result = $database->query("SELECT * FROM gateway_status WHERE time > '" . $influxSince->format('Y-m-d H:i:s.u') . "' GROUP BY eui;");
     }
     $now = self::getCurrentLocalDateTime();
     $gatewaysProcessed = array();
     foreach ($result->getSeries() as $serie) {
         $eui = $serie['tags']['eui'];
         $numberOfValues = count($serie['values']);
         $lastValue = $serie['values'][$numberOfValues - 1];
         $valueIndex = array_flip($serie['columns']);
         $gateway = Gateway::findFirstByEui($eui);
         $gateway->last_seen = self::prepareForDb(self::convertToLocalTimezone($lastValue[$valueIndex['time']]));
         $gateway->location = $lastValue[$valueIndex['latitude']] . ',' . $lastValue[$valueIndex['longitude']];
         $gateway->updated_at = self::prepareForDb($now);
         $statusUpdate = new StatusUpdate();
         $statusUpdate->update_time = self::prepareForDb($now);
         if (is_null($since)) {
             $statusUpdate->interval = $interval;
         } else {
             $statusUpdate->since_time = self::prepareForDb($localSince);
         }
         $statusUpdate->entries_seen = $numberOfValues;
         $gateway->StatusUpdate = $statusUpdate;
         if (!$gateway->save()) {
             foreach ($gateway->getMessages() as $message) {
                 echo $message;
             }
         } else {
             $gatewaysProcessed[] = $eui;
         }
     }
     // make sure that gateways that did not send a recent message to influx get updated
     $allGateways = Gateway::find();
     foreach ($allGateways as $gateway) {
         if (!in_array($gateway->eui, $gatewaysProcessed)) {
             $gateway->updated_at = self::prepareForDb($now);
             $gateway->save();
         }
     }
 }
开发者ID:nnikos123,项目名称:gateway-status,代码行数:61,代码来源:Gateway.php

示例3: function

    if (is_null($team)) {
        return App::abort(404);
    } else {
        return $team;
    }
});
Route::bind('donation', function ($value) {
    $donation = Donation::find($value);
    if (is_null($donation)) {
        return App::abort(404);
    } else {
        return $donation;
    }
});
Route::bind('gateway', function ($value) {
    $gateway = Gateway::find($value);
    if (is_null($gateway)) {
        return App::abort(404);
    } else {
        return $gateway;
    }
});
/*
|--------------------------------------------------------------------------
| Legacy URLs
|--------------------------------------------------------------------------
|
| These are the old URLs for original vataware. When possible it should be
| a 301 (permanent redirect). This is not always possible though.
|
*/
开发者ID:T-SummerStudent,项目名称:new,代码行数:31,代码来源:routes.php

示例4: function

 * Local variables
 * @var \Phalcon\Mvc\Micro $app
 */
/**
 * Add your routes here
 */
$app->get('/', function () use($app) {
    $gateways = Gateway::find();
    $lastEntry = Gateway::getLastEntry();
    // this isn't 100% correct: if all gateways are down, the last update datetime won't be the same as the actual update time. Otherwise the update datetime could be up to gateway-update-interval off
    echo $app['view']->render('index', array('gateways' => $gateways, 'lastUpdate' => $lastEntry->last_seen));
});
$app->get('/gateways', function () use($app) {
    $response = new Phalcon\Http\Response();
    $response->setContentType('application/json');
    $gateways = Gateway::find();
    $gatewaysArray = array();
    foreach ($gateways as $gateway) {
        $gatewayArray = $gateway->toArray();
        unset($gatewayArray['ID']);
        $gatewaysArray[] = $gatewayArray;
    }
    // Pass the content of a file
    $response->setContent(json_encode($gatewaysArray));
    return $response;
});
$app->get('/gateways/{eui}', function ($eui) use($app) {
    $response = new Phalcon\Http\Response();
    $response->setContentType('application/json');
    $gateway = Gateway::findFirstByEui($eui);
    if (empty($gateway)) {
开发者ID:nnikos123,项目名称:gateway-status,代码行数:31,代码来源:app.php


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