本文整理汇总了PHP中Node::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::setValue方法的具体用法?PHP Node::setValue怎么用?PHP Node::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::setValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTextElement
function createTextElement($text)
{
$node = new Node();
$node->setType(TEXTELEMENT);
$node->setValue($text);
return $node;
}
示例2: xmlToObject
/**
* Converts an XML string into an object struct.
*
* @param string $data The XML string
*
* @return esXml The parsed XML
*/
private function xmlToObject($data)
{
$root = new Node();
$root->setName('root');
$actualLevel = 1;
$actualNode = $root;
$stack = array();
$stack[1] = $root;
foreach ($this->parseIntoStruct($data) as $element) {
if ($element['type'] === 'close') {
continue;
}
$node = new Node();
$node->setName($element['tag']);
if (isset($element['attributes'])) {
$node->setAttributes($element['attributes']);
}
if (isset($element['value'])) {
$node->setValue($element['value']);
}
$level = $element['level'];
if ($level > $actualLevel) {
$stack[$level] = $actualNode;
}
$stack[$level]->addChild($node);
$actualNode = $node;
$actualLevel = $element['level'];
}
$children = $root->getChildren();
unset($root);
return $children[0]->setParent(null);
}
示例3: __construct
/**
* @param array $config
* @param array $params
* @throws ApiRequestException
*/
public function __construct(array $config, array $params = [])
{
$filterNode = new Node('filter');
if (isset($params['key'])) {
$filterNode->setValue(new Node('key', $params['key']));
}
if (isset($params['keys']) && is_array($params['keys'])) {
$nodes = [];
foreach ($params['keys'] as $key) {
$nodes[] = new Node('key', $key);
}
$filterNode->setValue(new NodeList($nodes));
}
$params['filter'] = $filterNode;
parent::__construct($config, $params);
}
示例4: insertFirst
/**
* 头插法
* @param unknown_type $value
*/
public function insertFirst($value)
{
$new = new Node(null, $value);
$new->setValue($value);
$new->next = $this->head->next;
$this->head->next = $new;
}
示例5: readType
/**
* Read an individual type from the stream.
*
* @param resource $fPtr Stream pointer
* @param int $tagType Tag to read
* @param Node $node Node to add data to
*
* @return mixed
*/
private function readType($fPtr, $tagType, Node $node)
{
switch ($tagType) {
case Tag::TAG_BYTE:
// Signed byte (8 bit)
$node->setValue($this->dataHandler->getTAGByte($fPtr));
break;
case Tag::TAG_SHORT:
// Signed short (16 bit, big endian)
$node->setValue($this->dataHandler->getTAGShort($fPtr));
break;
case Tag::TAG_INT:
// Signed integer (32 bit, big endian)
$node->setValue($this->dataHandler->getTAGInt($fPtr));
break;
case Tag::TAG_LONG:
// Signed long (64 bit, big endian)
$node->setValue($this->dataHandler->getTAGLong($fPtr));
break;
case Tag::TAG_FLOAT:
// Floating point value (32 bit, big endian, IEEE 754-2008)
$node->setValue($this->dataHandler->getTAGFloat($fPtr));
break;
case Tag::TAG_DOUBLE:
// Double value (64 bit, big endian, IEEE 754-2008)
$node->setValue($this->dataHandler->getTAGDouble($fPtr));
break;
case Tag::TAG_BYTE_ARRAY:
// Byte array
$node->setValue($this->dataHandler->getTAGByteArray($fPtr));
break;
case Tag::TAG_STRING:
// String
$node->setValue($this->dataHandler->getTAGString($fPtr));
break;
case Tag::TAG_INT_ARRAY:
$node->setValue($this->dataHandler->getTAGIntArray($fPtr));
break;
case Tag::TAG_LIST:
// List
$tagID = $this->dataHandler->getTAGByte($fPtr);
$listLength = $this->dataHandler->getTAGInt($fPtr);
// Add a reference to the payload type
$node->setPayloadType($tagID);
for ($i = 0; $i < $listLength; ++$i) {
if (feof($fPtr)) {
break;
}
$listNode = new Node();
$this->readType($fPtr, $tagID, $listNode);
$node->addChild($listNode);
}
break;
case Tag::TAG_COMPOUND:
// Compound
// Uck. Don't know a better way to do this,
$compoundNode = new Node();
while ($this->traverseTag($fPtr, $compoundNode)) {
$node->addChild($compoundNode);
// Reset the node for adding the next tags
$compoundNode = new Node();
}
break;
}
}