コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function resolve(RequestInterface $request, array $documentIds)
 {
     $data = $this->config->get($request->getName());
     $bucketKeys = isset($data['aggregations']) ? array_keys($data['aggregations']) : [];
     $attributeCodes = $this->getApplicableAttributeCodes($documentIds);
     $resolvedAggregation = array_filter($request->getAggregation(), function ($bucket) use($attributeCodes, $bucketKeys) {
         /** @var BucketInterface $bucket */
         return in_array($bucket->getField(), $attributeCodes) || in_array($bucket->getName(), $bucketKeys);
     });
     return array_values($resolvedAggregation);
 }
コード例 #2
0
ファイル: Builder.php プロジェクト: shabbirvividads/magento2
 /**
  * Create request object
  *
  * @return RequestInterface
  */
 public function create()
 {
     if (!isset($this->data['requestName'])) {
         throw new \InvalidArgumentException("Request name not defined.");
     }
     $requestName = $this->data['requestName'];
     /** @var array $data */
     $data = $this->config->get($requestName);
     if ($data === null) {
         throw new \InvalidArgumentException("Request name '{$requestName}' doesn't exist.");
     }
     $data = $this->binder->bind($data, $this->data);
     $data = $this->cleaner->clean($data);
     $this->clear();
     return $this->convert($data);
 }