예제 #1
0
 /**
  * A factory method to get an indexer depending on an item's configuration.
  *
  * By default all items are indexed using the default indexer
  * (ApacheSolrForTypo3\Solr\IndexQueue\Indexer) coming with EXT:solr. Pages by default are
  * configured to be indexed through a dedicated indexer
  * (ApacheSolrForTypo3\Solr\IndexQueue\PageIndexer). In all other cases a dedicated indexer
  * can be specified through TypoScript if needed.
  *
  * @param string $indexingConfigurationName Indexing configuration name.
  * @throws \RuntimeException
  * @return Indexer An instance of ApacheSolrForTypo3\Solr\IndexQueue\Indexer or a sub class of it.
  */
 protected function getIndexerByItem($indexingConfigurationName)
 {
     $indexerClass = $this->configuration->getIndexQueueIndexerByConfigurationName($indexingConfigurationName);
     $indexerConfiguration = $this->configuration->getIndexQueueIndexerConfigurationByConfigurationName($indexingConfigurationName);
     $indexer = GeneralUtility::makeInstance($indexerClass, $indexerConfiguration);
     if (!$indexer instanceof Indexer) {
         throw new \RuntimeException('The indexer class "' . $indexerClass . '" for indexing configuration "' . $indexingConfigurationName . '" is not a valid indexer. Must be a subclass of ApacheSolrForTypo3\\Solr\\IndexQueue\\Indexer.', 1260463206);
     }
     return $indexer;
 }
 /**
  * @test
  */
 public function canGetIndexQueueIndexerByConfigurationName()
 {
     $fakeConfigurationArray['plugin.']['tx_solr.'] = array('index.' => array('queue.' => array('pages.' => array('indexer' => 'Foobar'))));
     $configuration = new TypoScriptConfiguration($fakeConfigurationArray);
     $configuredIndexer = $configuration->getIndexQueueIndexerByConfigurationName('pages');
     $this->assertSame('Foobar', $configuredIndexer, 'Retrieved unexpected indexer from typoscript configuration');
 }