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


PHP Entity::getData方法代码示例

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


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

示例1: post2

 /**
  * send a message to specified fluentd.
  *
  * @todo use HTTP1.1 protocol and persistent socket.
  * @param string $tag
  * @param array  $data
  */
 public function post2(Entity $entity)
 {
     $packed = json_encode($entity->getData());
     $request = sprintf('http://%s:%d/%s?json=%s', $this->host, $this->port, $entity->getTag(), urlencode($packed));
     $ret = file_get_contents($request);
     return $ret !== false;
 }
开发者ID:nagyist,项目名称:fluent-logger-php,代码行数:14,代码来源:HttpLogger.php

示例2: postImpl

 /**
  * @param Entity $entity
  * @return int
  */
 protected function postImpl(Entity $entity)
 {
     /*
      * example ouputs:
      *   2012-02-26T01:26:20+0900        debug.test      {"hello":"world"}
      */
     $format = "%s\t%s\t%s\n";
     return $this->write(sprintf($format, date(\DateTime::ISO8601, $entity->getTime()), $entity->getTag(), json_encode($entity->getData())));
 }
开发者ID:cy-katsuhiro-miura,项目名称:fuelphp-with-fluentd,代码行数:13,代码来源:ConsoleLogger.php

示例3: postImpl

 protected function postImpl(Entity $entity)
 {
     $packed = json_encode($entity->getData());
     $data = $wbuffer = sprintf("%s\t%s\t%s", date(\DateTime::ISO8601, $entity->getTime()), $entity->getTag(), $packed . PHP_EOL);
     $length = strlen($data);
     $written = 0;
     $retry = 0;
     try {
         if (!flock($this->fp, LOCK_EX)) {
             throw new \Exception('could not obtain LOCK_EX');
         }
         fseek($this->fp, 0, SEEK_END);
         while ($written < $length) {
             $nwrite = fwrite($this->fp, $wbuffer);
             if ($nwrite === false) {
                 throw new \Exception("could not write message");
             } else {
                 if ($nwrite === "") {
                     throw new \Exception("connection aborted");
                 } else {
                     if ($nwrite === 0) {
                         if ($retry > self::MAX_WRITE_RETRY) {
                             throw new \Exception("failed fwrite retry: max retry count");
                         }
                         $retry++;
                     }
                 }
             }
             $written += $nwrite;
             $wbuffer = substr($wbuffer, $written);
         }
         flock($this->fp, LOCK_UN);
     } catch (\Exception $e) {
         $this->processError($this, $entity, $e->getMessage());
         return false;
     }
     return true;
 }
开发者ID:andgorrie,项目名称:fluent-logger-php,代码行数:38,代码来源:FileLogger.php

示例4: defaultErrorHandler

 public function defaultErrorHandler(BaseLogger $logger, Entity $entity, $error)
 {
     error_log(sprintf("ChainLogger: %s %s %s: %s", get_class($logger), $error, $entity->getTag(), json_encode($entity->getData())));
 }
开发者ID:cy-katsuhiro-miura,项目名称:fuelphp-with-fluentd,代码行数:4,代码来源:ChainLogger.php

示例5: testSetData

 public function testSetData()
 {
     $this->entity->setData(['TEST' => 'TEST2']);
     $this->assertEquals(['TEST' => 'TEST2'], $this->entity->getData());
 }
开发者ID:jarick,项目名称:bx,代码行数:5,代码来源:EntityTest.php

示例6: pack

 /**
  * pack entity as a json string.
  *
  * @param Entity $entity
  * @return string
  */
 public function pack(Entity $entity)
 {
     return json_encode(array($entity->getTag(), $entity->getTime(), $entity->getData()));
 }
开发者ID:cy-katsuhiro-miura,项目名称:fuelphp-with-fluentd,代码行数:10,代码来源:JsonPacker.php

示例7: offsetSet

 /**
  * @param string $offset
  * @param Entity $value
  * @return NULL
  */
 public function offsetSet($offset, $value)
 {
     $this->data[$offset] = $value;
     return $this->selection->offsetSet($offset, $value->getData());
 }
开发者ID:redwormik,项目名称:fakeorm,代码行数:10,代码来源:Repository.php


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