view core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSelected.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
line wrap: on
line source
<?php

namespace Drupal\language\Plugin\LanguageNegotiation;

use Drupal\language\LanguageNegotiationMethodBase;
use Symfony\Component\HttpFoundation\Request;

/**
 * Class for identifying language from a selected language.
 *
 * @LanguageNegotiation(
 *   id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected::METHOD_ID,
 *   weight = 12,
 *   name = @Translation("Selected language"),
 *   description = @Translation("Language based on a selected language."),
 *   config_route_name = "language.negotiation_selected"
 * )
 */
class LanguageNegotiationSelected extends LanguageNegotiationMethodBase {

  /**
   * The language negotiation method id.
   */
  const METHOD_ID = 'language-selected';

  /**
   * {@inheritdoc}
   */
  public function getLangcode(Request $request = NULL) {
    $langcode = NULL;

    if ($this->languageManager) {
      $langcode = $this->config->get('language.negotiation')->get('selected_langcode');
    }

    return $langcode;
  }

}