/** * {@inheritdoc} */ public function initializeListBuilder(ListBuilderInterface $listBuilder, array $fieldDescriptors) { $listBuilder->limit($this->listRestHelper->getLimit())->setCurrentPage($this->listRestHelper->getPage()); $listBuilder->setFieldDescriptors($fieldDescriptors); $fields = $this->listRestHelper->getFields(); if ($fields != null) { foreach ($fields as $field) { if (!array_key_exists($field, $fieldDescriptors)) { continue; } $listBuilder->addSelectField($fieldDescriptors[$field]); } } else { $listBuilder->setSelectFields($fieldDescriptors); } $searchFields = $this->listRestHelper->getSearchFields(); if ($searchFields != null) { foreach ($searchFields as $searchField) { $listBuilder->addSearchField($fieldDescriptors[$searchField]); } $listBuilder->search($this->listRestHelper->getSearchPattern()); } $sortBy = $this->listRestHelper->getSortColumn(); if ($sortBy != null) { $listBuilder->sort($fieldDescriptors[$sortBy], $this->listRestHelper->getSortOrder()); } }
/** * Creates expressions from conditions and add them to the expressions array. * * @param Condition $condition * @param AbstractFieldDescriptor $fieldDescriptor */ protected function createExpression(Condition $condition, $fieldDescriptor) { $value = $this->getValue($condition); // relative date for cases like "within a week" or "within this month" if ($condition->getOperator() === 'between' && $condition->getType() === DataTypes::DATETIME_TYPE) { $this->expressions[] = $this->listBuilder->createBetweenExpression($fieldDescriptor, [$value, new \Datetime()]); } else { $this->expressions[] = $this->listBuilder->createWhereExpression($fieldDescriptor, $value, $condition->getOperator()); } }