You are here

function _apachesolr_realtime__entity_should_index in Apache Solr Real-Time 7

Check whether a single entity is indexable (based on its published status).

Parameters

object $entity: Entity and its fields.

string $type: The type of entity.

Return value

boolean TRUE if the entity can be indexed by Solr.

1 call to _apachesolr_realtime__entity_should_index()
apachesolr_realtime_index_now in ./apachesolr_realtime.module
Prepare entity as document for adding to Solr index.

File

./apachesolr_realtime.module, line 134
Module file for apachesolr_realtime

Code

function _apachesolr_realtime__entity_should_index($entity, $type) {

  // Include the index file for the status callback
  module_load_include('inc', 'apachesolr', 'apachesolr.index');
  $info = entity_get_info($type);
  list($id, $vid, $bundle) = entity_extract_ids($type, $entity);

  // Check status callback before sending to the index
  $status_callbacks = apachesolr_entity_get_callback($type, 'status callback', $bundle);
  $status = TRUE;
  if (is_array($status_callbacks)) {
    foreach ($status_callbacks as $status_callback) {
      if (is_callable($status_callback)) {

        // By placing $status in front we prevent calling any other callback
        // after one status callback returned false.
        // The entity being saved is passed to the status callback in
        // addition to $id in case the callback needs to examine properties
        // such as the current node revision which cannot be determined by
        // loading a fresh copy of the entity.
        $status = $status && $status_callback($id, $type, $entity);
      }
    }
  }
  return $status;
}