/**
  * Test that get() throws on a non-backend.
  *
  * @return void
  *
  * @expectedException        UnexpectedValueException
  * @expectedExceptionMessage does not implement the expected interface
  */
 public function testGetThrowsOnNonBackend()
 {
     $registry = $this->getMockForAbstractClass('Zend\\ServiceManager\\ServiceLocatorInterface');
     $registry->expects($this->once())->method('get')->will($this->returnValue($this));
     $manager = new BackendManager($registry);
     $manager->get('not-a-backend');
 }
Exemple #2
0
 /**
  * Get the connector for a specified backend.
  *
  * @param string $backend Backend ID
  *
  * @return Connector
  */
 protected function getConnector($backend)
 {
     $connector = $this->backendManager->get($backend)->getConnector();
     if (!$connector instanceof Connector) {
         throw new \Exception('Unexpected connector: ' . get_class($connector));
     }
     return $connector;
 }
Exemple #3
0
 /**
  * Generate the sitemaps based on settings established by the constructor.
  *
  * @return void
  */
 public function generate()
 {
     // Initialize variable
     $currentPage = 1;
     // Loop through all backends
     foreach ($this->backendSettings as $current) {
         $backend = $this->backendManager->get($current['id']);
         if (!$backend instanceof Backend) {
             throw new \Exception('Unsupported backend: ' . get_class($backend));
         }
         $recordUrl = $this->baseUrl . $current['url'];
         $currentPage = $this->generateForBackend($backend, $recordUrl, $currentPage);
     }
     // Set-up Sitemap Index
     $this->buildIndex($currentPage - 1);
 }
Exemple #4
0
 /**
  * Extract a Lucene syntax helper from the search backend, if possible.
  *
  * @return bool|\VuFindSearch\Backend\Solr\LuceneSyntaxHelper
  */
 protected function getLuceneHelper()
 {
     $backend = $this->backendManager->get($this->backend);
     $qb = is_callable([$backend, 'getQueryBuilder']) ? $backend->getQueryBuilder() : false;
     return $qb && is_callable([$qb, 'getLuceneHelper']) ? $qb->getLuceneHelper() : false;
 }