adminLabel example

array_walk($plugins[$this, 'calculatePluginDependencies']);

    return $this->dependencies;
  }

  /** * {@inheritdoc} */
  public function getFieldLabels($groupable_only = FALSE) {
    $options = [];
    foreach ($this->getHandlers('relationship') as $relationship => $handler) {
      $relationships[$relationship] = $handler->adminLabel();
    }

    foreach ($this->getHandlers('field') as $id => $handler) {
      if ($groupable_only && !$handler->useStringGroupBy()) {
        // Continue to next handler if it's not groupable.         continue;
      }
      if ($label = $handler->label()) {
        $options[$id] = $label;
      }
      else {
        
$handlers = $view->form_cache['handlers'];
    }
    else {
      $groups = $display->getOption('filter_groups');
      $handlers = $display->getOption($types[$type]['plural']);
    }
    $count = 0;

    // Get relationship labels     $relationships = [];
    foreach ($display->getHandlers('relationship') as $id => $handler) {
      $relationships[$id] = $handler->adminLabel();
    }

    $group_options = [];

    /** * Filter groups is an array that contains: * array( * 'operator' => 'and' || 'or', * 'groups' => array( * $group_id => 'and' || 'or', * ), * ); */
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
    $options['admin_label']['default'] = $label;
    $options['empty'] = ['default' => FALSE];

    return $options;
  }

  /** * {@inheritdoc} */
  public function adminSummary() {
    return $this->adminLabel();
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    if ($form_state->get('type') != 'empty') {
      $form['empty'] = [
        '#type' => 'checkbox',
        
if ($display->defaultableSections($types[$type]['plural'])) {
      $section = $types[$type]['plural'];
      $form_state->set('section', $section);
      views_ui_standard_display_dropdown($form$form_state$section);
    }

    $count = 0;

    // Get relationship labels     $relationships = [];
    foreach ($display->getHandlers('relationship') as $id => $handler) {
      $relationships[$id] = $handler->adminLabel();
    }

    $form['fields'] = [
      '#type' => 'table',
      '#header' => ['', $this->t('Weight')$this->t('Remove')],
      '#empty' => $this->t('No fields available.'),
      '#tabledrag' => [
        [
          'action' => 'order',
          'relationship' => 'sibling',
          'group' => 'weight',
        ],

      else {
        $build['#defaulted'] = TRUE;
      }
    }

    static $relationships = NULL;
    if (!isset($relationships)) {
      // Get relationship labels.       $relationships = [];
      foreach ($executable->display_handler->getHandlers('relationship') as $id => $handler) {
        $relationships[$id] = $handler->adminLabel();
      }
    }

    // Filters can now be grouped so we do a little bit extra:     $groups = [];
    $grouping = FALSE;
    if ($type == 'filter') {
      $group_info = $executable->display_handler->getOption('filter_groups');
      // If there is only one group but it is using the "OR" filter, we still       // treat it as a group for display purposes, since we want to display the       // "OR" label next to items within the group.
$item = $executable->getHandler($display_id$type$id);

    if ($item) {
      $handler = $executable->display_handler->getHandler($type$id);
      if (empty($handler)) {
        $form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
      }
      else {
        $handler->init($executable$executable->display_handler, $item);
        $types = ViewExecutable::getHandlerTypes();

        $form['#title'] = $this->t('Configure extra settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);

        $form['#section'] = $display_id . '-' . $type . '-' . $id;

        // Get form from the handler.         $handler->buildExtraOptionsForm($form['options']$form_state);
        $form_state->set('handler', $handler);
      }

      $view->getStandardButtons($form$form_state, 'views_ui_config_item_extra_form');
    }
    return $form;
  }
public function query() {
    $this->ensureMyTable();

    $params = [
      'function' => $this->options['group_type'],
    ];

    $this->query->addOrderBy($this->tableAlias, $this->realField, $this->options['order'], NULL, $params);
  }

  public function adminLabel($short = FALSE) {
    return $this->getField(parent::adminLabel($short));
  }

}
    // handlers. Note that the sort field identifier is different that other     // identifiers because it is used as a query string value of the 'sort_by'     // parameter, while the others are used as query string parameter keys.     // Therefore we can have a sort field identifier be the same as an exposed     // filter identifier. This prevents us from using     // DisplayPluginInterface::isIdentifierUnique() to test for uniqueness.     // @see \Drupal\views\Plugin\views\display\DisplayPluginInterface::isIdentifierUnique()     foreach ($this->view->display_handler->getHandlers('sort') as $key => $handler) {
      if ($handler->canExpose() && $handler->isExposed()) {
        if ($form_state->get('id') !== $key && isset($handler->options['expose']['field_identifier']) && $field_identifier === $handler->options['expose']['field_identifier']) {
          $form_state->setErrorByName('expose][field_identifier', $this->t('This identifier is already used by %label sort handler.', [
            '%label' => $handler->adminLabel(TRUE),
          ]));
          return;
        }
      }
    }
  }

  /** * {@inheritdoc} */
  public static function trustedCallbacks() {
    
class GroupByNumeric extends ArgumentPluginBase {

  public function query($group_by = FALSE) {
    $this->ensureMyTable();
    $field = $this->getField();
    $placeholder = $this->placeholder();

    $this->query->addHavingExpression(0, "$field = $placeholder", [$placeholder => $this->argument]);
  }

  public function adminLabel($short = FALSE) {
    return $this->getField(parent::adminLabel($short));
  }

  /** * {@inheritdoc} */
  public function getSortName() {
    return $this->t('Numerical', []['context' => 'Sort order']);
  }

}
// Get a list of the available fields and arguments for token replacement.
      // Setup the tokens for fields.       $previous = $this->getPreviousFieldLabels();
      $optgroup_arguments = (string) $this->t('Arguments');
      $optgroup_fields = (string) $this->t('Fields');
      foreach ($previous as $id => $label) {
        $options[$optgroup_fields]["{{ $id }}"] = substr(strrchr($label, ":"), 2);
      }
      // Add the field to the list of options.       $options[$optgroup_fields]["{{ {$this->options['id']} }}"] = substr(strrchr($this->adminLabel(), ":"), 2);

      foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
        $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
        $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
      }

      $this->documentSelfTokens($options[$optgroup_fields]);

      // Default text.
      $output = [];
      
/** * {@inheritdoc} */
  public function getContextDefinition() {
    if ($context_definition = parent::getContextDefinition()) {
      return $context_definition;
    }

    // If the parent does not provide a context definition through the     // validation plugin, fall back to the integer type.     return new ContextDefinition('integer', $this->adminLabel(), FALSE);
  }

}
$item = $executable->getHandler($display_id$type$id);

    if ($item) {
      $handler = $executable->display_handler->getHandler($type$id);
      if (empty($handler)) {
        $form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
      }
      else {
        $handler->init($executable$executable->display_handler, $item);
        $types = ViewExecutable::getHandlerTypes();

        $form['#title'] = $this->t('Configure aggregation settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);

        $handler->buildGroupByForm($form['options']$form_state);
        $form_state->set('handler', $handler);
      }

      $view->getStandardButtons($form$form_state, 'views_ui_config_item_group_form');
    }
    return $form;
  }

  /** * {@inheritdoc} */
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    $this->view->initStyle();

    // Allow to choose all fields as possible     if ($this->view->style_plugin->usesFields()) {
      $options = [];
      foreach ($this->view->display_handler->getHandlers('field') as $name => $field) {
        // Only allow clickSortable fields. Fields without clickSorting will         // probably break in the Combine filter.         if ($field->clickSortable()) {
          $options[$name] = $field->adminLabel(TRUE);
        }
      }
      if ($options) {
        $form['fields'] = [
          '#type' => 'select',
          '#title' => $this->t('Choose fields to combine for filtering'),
          '#description' => $this->t("This filter doesn't work for very special field handlers."),
          '#multiple' => TRUE,
          '#options' => $options,
          '#default_value' => $this->options['fields'],
        ];
      }
$definition = [
      'title' => 'Is InOperator Test',
      'group' => 'Test',
      'options callback' => '\Drupal\Tests\views\Unit\Plugin\filter\InOperatorTest::validate_options_callback',
    ];
    $filter = new InOperator([], 'in_operator', $definition);
    $filter->value = 'string';
    $filter->operator = 'in';
    $translation_stub = $this->getStringTranslationStub();
    $filter->setStringTranslation($translation_stub);
    $errors = $filter->validate();
    $this->assertSame('The value 'string' is not an array for in on filter: ' . $filter->adminLabel(TRUE)(string) $errors[0]);
  }

  /** * @return array */
  public static function validate_options_callback() {
    return ['Yes', 'No'];
  }

}
$form['tokenize'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Use replacement tokens from the first row'),
      '#default_value' => $this->options['tokenize'],
    ];

    // Get a list of the available fields and arguments for token replacement.     $options = [];
    $optgroup_arguments = (string) $this->t('Arguments');
    $optgroup_fields = (string) $this->t('Fields');
    foreach ($this->view->display_handler->getHandlers('field') as $field => $handler) {
      $options[$optgroup_fields]["{{ $field }}"] = $handler->adminLabel();
    }

    foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
      $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
      $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
    }

    if (!empty($options)) {
      $form['tokens'] = [
        '#type' => 'details',
        '#title' => $this->t('Replacement patterns'),
        
Home | Imprint | This part of the site doesn't use cookies.