Builder.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\CatalogSearch\Model\Advanced\Request;
  7. use Magento\Framework\Search\Request\Builder as RequestBuilder;
  8. /**
  9. * Catalog search advanced request builder.
  10. *
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Builder extends RequestBuilder
  15. {
  16. /**
  17. * Bind value to query.
  18. *
  19. * @param string $attributeCode
  20. * @param array|string $attributeValue
  21. * @return void
  22. * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  23. */
  24. public function bindRequestValue($attributeCode, $attributeValue)
  25. {
  26. if (isset($attributeValue['from']) || isset($attributeValue['to'])) {
  27. if (isset($attributeValue['from']) && '' !== $attributeValue['from']) {
  28. $this->bind("{$attributeCode}.from", $attributeValue['from']);
  29. }
  30. if (isset($attributeValue['to']) && '' !== $attributeValue['to']) {
  31. $this->bind("{$attributeCode}.to", $attributeValue['to']);
  32. }
  33. } elseif (!is_array($attributeValue)) {
  34. $this->bind($attributeCode, $attributeValue);
  35. } elseif (isset($attributeValue['like'])) {
  36. $this->bind($attributeCode, $attributeValue['like']);
  37. } elseif (isset($attributeValue['in'])) {
  38. $this->bind($attributeCode, $attributeValue['in']);
  39. } elseif (isset($attributeValue['in_set'])) {
  40. $this->bind($attributeCode, $attributeValue['in_set']);
  41. }
  42. }
  43. }