Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6172062
ContentJsonCodec.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ContentJsonCodec.php
View Options
<?php
declare
(
strict_types
=
1
);
/**
* @license GPL-2.0-or-later
* @file
*/
namespace
MediaWiki\Content
;
use
Wikimedia\JsonCodec\JsonClassCodec
;
/**
* ContentJsonCodec handles serialization of Content objects to/from
* JSON using methods of the appropriate ContentHandler.
*
* @implements JsonClassCodec<Content>
* @internal
*/
class
ContentJsonCodec
implements
JsonClassCodec
{
public
function
__construct
(
private
IContentHandlerFactory
$contentHandlerFactory
)
{
}
/** @inheritDoc */
public
function
toJsonArray
(
$obj
):
array
{
// To serialize content we need a handler.
$model
=
$obj
->
getModel
();
$handler
=
$this
->
contentHandlerFactory
->
getContentHandler
(
$model
);
// @phan-suppress-next-line PhanTypeMismatchArgument -- Phan doesn't support generic interfaces
return
[
'model'
=>
$model
]
+
$handler
->
serializeContentToJsonArray
(
$obj
);
}
/** @inheritDoc */
public
function
newFromJsonArray
(
string
$className
,
array
$json
)
{
// To deserialize content we need a handler.
$model
=
$json
[
'model'
];
$handler
=
$this
->
contentHandlerFactory
->
getContentHandler
(
$model
);
$content
=
$handler
->
deserializeContentFromJsonArray
(
$json
);
// @phan-suppress-next-line PhanTypeMismatchReturn -- Phan doesn't support generic interfaces
return
$content
;
}
/** @inheritDoc */
public
function
jsonClassHintFor
(
string
$className
,
string
$keyName
)
{
return
null
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 8 2026, 22:03 (7 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
58/08/21fbe6ed3ed7d44ca91cefda6ab3
Default Alt Text
ContentJsonCodec.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment