LanguageNegotiationMethodBase.php

Same filename in other branches
  1. 9 core/modules/language/src/LanguageNegotiationMethodBase.php
  2. 10 core/modules/language/src/LanguageNegotiationMethodBase.php
  3. 11.x core/modules/language/src/LanguageNegotiationMethodBase.php

Namespace

Drupal\language

File

core/modules/language/src/LanguageNegotiationMethodBase.php

View source
<?php

namespace Drupal\language;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Base class for language negotiation methods.
 */
abstract class LanguageNegotiationMethodBase implements LanguageNegotiationMethodInterface {
    
    /**
     * The language manager.
     *
     * @var \Drupal\Core\Language\LanguageManagerInterface
     */
    protected $languageManager;
    
    /**
     * The configuration factory.
     *
     * @var \Drupal\Core\Config\ConfigFactoryInterface
     */
    protected $config;
    
    /**
     * The current active user.
     *
     * @var \Drupal\Core\Session\AccountInterface
     */
    protected $currentUser;
    
    /**
     * {@inheritdoc}
     */
    public function setLanguageManager(ConfigurableLanguageManagerInterface $language_manager) {
        $this->languageManager = $language_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public function setConfig(ConfigFactoryInterface $config) {
        $this->config = $config;
    }
    
    /**
     * {@inheritdoc}
     */
    public function setCurrentUser(AccountInterface $current_user) {
        $this->currentUser = $current_user;
    }
    
    /**
     * {@inheritdoc}
     */
    public function persist(LanguageInterface $language) {
        // Default implementation persists nothing.
    }

}

Classes

Title Deprecated Summary
LanguageNegotiationMethodBase Base class for language negotiation methods.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.