本文整理匯總了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);
}