22use Wikimedia\Minify\CSSMin;
44 if ( isset( $options[
'lessMessages'] ) ) {
45 $this->lessVariables = $options[
'lessMessages'];
55 return array_merge( $this->messages, $this->lessVariables );
65 private function pluckFromMessageBlob(
$blob, array $allowed ): array {
69 return array_intersect_key( $data, array_fill_keys( $allowed,
true ) );
76 $blob = parent::getMessageBlob( $context );
82 return json_encode( (
object)$this->pluckFromMessageBlob(
$blob, $this->messages ) );
106 private static function wrapAndEscapeMessage( $msg ) {
107 return str_replace(
"'",
"\'", CSSMin::serializeStringValue( $msg ) );
119 $vars = parent::getLessVars( $context );
121 $blob = parent::getMessageBlob( $context );
122 $messages = $this->pluckFromMessageBlob(
$blob, $this->lessVariables );
129 foreach ( $this->lessVariables as $msgKey ) {
130 $vars[
'msg-' . $msgKey] = self::wrapAndEscapeMessage( $messages[$msgKey] ??
"⧼{$msgKey}⧽" );
138class_alias( LessVarFileModule::class,
'ResourceLoaderLessVarFileModule' );
Context object that contains information about the state of a specific ResourceLoader web request.