/** * {@inheritdoc} */ public function process(ContextInterface $context) { /** @var NormalizeValueContext $context */ if (!$context->hasRequirement()) { $context->setRequirement(self::REQUIREMENT); } if ($context->hasResult()) { $value = $context->getResult(); if (null !== $value && is_string($value)) { $orderBy = []; $items = explode(RestRequest::ARRAY_DELIMITER, $value); foreach ($items as $item) { $item = trim($item); if (0 === strpos($item, '-')) { $orderBy[substr($item, 1)] = Criteria::DESC; } else { $orderBy[$item] = Criteria::ASC; } } $context->setResult($orderBy); } } }