/**
  * Only support indexes with Panelize-able entities.
  */
 public function supportsIndex(SearchApiIndex $index)
 {
     $panelizer_plugins = panelizer_get_entity_plugins();
     if (isset($panelizer_plugins[$index->getEntityType()])) {
         $plugin = $panelizer_plugins[$index->getEntityType()];
         return !empty($plugin['uses page manager']);
     }
 }
 /**
  * {@inheritdoc}
  */
 public static function supportsIndex(SearchApiIndex $index)
 {
     try {
         return $index->server() && $index->server()->supportsFeature('search_api_autocomplete');
     } catch (SearchApiException $e) {
         return FALSE;
     }
 }
Ejemplo n.º 3
0
/**
 * Allows modules to react after items were indexed.
 *
 * @param SearchApiIndex $index
 *   The used index.
 * @param array $item_ids
 *   An array containing the indexed items' IDs.
 */
function hook_search_api_items_indexed(SearchApiIndex $index, array $item_ids)
{
    if ($index->getEntityType() == 'node') {
        // Flush page cache of the search page.
        cache_clear_all(url('search'), 'cache_page');
    }
}
 /**
  * @param SearchApiIndex $index
  *   The index for which item IDs should be retrieved.
  * @param array $entity_ids
  *   The entity ids to get the trackable entity ids for.
  *
  * @return array
  *   An array with all trackable Entity IDs for a given index.
  */
 public function getTrackableEntityIds(SearchApiIndex $index, $entity_ids = NULL)
 {
     $entity_type = $index->getEntityType();
     if (!empty($this->entityInfo['base table']) && $this->idKey) {
         // Assumes that all entities use the "base table" property and the
         // "entity keys[id]" in the same way as the default controller.
         $table = $this->entityInfo['base table'];
         // Select all entity ids.
         $query = db_select($table, 't');
         $query->addField('t', $this->idKey);
         if ($bundles = $this->getIndexBundles($index)) {
             $query->condition($this->bundleKey, $bundles);
         }
         if ($entity_ids) {
             $query->condition($this->idKey, $entity_ids);
         }
         $ids = $query->execute()->fetchCol();
     } else {
         // In the absence of a 'base table', load the entities.
         $query = new EntityFieldQuery();
         $query->entityCondition('entity_type', $entity_type);
         if ($bundles = $this->getIndexBundles($index)) {
             $query->entityCondition('bundle', $bundles);
         }
         if ($entity_ids) {
             $query->entityCondition('entity_id', $entity_ids);
         }
         $entities = $query->execute();
         $ids = array_keys($entities[$entity_type]);
     }
     return $ids;
 }