You are here

class MockLanguageManager in Token 8

A language manager that can be easily overridden for testing purposes.

Hierarchy

Expanded class hierarchy of MockLanguageManager

File

tests/src/Kernel/MockLanguageManager.php, line 11

Namespace

Drupal\Tests\token\Kernel
View source
class MockLanguageManager extends ConfigurableLanguageManager {

  /**
   * List of current languages used in the test.
   *
   * @var \Drupal\Core\Language\LanguageInterface[]
   */
  protected $currentLanguages;

  /**
   * {@inheritdoc}
   */
  public function getCurrentLanguage($type = LanguageInterface::TYPE_INTERFACE) {
    if (isset($this->currentLanguages[$type])) {
      return $this->currentLanguages[$type];
    }
    return parent::getCurrentLanguage($type);
  }

  /**
   * Sets the current language of the given type to use during tests.
   *
   * @param string $type
   *   The language type.
   * @param \Drupal\Core\Language\LanguageInterface $language
   *   The language.
   */
  public function setCurrentLanguage($type, LanguageInterface $language) {
    $this->currentLanguages[$type] = $language;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurableLanguageManager::$configFactory protected property The configuration storage service.
ConfigurableLanguageManager::$configFactoryOverride protected property The language configuration override service.
ConfigurableLanguageManager::$initialized protected property Whether or not the language manager has been initialized.
ConfigurableLanguageManager::$initializing protected property Whether language types are in the process of language initialization.
ConfigurableLanguageManager::$languageTypes protected property Local cache for language type configuration data.
ConfigurableLanguageManager::$languageTypesInfo protected property Local cache for language type information.
ConfigurableLanguageManager::$moduleHandler protected property The module handler service.
ConfigurableLanguageManager::$negotiatedLanguages protected property An array of language objects keyed by language type.
ConfigurableLanguageManager::$negotiatedMethods protected property An array of language negotiation method IDs keyed by language type.
ConfigurableLanguageManager::$negotiator protected property The language negotiator.
ConfigurableLanguageManager::$requestStack protected property The request object.
ConfigurableLanguageManager::getConfigOverrideLanguage public function Gets the current configuration override language. Overrides LanguageManager::getConfigOverrideLanguage
ConfigurableLanguageManager::getDefinedLanguageTypes public function Returns all the defined language types including fixed ones. Overrides ConfigurableLanguageManagerInterface::getDefinedLanguageTypes
ConfigurableLanguageManager::getDefinedLanguageTypesInfo public function Returns information about all defined language types. Overrides LanguageManager::getDefinedLanguageTypesInfo
ConfigurableLanguageManager::getFallbackCandidates public function Returns the language fallback candidates for a given context. Overrides LanguageManager::getFallbackCandidates
ConfigurableLanguageManager::getLanguageConfigOverride public function Gets a language config override object. Overrides ConfigurableLanguageManagerInterface::getLanguageConfigOverride
ConfigurableLanguageManager::getLanguageConfigOverrideStorage public function Gets a language configuration override storage object. Overrides ConfigurableLanguageManagerInterface::getLanguageConfigOverrideStorage
ConfigurableLanguageManager::getLanguages public function Returns a list of languages set up on the site. Overrides LanguageManager::getLanguages
ConfigurableLanguageManager::getLanguageSwitchLinks public function Returns the language switch links for the given language type. Overrides LanguageManager::getLanguageSwitchLinks
ConfigurableLanguageManager::getLanguageTypes public function Returns an array of the available language types. Overrides LanguageManager::getLanguageTypes
ConfigurableLanguageManager::getNativeLanguages public function Returns a list of languages set up on the site in their native form. Overrides LanguageManager::getNativeLanguages
ConfigurableLanguageManager::getNegotiatedLanguageMethod public function Gets the negotiated language method ID. Overrides ConfigurableLanguageManagerInterface::getNegotiatedLanguageMethod
ConfigurableLanguageManager::getNegotiator public function Returns the language negotiator. Overrides ConfigurableLanguageManagerInterface::getNegotiator
ConfigurableLanguageManager::getStandardLanguageListWithoutConfigured public function Returns the standard language list excluding already configured languages. Overrides ConfigurableLanguageManagerInterface::getStandardLanguageListWithoutConfigured
ConfigurableLanguageManager::init public function
ConfigurableLanguageManager::isMultilingual public function Returns whether or not the site has more than one language added. Overrides LanguageManager::isMultilingual
ConfigurableLanguageManager::loadLanguageTypesConfiguration protected function Retrieves language types from the configuration storage.
ConfigurableLanguageManager::rebuildServices public static function Rebuild the container to register services needed on multilingual sites. Overrides ConfigurableLanguageManagerInterface::rebuildServices
ConfigurableLanguageManager::reset public function Resets the given language type or all types if none specified. Overrides LanguageManager::reset
ConfigurableLanguageManager::saveLanguageTypesConfiguration public function Stores language types configuration. Overrides ConfigurableLanguageManagerInterface::saveLanguageTypesConfiguration
ConfigurableLanguageManager::setConfigOverrideLanguage public function Sets the configuration override language. Overrides LanguageManager::setConfigOverrideLanguage
ConfigurableLanguageManager::setNegotiator public function Injects the language negotiator. Overrides ConfigurableLanguageManagerInterface::setNegotiator
ConfigurableLanguageManager::updateLockedLanguageWeights public function Updates locked system language weights. Overrides ConfigurableLanguageManagerInterface::updateLockedLanguageWeights
ConfigurableLanguageManager::__construct public function Constructs a new ConfigurableLanguageManager object. Overrides LanguageManager::__construct
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
LanguageManager::$defaultLanguage protected property The default language object.
LanguageManager::$languages protected property A static cache of translated language lists.
LanguageManager::filterLanguages protected function Filters the full list of languages based on the value of the flag.
LanguageManager::getDefaultLanguage public function Returns a language object representing the site's default language. Overrides LanguageManagerInterface::getDefaultLanguage
LanguageManager::getDefaultLockedLanguages public function Returns a list of the default locked languages. Overrides LanguageManagerInterface::getDefaultLockedLanguages
LanguageManager::getLanguage public function Returns a language object from the given language code. Overrides LanguageManagerInterface::getLanguage
LanguageManager::getLanguageName public function Produced the printed name for a language for display. Overrides LanguageManagerInterface::getLanguageName
LanguageManager::getStandardLanguageList public static function Some common languages with their English and native names. Overrides LanguageManagerInterface::getStandardLanguageList
LanguageManager::getUnitedNationsLanguageList public static function The 6 official languages used at the United Nations.
LanguageManager::isLanguageLocked public function Checks whether a language is locked. Overrides LanguageManagerInterface::isLanguageLocked
MockLanguageManager::$currentLanguages protected property List of current languages used in the test.
MockLanguageManager::getCurrentLanguage public function Returns the current language for the given type. Overrides ConfigurableLanguageManager::getCurrentLanguage
MockLanguageManager::setCurrentLanguage public function Sets the current language of the given type to use during tests.