You are here

function apachesolr_index_mark_for_reindex in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr.index.inc \apachesolr_index_mark_for_reindex()
  2. 6.3 apachesolr.index.inc \apachesolr_index_mark_for_reindex()

Mark a certain entity type for a specific environment for reindexing.

Parameters

$env_id:

null $entity_type:

5 calls to apachesolr_index_mark_for_reindex()
apachesolr_drush_solr_mark_for_reindex in drush/apachesolr.drush.inc
Mark all of a specific environment id for reindexing
apachesolr_enable in ./apachesolr.install
Implements hook_enable().
apachesolr_index_action_form_reset_confirm_submit in ./apachesolr.admin.inc
Submit handler for the deletion form.
apachesolr_index_delete_index in ./apachesolr.index.inc
Delete the whole index for an environment.
apachesolr_search_search_reset in ./apachesolr_search.module
Implements hook_search_reset().

File

./apachesolr.index.inc, line 748
Functions related to Apache Solr indexing operations.

Code

function apachesolr_index_mark_for_reindex($env_id, $entity_type = NULL) {
  $entities = entity_get_info();
  $node_types = node_type_get_names();
  foreach ($node_types as $node_type => $node_info) {
    if ($node_type == $entity_type) {
      if (isset($entities['node']['apachesolr']) && $entities['node']['apachesolr']['indexable']) {
        $reindex_callback = apachesolr_entity_get_callback('node', 'reindex callback');
        if (!empty($reindex_callback)) {
          call_user_func($reindex_callback, $env_id, $entity_type, 'node');
        }
      }
    }
  }
  foreach ($entities as $type => $entity_info) {
    if ($type == $entity_type || $entity_type == NULL) {
      if (isset($entity_info['apachesolr']) && $entity_info['apachesolr']['indexable']) {
        $reindex_callback = apachesolr_entity_get_callback($type, 'reindex callback');
        if (!empty($reindex_callback)) {
          call_user_func($reindex_callback, $env_id, NULL, $type);
        }
      }
    }
  }
  apachesolr_clear_last_index_position($env_id, $entity_type);
  cache_clear_all('*', 'cache_apachesolr', TRUE);
}