/**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var Context $context */
     if (!$context->hasConfigExtra(ExpandRelatedEntitiesConfigExtra::NAME)) {
         $filterValue = $context->getFilterValues()->get(self::FILTER_KEY);
         if (null !== $filterValue) {
             $includes = $this->valueNormalizer->normalizeValue($filterValue->getValue(), DataType::STRING, $context->getRequestType(), true);
             if (!empty($includes)) {
                 $context->addConfigExtra(new ExpandRelatedEntitiesConfigExtra((array) $includes));
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var Context $context */
     if (!$context->hasConfigExtra(FilterFieldsConfigExtra::NAME)) {
         $fields = [];
         $filterValues = $context->getFilterValues()->getAll(self::FILTER_KEY);
         foreach ($filterValues as $filterValue) {
             $fields[$filterValue->getPath()] = (array) $this->valueNormalizer->normalizeValue($filterValue->getValue(), DataType::STRING, $context->getRequestType(), true);
         }
         if (!empty($fields)) {
             $context->addConfigExtra(new FilterFieldsConfigExtra($fields));
         }
     }
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var Context $context */
     if ($context->hasQuery()) {
         // a query is already built
         return;
     }
     $filterValues = $context->getFilterValues();
     $filters = $context->getFilters();
     foreach ($filters as $filterKey => $filter) {
         if ($filter instanceof SortFilter) {
             $this->validateSortValue($this->getSortFilterValue($filterValues, $filterKey), $context->hasConfigOfSorters() ? $context->getConfigOfSorters() : null);
         }
     }
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var GetListContext $context */
     if ($context->hasQuery()) {
         // a query is already built
         return;
     }
     $criteria = $context->getCriteria();
     $filterValues = $context->getFilterValues();
     $filters = $context->getFilters();
     foreach ($filters as $filterKey => $filter) {
         $filterValue = $filterValues->has($filterKey) ? $filterValues->get($filterKey) : null;
         $filter->apply($criteria, $filterValue);
     }
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var GetListContext $context */
     if ($context->hasQuery()) {
         // a query is already built
         return;
     }
     $entityClass = $context->getClassName();
     if (!$this->doctrineHelper->isManageableEntityClass($entityClass)) {
         // only manageable entities are supported
         return;
     }
     $filterValues = $context->getFilterValues();
     if ($filterValues->has(self::SORT_FILTER_KEY)) {
         $filterValue = $filterValues->get(self::SORT_FILTER_KEY);
         $filterValue->setValue($this->normalizeValue($filterValue->getValue(), $entityClass));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var GetListContext $context */
     if ($context->hasQuery()) {
         // a query is already built
         return;
     }
     $filterValues = $context->getFilterValues();
     $filters = $context->getFilters();
     foreach ($filters as $filterKey => $filter) {
         $filterValue = null;
         if ($filterValues->has($filterKey)) {
             $filterValue = $filterValues->get($filterKey);
             if ($filter instanceof StandaloneFilter) {
                 $value = $this->valueNormalizer->normalizeValue($filterValue->getValue(), $filter->getDataType(), $context->getRequestType(), $filter->isArrayAllowed($filterValue->getOperator()));
                 $filterValue->setValue($value);
             }
         }
     }
 }