本文整理汇总了PHP中Node::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::toArray方法的具体用法?PHP Node::toArray怎么用?PHP Node::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::toArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transformData
/**
* Transform the \Node entity.
*
* @param \Node $model
*
* @return array
*/
public function transformData($model)
{
return $model->toArray();
}
示例2: transformData
/**
* Transform the \Node entity.
*
* @param \Node $model
*
* @return array
*/
public function transformData($model)
{
$data = $model->toArray();
$data['parent_node'] = $model->parent_node ?: 0;
return $data;
}
示例3: nodeToPersistentArray
public function nodeToPersistentArray(Node $obj)
{
$persistent = array_intersect_key($obj->toArray(), array_flip($this->NodeDBMeta->getPersistentFields()));
$persistent['ElementID'] = $obj->getNodeRef()->getElement()->getElementID();
return $persistent;
}
示例4: json_encode
<?php
require_once 'Node.php';
$nodes = array();
$node = new Node("Titutlo A1", "A1", true, true, true, array(new Node("Titutlo A1.B1", "A1.B1", true, true, true), new Node("Titutlo A1.B2", "A1.B2", true, true, true, array(new Node("Titutlo A1.B2.C1", "A1.B2.C1", true, true, true)))));
$node2 = new Node("Titutlo A2", "A2", true, true, true, array(new Node("Titutlo A2.B1", "A2.B1", true, true, true, array(new Node("Titutlo A2.B1.C1", "A2.B1.C1"), new Node("Titutlo A2.B1.C2", "A2.B1.C2"), new Node("Titutlo A2.B1.C3", "A2.B1.C3")))));
$node3 = new Node("Titutlo A3", "A3");
array_push($nodes, $node->toArray());
array_push($nodes, $node2->toArray());
array_push($nodes, $node3->toArray());
echo json_encode($nodes);
示例5: function
$pass = false;
echo "Must return false\n";
}
// Print
$root->print_r();
return $pass;
};
$tests['fromArray toArray'] = function () {
$pass = true;
// Prepare
$json = '{"id":"c170ad596fb6f987f0b34bf58099ca63","properties":[],"children":{"a":{"id":"2d63f222710222663373b0692b273103","properties":[],"children":{"b":{"id":"dc3a2e4652f068bad6f78e71920483f8","properties":[],"children":{"c":{"id":"63f5f8032383f518381541e2053b9213","properties":[],"children":[]},"d":{"id":"1f3b9cf313b126f9ed03739730d58eed","properties":[],"children":[]}}},"e":{"id":"5049e43d9fd9576aa0e715d9bd8dea20","properties":[],"children":{"f":{"id":"f8a45a93ed68521a7d4c23b7918b13b3","properties":[],"children":[]},"g":{"id":"a95c67d9ebdbc4f3fb175242fb1307eb","properties":[],"children":[]}}}}}}}';
$array = json_decode($json, true);
// Run
$root = new Node();
$root->fromArray($array);
$result = $root->toArray();
$result_json = json_encode($result);
// Check
if ($json !== $result_json) {
$pass = false;
echo "Serialization fail\n";
}
// Print
echo "{$json}\n{$result_json}";
return $pass;
};
$tests['get property'] = function () {
$pass = true;
// Prepare
$hash_red = md5(microtime());
$hash_blue = md5(microtime());
示例6: getThePropertiesAsAnArray
/**
* @test
*/
public function getThePropertiesAsAnArray()
{
$properties = array('id' => 'xyz', 'foo' => 'bar', 'gggg' => 123);
$node = new Node($properties);
$this->assertEquals($properties, $node->toArray());
}