本文整理汇总了PHP中Tree::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::getItems方法的具体用法?PHP Tree::getItems怎么用?PHP Tree::getItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::getItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getColumnsArray
/**
* Get column list as array (without tree architecture)
* @return array
*/
public function getColumnsArray()
{
$items = $this->_columns->getItems();
$data = array();
if (!empty($items)) {
foreach ($items as $k => $v) {
$data[$v['id']] = $v['data'];
}
}
return $data;
}
示例2: getSelectedObjects
/**
* Get list of selected objects
* @return array
*/
public function getSelectedObjects()
{
$result = array();
$partsArray = $this->_tree->getItems();
if (!empty($partsArray)) {
foreach ($partsArray as $part) {
$result[] = $part['data']->getObject();
}
}
return array_unique($result);
}
示例3: getObjectsByClass
/**
* Get objects by class
* @param string|array $class
* @return array, indexed by object name
*/
public function getObjectsByClass($class)
{
if (!is_array($class)) {
$class = array($class);
}
$class = array_map('ucfirst', $class);
$items = $this->_tree->getItems();
if (empty($items)) {
return array();
}
$result = array();
foreach ($items as $config) {
if (in_array($config['data']->getClass(), $class, true)) {
$result[$config['id']] = $config['data'];
}
}
return $result;
}
示例4: testGetItems
public function testGetItems()
{
$tree = new Tree();
$item = new stdClass();
$item->id = 1;
$tree->addItem($item->id, 0, $item);
$item2 = new stdClass();
$item2->id = 2;
$tree->addItem($item2->id, 1, $item2);
$data = $tree->getItems();
$this->assertTrue(is_array($data));
$this->assertEquals(count($data), 2);
$this->assertEquals($data[1]['data'], $item);
$this->assertEquals($data[2]['data'], $item2);
}