/**
  * When an item is saved, index the record if the item is set public, and
  * clear an existing record if it is set private.
  *
  * @param array $args With `record`.
  */
 public function hookAfterSaveItem($args)
 {
     SolrSearch_Utils::ensureView();
     $item = $args['record'];
     $excludes = get_db()->getTable('SolrSearchExclude');
     $collection = get_collection_for_item($item);
     if (!is_null($collection) && $excludes->isExcluded($collection)) {
         return;
     }
     $solr = SolrSearch_Helpers_Index::connect();
     // Both public and private items will be indexed
     $doc = SolrSearch_Helpers_Index::itemToDocument($item);
     $solr->addDocuments(array($doc));
     $solr->commit();
     $solr->optimize();
 }
 /**
  * When an item is saved, index the record if the item is set public, and
  * clear an existing record if it is set private.
  *
  * @param array $args With `record`.
  */
 public function hookAfterSaveItem($args)
 {
     SolrSearch_Utils::ensureView();
     $item = $args['record'];
     $excludes = get_db()->getTable('SolrSearchExclude');
     $collection = get_collection_for_item($item);
     if (!is_null($collection) && $excludes->isExcluded($collection)) {
         return;
     }
     $solr = SolrSearch_Helpers_Index::connect();
     // If the item is public, add/update the Solr document.
     if ($item['public'] == true) {
         $doc = SolrSearch_Helpers_Index::itemToDocument($item);
         $solr->addDocuments(array($doc));
         $solr->commit();
         $solr->optimize();
     } else {
         $solr->deleteById('Item_' . $item['id']);
         $solr->commit();
         $solr->optimize();
     }
 }