本文整理汇总了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;
}
示例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())));
}
示例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;
}
示例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())));
}
示例5: testSetData
public function testSetData()
{
$this->entity->setData(['TEST' => 'TEST2']);
$this->assertEquals(['TEST' => 'TEST2'], $this->entity->getData());
}
示例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()));
}
示例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());
}