SearchResultProcessorInterface.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Data;
  7. /**
  8. * Interface SearchResultProcessorInterface
  9. */
  10. interface SearchResultProcessorInterface
  11. {
  12. /**
  13. * Retrieve all ids for collection
  14. *
  15. * @return array
  16. */
  17. public function getAllIds();
  18. /**
  19. * Get current collection page
  20. *
  21. * @return int
  22. */
  23. public function getCurrentPage();
  24. /**
  25. * Retrieve collection page size
  26. *
  27. * @return int
  28. */
  29. public function getPageSize();
  30. /**
  31. * Retrieve collection first item
  32. *
  33. * @return \Magento\Framework\DataObject
  34. */
  35. public function getFirstItem();
  36. /**
  37. * Retrieve collection last item
  38. *
  39. * @return \Magento\Framework\DataObject
  40. */
  41. public function getLastItem();
  42. /**
  43. * Retrieve field values from all items
  44. *
  45. * @param string $colName
  46. * @return array
  47. */
  48. public function getColumnValues($colName);
  49. /**
  50. * Search all items by field value
  51. *
  52. * @param string $column
  53. * @param mixed $value
  54. * @return array
  55. */
  56. public function getItemsByColumnValue($column, $value);
  57. /**
  58. * Search first item by field value
  59. *
  60. * @param string $column
  61. * @param mixed $value
  62. * @return \Magento\Framework\DataObject || null
  63. */
  64. public function getItemByColumnValue($column, $value);
  65. /**
  66. * Retrieve item by id
  67. *
  68. * @param mixed $idValue
  69. * @return \Magento\Framework\DataObject
  70. */
  71. public function getItemById($idValue);
  72. /**
  73. * Walk through the collection and run model method or external callback
  74. * with optional arguments
  75. *
  76. * Returns array with results of callback for each item
  77. *
  78. * @param string $callback
  79. * @param array $arguments
  80. * @return array
  81. */
  82. public function walk($callback, array $arguments = []);
  83. /**
  84. * Convert collection to XML
  85. *
  86. * @return string
  87. */
  88. public function toXml();
  89. /**
  90. * Convert collection to array
  91. *
  92. * @param array $arrRequiredFields
  93. * @return array
  94. */
  95. public function toArray($arrRequiredFields = []);
  96. /**
  97. * Convert items array to array for select options
  98. *
  99. * return items array
  100. * array(
  101. * $index => array(
  102. * 'value' => mixed
  103. * 'label' => mixed
  104. * )
  105. * )
  106. *
  107. * @param string $valueField
  108. * @param string $labelField
  109. * @param array $additional
  110. * @return array
  111. */
  112. public function toOptionArray($valueField = null, $labelField = null, $additional = []);
  113. /**
  114. * Convert items array to hash for select options
  115. *
  116. * return items hash
  117. * array($value => $label)
  118. *
  119. * @param string $valueField
  120. * @param string $labelField
  121. * @return array
  122. */
  123. public function toOptionHash($valueField, $labelField);
  124. }