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
Sat, May 16, 15:19 (15 h, 13 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ae/df/7383bb1b963a8c9c8fc2596e4747
Default Alt Text
LazyLocalizationContext.php (849 B)

Event Timeline