function elgg_solr_add_update_entity($event, $type, $entity) { $debug = false; if (elgg_get_config('elgg_solr_debug')) { $debug = true; } if (!elgg_instanceof($entity)) { if ($debug) { elgg_solr_debug_log('Not a valid elgg entity'); } return true; } if (!is_registered_entity_type($entity->type, $entity->getSubtype())) { if ($debug) { elgg_solr_debug_log('Not a registered entity type'); } return true; } $function = elgg_solr_get_solr_function($entity->type, $entity->getSubtype()); if (is_callable($function)) { if ($debug) { elgg_solr_debug_log('processing entity with function - ' . $function); } $function($entity); } else { if ($debug) { elgg_solr_debug_log('Not a callable function - ' . $function); } } }
/** * Update entity event * * @param string $event "create"|"update" * @param string $type "object"|"user"|"group" * @param ElggEntity $entity * @return void */ function elgg_solr_add_update_entity($event, $type, $entity) { if (elgg_get_config('solr_is_indexing')) { // this flag indicates that we're already updating this entity // an event handler may have triggered an event leading to // an infinite loop, and we're breaking it return; } if (!elgg_instanceof($entity)) { elgg_solr_debug_log('Not a valid elgg entity'); return; } if (!elgg_solr_is_registered_entity_type($entity->type, $entity->getSubtype())) { elgg_solr_debug_log('Not a registered entity type'); return; } $function = elgg_solr_get_solr_function($entity->type, $entity->getSubtype()); if (!is_callable($function)) { elgg_solr_debug_log('Not a callable function - ' . $function); return; } elgg_solr_debug_log('processing entity with function - ' . $function); // make sure info indexed isn't dependent on the permissions of the logged in user $ia = elgg_set_ignore_access(true); elgg_set_config('solr_is_indexing', true); call_user_func($function, $entity); elgg_set_config('solr_is_indexing', false); elgg_set_ignore_access($ia); }