You are here

function facetapi_test_search_callback in Facet API 7.2

Same name and namespace in other branches
  1. 6.3 tests/facetapi_test/facetapi_test.module \facetapi_test_search_callback()
  2. 7 tests/facetapi_test.module \facetapi_test_search_callback()

Fake search page callback.

1 string reference to 'facetapi_test_search_callback'
facetapi_test_menu in tests/facetapi_test.module
Implements hook_menu().

File

tests/facetapi_test.module, line 162
Provides a test adapter and plugins.

Code

function facetapi_test_search_callback() {
  $build = array();

  // Load adapter, throw exception on error.
  if (!($adapter = facetapi_adapter_load('facetapi_test'))) {
    throw new Exception(t('Error loading adapter.'));
  }

  // Set result count if passed through query string.
  if (isset($_GET['count'])) {
    $adapter
      ->setResultCount((int) $_GET['count']);
  }

  // Instantiate a dummy query class, initialize facets.
  $query = new stdClass();
  $adapter
    ->addActiveFilters($query);

  // Set keywords if passed through query string.
  $keys = isset($_GET['keys']) ? $_GET['keys'] : arg(2);
  $adapter
    ->setSearchKeys($keys);
  $build['placeholder'] = array(
    '#markup' => t('Placeholder'),
  );
  return $build;
}