public function getBranchItems($pk = null, $filter = null, $fields = null, $scope = null, $depth = 1, $limit = null, $offset = null, $withAcl = false)
{
$storageController = $this->objects->getStorageController($this->getObject());
if (null !== $pk) {
$pk = $storageController->normalizePrimaryKey($pk);
}
if (null === $pk && $this->getObjectDefinition()->getNestedRootAsObject() && $scope === null) {
throw new \Exception('No scope defined.');
}
$options = array();
$options['offset'] = $offset;
$options['limit'] = $limit ? $limit : $this->defaultLimit;
$options['fields'] = $this->getBranchItemsSelection($fields);
//
// if (!$fields) {
// $fields = array();
// $fields[] = $this->getObjectDefinition()->getLabelField();
//
// if ($rootField = $this->getObjectDefinition()->getNestedRootObjectLabelField()) {
// $fields[] = $rootField;
// }
//
// if ($extraFields = $this->getObjectDefinition()->getNestedRootObjectExtraFields()) {
// $extraFields = explode(',', trim(str_replace(' ', '', $extraFields)));
// foreach ($extraFields as $field) {
// $fields[] = $field;
// }
// }
// $options['fields'] = implode(',', $fields);
// }
// if ($filter) {
// $conditionObject = $filter instanceof Condition ? $filter : self::buildFilter($filter);
// } else {
$conditionObject = $this->getCondition();
// }
if ($limit = $this->getObjectDefinition()->getLimitDataSets()) {
$conditionObject->mergeAnd($limit);
}
if ($extraCondition = $this->getCustomListingCondition()) {
$conditionObject->mergeAnd($extraCondition);
}
if ($this->getPermissionCheck() && ($aclCondition = $this->acl->getListingCondition($this->getObject()))) {
$conditionObject->mergeAndBegin($aclCondition);
}
$options['order'] = $this->getOrder();
$items = $storageController->getBranch($pk, $conditionObject, $depth, $scope, $options);
if ($withAcl && is_array($items)) {
foreach ($items as &$item) {
$this->prepareRow($item);
}
}
return $items;
}