jenkins-bot has submitted this change and it was merged.
Change subject: Refactored JCSingleton::getContent -> parseContent
......................................................................
Refactored JCSingleton::getContent -> parseContent
JCSingleton::getContent() with optional $jsonText is now obsolete,
instead clients should use parseContent().
getContent() should only be used with a single TitleValue parameter
Needed-by: Idaa10e301b0fea6409d35ebd24da4a81415c37d8
Change-Id: I3abe44380499344c2048c1871f1ea19184a0ec77
---
M includes/JCSingleton.php
1 file changed, 23 insertions(+), 1 deletion(-)
Approvals:
MaxSem: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/JCSingleton.php b/includes/JCSingleton.php
index 598bc15..f22dc6a 100644
--- a/includes/JCSingleton.php
+++ b/includes/JCSingleton.php
@@ -278,10 +278,13 @@
* Namespace ID does not need to be defined in the current wiki,
* as long as it is defined in $wgJsonConfigs.
* @param TitleValue $titleValue
- * @param string $jsonText if given, parses this text instead of what's
stored in the database/cache
+ * @param string $jsonText obsolete, use parseContent() instead. If
given, parses this text instead of what's stored in the database/cache
* @return bool|JCContent Returns false if the title is not handled by
the settings
*/
public static function getContent( TitleValue $titleValue, $jsonText =
null ) {
+
+ // TODO: remove $jsonText -- parseContent() should be used
instead
+
$conf = self::getMetadata( $titleValue );
if ( $conf ) {
if ( is_string( $jsonText ) ) {
@@ -302,6 +305,25 @@
}
/**
+ * Parse json text into a content object for the given title.
+ * Namespace ID does not need to be defined in the current wiki,
+ * as long as it is defined in $wgJsonConfigs.
+ * @param TitleValue $titleValue
+ * @param string $jsonText json content
+ * @return bool|JCContent Returns false if the title is not handled by
the settings
+ */
+ public static function parseContent( TitleValue $titleValue, $jsonText
) {
+
+ $conf = self::getMetadata( $titleValue );
+ if ( $conf ) {
+ $handler = new JCContentHandler( $conf->model );
+ return $handler->unserializeContent( $jsonText, null,
false );
+ }
+
+ return false;
+ }
+
+ /**
* Mostly for debugging purposes, this function returns initialized
internal JsonConfig settings
* @return array
*/
--
To view, visit https://gerrit.wikimedia.org/r/291005
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3abe44380499344c2048c1871f1ea19184a0ec77
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/JsonConfig
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits