コード例 #1
0
 /**
  * Creates a list item for one datasource.
  *
  * @param \Drupal\search_api\Datasource\DatasourceInterface|null $datasource
  *   The datasource, or NULL for general properties.
  *
  * @return array
  *   A render array representing the given datasource and, possibly, its
  *   attached properties.
  */
 protected function getDatasourceListItem(DatasourceInterface $datasource = NULL)
 {
     $item = array('#type' => 'container', '#attributes' => array('class' => array('container-inline')));
     $active = FALSE;
     $datasource_id = $datasource ? $datasource->getPluginId() : '';
     $active_datasource = $this->getParameter('datasource');
     if (isset($active_datasource)) {
         $active = $active_datasource == $datasource_id;
     }
     $url = $this->entity->toUrl('add-fields');
     if ($active) {
         $expand_link = array('#type' => 'link', '#title' => '(-) ', '#url' => $url);
     } else {
         $url->setOption('query', array('datasource' => $datasource_id));
         $expand_link = array('#type' => 'link', '#title' => '(+) ', '#url' => $url);
     }
     $item['expand_link'] = $expand_link;
     $label = $datasource ? Html::escape($datasource->label()) : $this->t('General');
     $item['label']['#markup'] = $label;
     if ($active) {
         $properties = $this->entity->getPropertyDefinitions($datasource_id ?: NULL);
         if ($properties) {
             $active_property_path = $this->getParameter('property_path', '');
             $base_url = clone $url;
             $base_url->setOption('query', array('datasource' => $datasource_id));
             $item['properties'] = $this->getPropertiesList($properties, $active_property_path, $base_url);
         }
     }
     return $item;
 }
コード例 #2
0
ファイル: FieldTrait.php プロジェクト: jkyto/agolf
 public function getDataDefinition() {
   if (!isset($this->dataDefinition)) {
     $definitions = $this->index->getPropertyDefinitions($this->datasourceId);
     if (!isset($definitions[$this->propertyPath])) {
       $args['@field'] = $this->fieldIdentifier;
       $args['%index'] = $this->index->label();
       throw new SearchApiException(new FormattableMarkup('Could not retrieve data definition for field "@field" on index %index.', $args));
     }
     $this->dataDefinition = $definitions[$this->propertyPath];
   }
   return $this->dataDefinition;
 }
コード例 #3
0
ファイル: Field.php プロジェクト: curveagency/intranet
 /**
  * {@inheritdoc}
  */
 public function getDataDefinition()
 {
     if (!isset($this->dataDefinition)) {
         $definitions = $this->index->getPropertyDefinitions($this->getDatasourceId());
         $definition = $this->getNestedDefinition($definitions, explode(':', $this->getPropertyPath()));
         if (!$definition) {
             $args['%field'] = $this->getLabel();
             $args['%index'] = $this->getIndex()->label();
             throw new SearchApiException(new FormattableMarkup('Could not retrieve data definition for field %field on index %index.', $args));
         }
         $this->dataDefinition = $definition;
     }
     return $this->dataDefinition;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function getPropertyDefinitions($datasource_id, $alter = TRUE)
 {
     return $this->entity->getPropertyDefinitions($datasource_id, $alter);
 }