QueryContainer.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Search\Adapter\Mysql\Query;
  7. use Magento\Framework\DB\Select;
  8. use Magento\Framework\Search\Request\QueryInterface as RequestQueryInterface;
  9. /**
  10. * MySQL search query container.
  11. *
  12. * @deprecated 102.0.0
  13. * @see \Magento\ElasticSearch
  14. */
  15. class QueryContainer
  16. {
  17. const DERIVED_QUERY_PREFIX = 'derived_';
  18. /**
  19. * @var array
  20. */
  21. private $queries = [];
  22. /**
  23. * @var \Magento\Framework\Search\Adapter\Mysql\Query\MatchContainerFactory
  24. */
  25. private $matchContainerFactory;
  26. /**
  27. * @param MatchContainerFactory $matchContainerFactory
  28. */
  29. public function __construct(MatchContainerFactory $matchContainerFactory)
  30. {
  31. $this->matchContainerFactory = $matchContainerFactory;
  32. }
  33. /**
  34. * Add query to select.
  35. *
  36. * @param Select $select
  37. * @param RequestQueryInterface $query
  38. * @param string $conditionType
  39. * @return Select
  40. */
  41. public function addMatchQuery(
  42. Select $select,
  43. RequestQueryInterface $query,
  44. $conditionType
  45. ) {
  46. $container = $this->matchContainerFactory->create(
  47. [
  48. 'request' => $query,
  49. 'conditionType' => $conditionType,
  50. ]
  51. );
  52. $name = self::DERIVED_QUERY_PREFIX . count($this->queries);
  53. $this->queries[$name] = $container;
  54. return $select;
  55. }
  56. /**
  57. * Get queries.
  58. *
  59. * @return MatchContainer[]
  60. */
  61. public function getMatchQueries()
  62. {
  63. return $this->queries;
  64. }
  65. }