Language.php in Views (for Drupal 7) 8.3
Same filename in this branch
- 8.3 lib/Views/node/Plugin/views/field/Language.php
- 8.3 lib/Views/user/Plugin/views/field/Language.php
- 8.3 lib/Views/language/Plugin/views/filter/Language.php
- 8.3 lib/Views/language/Plugin/views/argument/Language.php
- 8.3 lib/Views/language/Plugin/views/field/Language.php
- 8.3 lib/Views/taxonomy/Plugin/views/field/Language.php
Definition of Views\node\Plugin\views\field\Language.
Namespace
Views\node\Plugin\views\fieldFile
lib/Views/node/Plugin/views/field/Language.phpView source
<?php
/**
* @file
* Definition of Views\node\Plugin\views\field\Language.
*/
namespace Views\node\Plugin\views\field;
use Views\node\Plugin\views\field\Node;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to translate a language into its readable form.
*
* @ingroup views_field_handlers
*
* @Plugin(
* id = "node_language",
* module = "node"
* )
*/
class Language extends Node {
protected function defineOptions() {
$options = parent::defineOptions();
$options['native_language'] = array(
'default' => FALSE,
'bool' => TRUE,
);
return $options;
}
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$form['native_language'] = array(
'#title' => t('Native language'),
'#type' => 'checkbox',
'#default_value' => $this->options['native_language'],
'#description' => t('If enabled, the native name of the language will be displayed'),
);
}
function render($values) {
// @todo: Drupal Core dropped native language until config translation is
// ready, see http://drupal.org/node/1616594.
$value = $this
->get_value($values);
$language = language_load($value);
$value = $language ? $language->name : '';
return $this
->render_link($value, $values);
}
}