MediaWiki REL1_35
XmlJsCode.php
Go to the documentation of this file.
1<?php
40class XmlJsCode {
41 public $value;
42
43 public function __construct( $value ) {
44 $this->value = $value;
45 }
46
58 public static function encodeObject( $obj, $pretty = false ) {
59 $parts = [];
60 foreach ( $obj as $key => $value ) {
61 $parts[] =
62 ( $pretty ? ' ' : '' ) .
63 Xml::encodeJsVar( $key, $pretty ) .
64 ( $pretty ? ': ' : ':' ) .
65 Xml::encodeJsVar( $value, $pretty );
66 }
67 return new self(
68 '{' .
69 ( $pretty ? "\n" : '' ) .
70 implode( $pretty ? ",\n" : ',', $parts ) .
71 ( $pretty ? "\n" : '' ) .
72 '}'
73 );
74 }
75}
A wrapper class which causes Xml::encodeJsVar() and Xml::encodeJsCall() to interpret a given string a...
Definition XmlJsCode.php:40
static encodeObject( $obj, $pretty=false)
Encode an object containing XmlJsCode objects.
Definition XmlJsCode.php:58
__construct( $value)
Definition XmlJsCode.php:43