Exemple #1
0
 /**
  * Support method for getHandlers() -- load combined settings.
  *
  * @param string $activeSearchClass Active search class ID
  * @param string $activeHandler     Active search handler
  *
  * @return array
  */
 protected function getCombinedHandlers($activeSearchClass, $activeHandler)
 {
     // Build settings:
     $handlers = [];
     $selectedFound = false;
     $backupSelectedIndex = false;
     $settings = $this->getCombinedHandlerConfig($activeSearchClass);
     $typeCount = count($settings['type']);
     for ($i = 0; $i < $typeCount; $i++) {
         $type = $settings['type'][$i];
         $target = $settings['target'][$i];
         $label = $settings['label'][$i];
         if ($type == 'VuFind') {
             $options = $this->optionsManager->get($target);
             $j = 0;
             $basic = $options->getBasicHandlers();
             if (empty($basic)) {
                 $basic = ['' => ''];
             }
             foreach ($basic as $searchVal => $searchDesc) {
                 $j++;
                 $selected = $target == $activeSearchClass && $activeHandler == $searchVal;
                 if ($selected) {
                     $selectedFound = true;
                 } else {
                     if ($backupSelectedIndex === false && $target == $activeSearchClass) {
                         $backupSelectedIndex = count($handlers);
                     }
                 }
                 $handlers[] = ['value' => $type . ':' . $target . '|' . $searchVal, 'label' => $j == 1 ? $label : $searchDesc, 'indent' => $j == 1 ? false : true, 'selected' => $selected];
             }
         } else {
             if ($type == 'External') {
                 $handlers[] = ['value' => $type . ':' . $target, 'label' => $label, 'indent' => false, 'selected' => false];
             }
         }
     }
     // If we didn't find an exact match for a selected index, use a fuzzy
     // match:
     if (!$selectedFound && $backupSelectedIndex !== false) {
         $handlers[$backupSelectedIndex]['selected'] = true;
     }
     return $handlers;
 }
Exemple #2
0
 /**
  * Wrapper to the options plugin manager
  *
  * @param string $type The search type of the object to retrieve
  *
  * @return \VuFind\Search\Base\Options
  */
 public function __invoke($type = 'Solr')
 {
     return $this->manager->get($type);
 }
 /**
  * Test expected interface.
  *
  * @return void
  *
  * @expectedException        Zend\ServiceManager\Exception\RuntimeException
  * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Search\Base\Options
  */
 public function testExpectedInterface()
 {
     $pm = new PluginManager(null);
     $pm->validatePlugin(new \ArrayObject());
 }