コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     try {
         parent::init($view, $display, $options);
         $this->fields = array();
         if (substr($view->storage->get('base_table'), 0, 17) == 'search_api_index_') {
             $id = substr($view->storage->get('base_table'), 17);
             $this->index = Index::load($id);
             $this->query = $this->index->query(array('parse mode' => $this->options['parse_mode']));
         } else {
             $this->abort(SafeMarkup::format('View %view is not based on Search API but tries to use its query plugin.', array('%view' => $view->storage->label())));
         }
     } catch (\Exception $e) {
         $this->abort($e->getMessage());
     }
 }
コード例 #2
0
ファイル: SearchApiQuery.php プロジェクト: jkyto/agolf
 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
   try {
     parent::init($view, $display, $options);
     $this->fields = array();
     $this->index = self::getIndexFromTable($view->storage->get('base_table'));
     if (!$this->index) {
       $this->abort(new FormattableMarkup('View %view is not based on Search API but tries to use its query plugin.', array('%view' => $view->storage->label())));
     }
     $this->query = $this->index->query(array(
       'parse mode' => $this->options['parse_mode'],
     ));
   }
   catch (\Exception $e) {
     $this->abort($e->getMessage());
   }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     try {
         parent::init($view, $display, $options);
         $this->index = static::getIndexFromTable($view->storage->get('base_table'));
         if (!$this->index) {
             $this->abort(new FormattableMarkup('View %view is not based on Search API but tries to use its query plugin.', array('%view' => $view->storage->label())));
         }
         $this->retrievedProperties = array_fill_keys($this->index->getDatasourceIds(), array());
         $this->retrievedProperties[NULL] = array();
         $this->query = $this->index->query();
         $this->query->setParseMode($this->options['parse_mode']);
         $this->query->addTag('views');
         $this->query->addTag('views_' . $view->id());
         $this->query->setOption('search_api_view', $view);
     } catch (\Exception $e) {
         $this->abort($e->getMessage());
     }
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function query(array $options = array())
 {
     return $this->entity->query($options);
 }