Mercurial > hg > isophonics-drupal-site
annotate core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSelected.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\language\Plugin\LanguageNegotiation; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\language\LanguageNegotiationMethodBase; |
Chris@0 | 6 use Symfony\Component\HttpFoundation\Request; |
Chris@0 | 7 |
Chris@0 | 8 /** |
Chris@0 | 9 * Class for identifying language from a selected language. |
Chris@0 | 10 * |
Chris@0 | 11 * @LanguageNegotiation( |
Chris@0 | 12 * id = Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected::METHOD_ID, |
Chris@0 | 13 * weight = 12, |
Chris@0 | 14 * name = @Translation("Selected language"), |
Chris@0 | 15 * description = @Translation("Language based on a selected language."), |
Chris@0 | 16 * config_route_name = "language.negotiation_selected" |
Chris@0 | 17 * ) |
Chris@0 | 18 */ |
Chris@0 | 19 class LanguageNegotiationSelected extends LanguageNegotiationMethodBase { |
Chris@0 | 20 |
Chris@0 | 21 /** |
Chris@0 | 22 * The language negotiation method id. |
Chris@0 | 23 */ |
Chris@0 | 24 const METHOD_ID = 'language-selected'; |
Chris@0 | 25 |
Chris@0 | 26 /** |
Chris@0 | 27 * {@inheritdoc} |
Chris@0 | 28 */ |
Chris@0 | 29 public function getLangcode(Request $request = NULL) { |
Chris@0 | 30 $langcode = NULL; |
Chris@0 | 31 |
Chris@0 | 32 if ($this->languageManager) { |
Chris@0 | 33 $langcode = $this->config->get('language.negotiation')->get('selected_langcode'); |
Chris@0 | 34 } |
Chris@0 | 35 |
Chris@0 | 36 return $langcode; |
Chris@0 | 37 } |
Chris@0 | 38 |
Chris@0 | 39 } |