cloudwords-8.x-1.x-dev/src/Plugin/views/field/SourceLanguage.php

src/Plugin/views/field/SourceLanguage.php
<?php

namespace Drupal\cloudwords\Plugin\views\field;

use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;

/**
 * Field handler which shows the target languages for a configured project.
 *
 * @ViewsField("cloudwords_project_source_language_field")
 */
class SourceLanguage extends FieldPluginBase {

  /**
   * @{inheritdoc}
   */
  public function query() {
    // Leave empty to avoid a query on this field.
  }

  /**
   * Define the available options
   * @return array
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    return $options;
  }

  /**
   * Provide the options form.
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {
    $lang_code = $this->getEntity($values)->get('source_language')->value;
    return \Drupal::languageManager()->getLanguageName($lang_code);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc