Jarves\Admin\ObjectCrud::getItems PHP Method

getItems() public method

array( 'items' => $items, 'count' => $maxItems, 'pages' => $maxPages );
public getItems ( array $filter = null, integer $limit = null, integer $offset = null, string $query = '', string $fields = null, array $orderBy = [], boolean $withAcl = false, array $primaryKeys = [] ) : array
$filter array
$limit integer
$offset integer
$query string
$fields string
$orderBy array
$withAcl boolean
$primaryKeys array
return array
    public function getItems($filter = null, $limit = null, $offset = null, $query = '', $fields = null, $orderBy = [], $withAcl = false, array $primaryKeys = [])
    {
        $options = array();
        $storageController = $this->objects->getStorageController($this->getObject());
        $options['offset'] = $offset;
        $options['limit'] = $limit ? $limit : $this->defaultLimit;
        $condition = $this->getCondition();
        if ($extraCondition = $this->getCustomListingCondition()) {
            $condition->mergeAnd($extraCondition);
        }
        $options['order'] = $orderBy ?: $this->getOrder();
        $options['fields'] = $this->getItemsSelection($fields);
        $options['permissionCheck'] = $this->getPermissionCheck();
        $aclRequest = ACLRequest::create($this->getObject())->onlyListingMode();
        if ($this->getPermissionCheck() && !$this->acl->check($aclRequest)) {
            return null;
        }
        if ($limit = $this->getObjectDefinition()->getLimitDataSets()) {
            $condition->mergeAnd($limit);
        }
        if ($this->getMultiLanguage() && $this->getLanguage()) {
            if ($this->getObjectDefinition()->getNestedRootAsObject() && ($rootObjectKey = $this->getObjectDefinition()->getNestedRootObject())) {
                $rootObjects = $this->objects->getList($rootObjectKey, null, ['lang' => $this->getLanguage(), 'fields' => 'id']);
                $langConditions = new Condition();
                foreach ($rootObjects as $item) {
                    $langConditions->addOr(['domain', '=', $item['id']]);
                }
                $condition->addAnd($langConditions);
            } else {
                //does the object have a lang field?
                if ($this->objectDefinition->hasField('lang') && !isset($filter['lang'])) {
                    $filter['lang'] = $this->getLanguage();
                }
            }
        }
        if ($query) {
            if ($queryCondition = $this->getQueryCondition($query, $options['fields'])) {
                $condition->mergeAnd($queryCondition);
            }
        }
        if ($primaryKeys) {
            $primaryKeyCondition = Condition::create();
            foreach ($primaryKeys as $pk) {
                $primaryKeyConditionItem = Condition::create();
                foreach ($this->getObjectDefinition()->getPrimaryKeyNames() as $primaryKeyName) {
                    if (!isset($pk[$primaryKeyName])) {
                        throw new \LogicException(sprintf('Field %s not found in primaryKey parameter (%s)', $primaryKeyName, json_encode($pk)));
                    }
                    $primaryKeyConditionItem->addAnd([$primaryKeyName, '=', $pk[$primaryKeyName]]);
                }
                $primaryKeyCondition->mergeOr($primaryKeyConditionItem);
            }
            $condition->mergeAndBegin($primaryKeyCondition);
        }
        if ($this->getPermissionCheck() && ($aclCondition = $this->acl->getListingCondition($this->getObject()))) {
            $condition->mergeAndBegin($aclCondition);
        }
        $items = $storageController->getItems($filter, $condition, $options);
        if ($withAcl && is_array($items)) {
            foreach ($items as &$item) {
                if ($item) {
                    $this->prepareRow($item);
                }
            }
        }
        return $items ?: null;
    }
ObjectCrud