SearchCriteria.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Api;
  7. /**
  8. * Data Object for SearchCriteria
  9. * @codeCoverageIgnore
  10. */
  11. class SearchCriteria extends AbstractSimpleObject implements SearchCriteriaInterface
  12. {
  13. /**#@+
  14. * Constants for Data Object keys
  15. */
  16. const FILTER_GROUPS = 'filter_groups';
  17. const SORT_ORDERS = 'sort_orders';
  18. const PAGE_SIZE = 'page_size';
  19. const CURRENT_PAGE = 'current_page';
  20. /**
  21. * Get a list of filter groups.
  22. *
  23. * @return \Magento\Framework\Api\Search\FilterGroup[]
  24. */
  25. public function getFilterGroups()
  26. {
  27. $filterGroups = $this->_get(self::FILTER_GROUPS);
  28. return is_array($filterGroups) ? $filterGroups : [];
  29. }
  30. /**
  31. * Get sort order.
  32. *
  33. * @return \Magento\Framework\Api\SortOrder[]|null
  34. */
  35. public function getSortOrders()
  36. {
  37. return $this->_get(self::SORT_ORDERS);
  38. }
  39. /**
  40. * Get page size.
  41. *
  42. * @return int|null
  43. */
  44. public function getPageSize()
  45. {
  46. return $this->_get(self::PAGE_SIZE);
  47. }
  48. /**
  49. * Get current page.
  50. *
  51. * @return int|null
  52. */
  53. public function getCurrentPage()
  54. {
  55. return $this->_get(self::CURRENT_PAGE);
  56. }
  57. /**
  58. * Set a list of filter groups.
  59. *
  60. * @param \Magento\Framework\Api\Search\FilterGroup[] $filterGroups
  61. * @return $this
  62. */
  63. public function setFilterGroups(array $filterGroups = null)
  64. {
  65. return $this->setData(self::FILTER_GROUPS, $filterGroups);
  66. }
  67. /**
  68. * Set sort order.
  69. *
  70. * @param \Magento\Framework\Api\SortOrder[] $sortOrders
  71. * @return $this
  72. */
  73. public function setSortOrders(array $sortOrders = null)
  74. {
  75. return $this->setData(self::SORT_ORDERS, $sortOrders);
  76. }
  77. /**
  78. * Set page size.
  79. *
  80. * @param int $pageSize
  81. * @return $this
  82. */
  83. public function setPageSize($pageSize)
  84. {
  85. return $this->setData(self::PAGE_SIZE, $pageSize);
  86. }
  87. /**
  88. * Set current page.
  89. *
  90. * @param int $currentPage
  91. * @return $this
  92. */
  93. public function setCurrentPage($currentPage)
  94. {
  95. return $this->setData(self::CURRENT_PAGE, $currentPage);
  96. }
  97. }