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


PHP Node::toArray方法代码示例

本文整理汇总了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();
 }
开发者ID:royalwang,项目名称:phphub-server,代码行数:11,代码来源:NodeTransformer.php

示例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;
 }
开发者ID:adminrt,项目名称:phphub-server,代码行数:13,代码来源:NodeTransformer.php

示例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;
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:6,代码来源:NodeMapper.php

示例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);
开发者ID:rafaelllins,项目名称:ytJsComponents,代码行数:11,代码来源:ajax-tree-sample.php

示例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());
开发者ID:fulldump,项目名称:8,代码行数:31,代码来源:Node.test.php

示例6: getThePropertiesAsAnArray

 /**
  * @test
  */
 public function getThePropertiesAsAnArray()
 {
     $properties = array('id' => 'xyz', 'foo' => 'bar', 'gggg' => 123);
     $node = new Node($properties);
     $this->assertEquals($properties, $node->toArray());
 }
开发者ID:bluem,项目名称:tree,代码行数:9,代码来源:NodeTest.php


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