addAdditionalFields example

/** * {@inheritdoc} */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view$display$options);

    $this->additional_fields['uid'] = ['table' => 'users_field_data', 'field' => 'uid'];
  }

  public function query() {
    $this->addAdditionalFields();
    $this->field_alias = $this->aliases['uid'];
  }

  public function preRender(&$values) {
    $this->items = [];

    $permission_names = \Drupal::service('user.permissions')->getPermissions();

    $rids = [];
    foreach ($values as $result) {
      $user = $this->getEntity($result);
      
'#default_value' => $this->options['link_to_comment'],
    ];

    parent::buildOptionsForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function query() {
    $this->ensureMyTable();
    $this->addAdditionalFields();
    $this->field_alias = $this->table . '_' . $this->field;
  }

  /** * {@inheritdoc} */
  public function preRender(&$values) {
    $user = \Drupal::currentUser();
    if ($user->isAnonymous() || empty($values)) {
      return;
    }

    
foreach ($options as $column) {
        $fields[$column] = $table_mapping->getFieldColumnName($field_definition$column);
      }

      $this->group_fields = $fields;
    }

    // Add additional fields (and the table join itself) if needed.     if ($this->add_field_table($use_groupby)) {
      $this->ensureMyTable();
      $this->addAdditionalFields($fields);
    }

    // Let the entity field renderer alter the query if needed.     $this->getEntityFieldRenderer()->query($this->query, $this->relationship);
  }

  /** * Determine if the field table should be added to the query. */
  public function add_field_table($use_groupby) {
    // Grouping is enabled.
public function usesGroupBy() {
    return FALSE;
  }

  /** * {@inheritdoc} */
  public function query() {
    if ($this->languageManager->isMultilingual()) {
      $this->getEntityTranslationRenderer()->query($this->query, $this->relationship);
    }
    $this->addAdditionalFields();
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $row) {
    $access = $this->checkUrlAccess($row);
    if ($access) {
      $build = ['#markup' => $access->isAllowed() ? $this->renderLink($row) : ''];
      BubbleableMetadata::createFromObject($access)->applyTo($build);
      return $build;
    }


    ];

    parent::buildOptionsForm($form$form_state);
  }

  /** * Add this term to the query. */
  public function query() {
    $this->addAdditionalFields();
  }

  public function preRender(&$values) {
    $vocabularies = $this->vocabularyStorage->loadMultiple();
    $this->field_alias = $this->aliases['nid'];
    $nids = [];
    foreach ($values as $result) {
      if (!empty($result->{$this->aliases['nid']})) {
        $nids[] = $result->{$this->aliases['nid']};
      }
    }

    


  /** * Called to add the field to a query. */
  public function query() {
    $this->ensureMyTable();
    // Add the field.     $params = $this->options['group_type'] != 'group' ? ['function' => $this->options['group_type']] : [];
    $this->field_alias = $this->query->addField($this->tableAlias, $this->realField, NULL, $params);

    $this->addAdditionalFields();
  }

  /** * Add 'additional' fields to the query. * * @param $fields * An array of fields. The key is an identifier used to later find the * field alias used. The value is either a string in which case it's * assumed to be a field on this handler's table; or it's an array in the * form of * @code array('table' => $tablename, 'field' => $fieldname) @endcode */
/** * {@inheritdoc} */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view$display$options);

    $this->additional_fields['uid'] = ['table' => 'users_field_data', 'field' => 'uid'];
  }

  public function query() {
    $this->addAdditionalFields();
    $this->field_alias = $this->aliases['uid'];
  }

  public function preRender(&$values) {
    $uids = [];
    $this->items = [];

    foreach ($values as $result) {
      $uids[] = $this->getValue($result);
    }

    
Home | Imprint | This part of the site doesn't use cookies.