Page MenuHomeWickedGov Phorge

LazyLocalizationContext.php
No OneTemporary

Size
849 B
Referenced Files
None
Subscribers
None

LazyLocalizationContext.php

<?php
/**
* @license GPL-2.0-or-later
* @file
*/
namespace MediaWiki\Language;
/**
* Wrapper for injecting a LocalizationContext with lazy initialization.
*
* @since 1.42
* @ingroup Language
*/
class LazyLocalizationContext implements LocalizationContext {
/** @var callable */
private $instantiator;
private ?LocalizationContext $context = null;
public function __construct( callable $instantiator ) {
$this->instantiator = $instantiator;
}
private function resolve(): LocalizationContext {
if ( !$this->context ) {
$this->context = ( $this->instantiator )();
}
return $this->context;
}
/** @inheritDoc */
public function getLanguageCode() {
return $this->resolve()->getLanguageCode();
}
/** @inheritDoc */
public function msg( $key, ...$params ) {
return $this->resolve()->msg( $key, ...$params );
}
}

File Metadata

Mime Type
text/x-php
Expires
Aug 19 2026, 18:40 (6 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
52/f6/9a423e122b31803cc4344deabb3a
Default Alt Text
LazyLocalizationContext.php (849 B)

Event Timeline