/**
  * @param Request              $request
  * @param Criteria             $criteria
  * @param ShopContextInterface $context
  */
 public function handleRequest(Request $request, Criteria $criteria, ShopContextInterface $context)
 {
     $requestedCategoryId = $request->getParam('sCategory', $request->getParam('categoryId', false));
     if (!$requestedCategoryId) {
         return;
     }
     $closestIdWithRules = $this->databaseAdapter->fetchClosestCategoryIdWithRule($requestedCategoryId);
     if (!$closestIdWithRules) {
         return;
     }
     $this->enabled = true;
     if ($request->sSort && $request->sSort != self::REQUEST_VALUE) {
         return;
     }
     $request->setParam('sSort', self::REQUEST_VALUE);
     $rules = $this->ruleHydrator->createRuleVos($this->databaseAdapter->fetchRawData($closestIdWithRules));
     $criteria->resetSorting();
     $criteria->addSorting(new DefaultSorting($rules));
 }
 public function testVoGenerate()
 {
     $vos = $this->ruleHydrator->createRuleVos($this->getFixtures());
     $this->assertContainsOnlyInstancesOf('Shopware\\SwagDefaultSort\\Components\\DataAccess\\RuleVo', $vos);
 }