You are here

Language.php in Config Pages 8

File

src/Plugin/ConfigPagesContext/Language.php
View source
<?php

namespace Drupal\config_pages\Plugin\ConfigPagesContext;

use Drupal\config_pages\ConfigPagesContextBase;

/**
 * Provides a language config pages context.
 *
 * @ConfigPagesContext(
 *   id = "language",
 *   label = @Translation("Language"),
 * )
 */
class Language extends ConfigPagesContextBase {

  /**
   * Return the value of the context.
   *
   * @return mixed
   */
  public static function getValue() {
    $lang = \Drupal::service('language_manager')
      ->getCurrentLanguage();
    return $lang
      ->getId();
  }

}

Classes

Namesort descending Description
Language Provides a language config pages context.