public function testFindAddonForRecordExhibitPage()
 {
     $mgr = new SolrSearch_Addon_Manager($this->db);
     $mgr->parseAll();
     $addon = $mgr->findAddonForRecord($this->_exhibitPage());
     $this->assertNotNull($addon);
     $this->assertEquals('exhibit_pages', $addon->name);
 }
 /**
  * When a record is saved, try to extract and index a Solr document.
  *
  * @param array $args With `record`.
  */
 public function hookAfterSaveRecord($args)
 {
     SolrSearch_Utils::ensureView();
     $record = $args['record'];
     $excludes = get_db()->getTable('SolrSearchExclude');
     $collection = get_collection_for_item($record);
     if (!is_null($collection) && $excludes->isExcluded($collection)) {
         return;
     }
     // Try to extract a document for the record.
     $mgr = new SolrSearch_Addon_Manager($this->_db);
     $doc = $mgr->indexRecord($record);
     // Does the record have an add-on profile?
     if ($addon = $mgr->findAddonForRecord($record)) {
         // Connect to Solr.
         $solr = SolrSearch_Helpers_Index::connect();
         // If the record yields a Solr document, index it.
         if (!is_null($doc)) {
             $solr->addDocuments(array($doc));
             $solr->commit();
             $solr->optimize();
         } else {
             try {
                 $solr->deleteById($mgr->getId($record));
                 $solr->commit();
                 $solr->optimize();
             } catch (Exception $e) {
             }
         }
     }
     // Reindex related records.
     $mgr->resaveRemoteParent($record);
     $mgr->resaveChildren($record);
 }
 /**
  * Get the key used on Solr documents for a field on a given record.
  *
  * @param Omeka_Record_AbstractRecord $record The record.
  * @param string $field The field.
  * @return string
  */
 protected function _getAddonKey($record, $field)
 {
     // Spin up a manager and indexer.
     $mgr = new SolrSearch_Addon_Manager($this->db);
     $idx = new SolrSearch_Addon_Indexer($this->db);
     $mgr->parseAll();
     // Return the key used to store the field on the Solr document.
     return $idx->makeSolrName($mgr->findAddonForRecord($record), $field);
 }