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\language\Plugin\views\field\Language.
Namespace
Views\language\Plugin\views\fieldFile
lib/Views/language/Plugin/views/field/Language.phpView source
<?php
/**
* @file
* Definition of Views\language\Plugin\views\field\Language.
*/
namespace Views\language\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to translate a language into its readable form.
*
* @ingroup views_field_handlers
*
* @Plugin(
* id = "language",
* module = "language"
* )
*/
class Language extends FieldPluginBase {
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);
return $language ? $language->name : '';
}
}