You are here

function LinkitViewsPlugin::autocomplete_callback in Linkit views 7.2

The autocomplete callback function for the Linkit Entity plugin.

Overrides LinkitPluginInterface::autocomplete_callback

File

plugins/linkit_plugins/linkit_views.class.php, line 61

Class

LinkitViewsPlugin
Plugin class.

Code

function autocomplete_callback() {

  // Create the tmp table.
  $this
    ->create_tmp_table();

  // Populate the tmp table.
  $this
    ->populate_tmp_table();
  $matches = array();
  $query = db_select($this->table_name, 'tmp')
    ->fields('tmp', array(
    'path',
    'display_title',
    'human_name',
  ))
    ->condition('tmp.display_title', '%' . db_like($this->serach_string) . '%', 'LIKE')
    ->addTag('linkit_views_autocomplete')
    ->execute();
  foreach ($query as $view) {
    $matches[] = array(
      'title' => $view->display_title,
      'path' => base_path() . $view->path,
      'description' => t('View: %view', array(
        '%view' => $view->human_name,
      )),
      'group' => t('View pages'),
    );
  }
  return $matches;
}