search_api_test_2.module 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * @file
  4. * Provides a second test service and server for testing Search API.
  5. */
  6. /**
  7. * Implements hook_search_api_service_info().
  8. */
  9. function search_api_test_2_search_api_service_info() {
  10. $name = 'search_api_test_service_2';
  11. $services[$name] = array(
  12. 'name' => $name,
  13. 'description' => 'search_api_test_service_2 description',
  14. 'class' => 'SearchApiDummyService',
  15. );
  16. return $services;
  17. }
  18. /**
  19. * Implements hook_default_search_api_server().
  20. */
  21. function search_api_test_2_default_search_api_server() {
  22. $id = 'test_server_2';
  23. $items[$id] = entity_create('search_api_server', array(
  24. 'name' => 'Search API test server 2',
  25. 'machine_name' => $id,
  26. 'enabled' => 1,
  27. 'description' => 'A server used for testing.',
  28. 'class' => 'search_api_test_service_2',
  29. ));
  30. return $items;
  31. }
  32. /**
  33. * Dummy service for testing.
  34. */
  35. class SearchApiDummyService implements SearchApiServiceInterface {
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function __construct(\SearchApiServer $server) {}
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function configurationForm(array $form, array &$form_state) {
  44. return array();
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function configurationFormValidate(array $form, array &$values, array &$form_state) {}
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function configurationFormSubmit(array $form, array &$values, array &$form_state) {}
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function supportsFeature($feature) {
  58. return FALSE;
  59. }
  60. /**
  61. * {@inheritdoc}
  62. */
  63. public function viewSettings() {
  64. return array();
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function postCreate() {}
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function postUpdate() {
  74. return FALSE;
  75. }
  76. /**
  77. * {@inheritdoc}
  78. */
  79. public function preDelete() {}
  80. /**
  81. * {@inheritdoc}
  82. */
  83. public function addIndex(SearchApiIndex $index) {}
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public function fieldsUpdated(SearchApiIndex $index) {
  88. return FALSE;
  89. }
  90. /**
  91. * {@inheritdoc}
  92. */
  93. public function removeIndex($index) {}
  94. /**
  95. * {@inheritdoc}
  96. */
  97. public function indexItems(SearchApiIndex $index, array $items) {
  98. return array();
  99. }
  100. /**
  101. * {@inheritdoc}
  102. */
  103. public function deleteItems($ids = 'all', SearchApiIndex $index = NULL) {}
  104. /**
  105. * {@inheritdoc}
  106. */
  107. public function query(SearchApiIndex $index, $options = array()) {
  108. throw new SearchApiException("The dummy service doesn't support queries");
  109. }
  110. /**
  111. * {@inheritdoc}
  112. */
  113. public function search(SearchApiQueryInterface $query) {
  114. return array();
  115. }
  116. }