MediaWiki
master
JsonDeserializableCodec.php
Go to the documentation of this file.
1
<?php
22
namespace
MediaWiki\Json
;
23
24
use Wikimedia\JsonCodec\JsonClassCodec;
25
34
class
JsonDeserializableCodec
implements
JsonClassCodec {
35
private
JsonDeserializer
$codec;
36
37
public
function
__construct
(
JsonDeserializer
$codec ) {
38
$this->codec = $codec;
39
}
40
42
public
function
toJsonArray
( $obj ): array {
43
$result = $obj->jsonSerialize();
44
// Undo the work of JsonDeserializableTrait to avoid
45
// redundant storage of TYPE_ANNOTATION
46
unset( $result[
JsonConstants::TYPE_ANNOTATION
] );
47
return
$result;
48
}
49
51
public
function
newFromJsonArray
(
string
$className, array $json ) {
52
return
$className::newFromJsonArray( $this->codec, $json );
53
}
54
56
public
function
jsonClassHintFor
(
string
$className,
string
$keyName ) {
57
return
null
;
58
}
59
}
MediaWiki\Json\JsonDeserializableCodec
A JsonClassCodec for objects implementing the JsonDeserializable interface.
Definition
JsonDeserializableCodec.php:34
MediaWiki\Json\JsonDeserializableCodec\jsonClassHintFor
jsonClassHintFor(string $className, string $keyName)
Definition
JsonDeserializableCodec.php:56
MediaWiki\Json\JsonDeserializableCodec\__construct
__construct(JsonDeserializer $codec)
Definition
JsonDeserializableCodec.php:37
MediaWiki\Json\JsonDeserializableCodec\newFromJsonArray
newFromJsonArray(string $className, array $json)
Definition
JsonDeserializableCodec.php:51
MediaWiki\Json\JsonDeserializableCodec\toJsonArray
toJsonArray( $obj)
Definition
JsonDeserializableCodec.php:42
MediaWiki\Json\JsonConstants\TYPE_ANNOTATION
const TYPE_ANNOTATION
Name of the property where the class information is stored.
Definition
JsonConstants.php:34
MediaWiki\Json\JsonDeserializer
Definition
JsonDeserializer.php:33
MediaWiki\Json
Definition
FormatJson.php:23
includes
json
JsonDeserializableCodec.php
Generated on Thu Dec 26 2024 23:24:07 for MediaWiki by
1.10.0