WikiLambda
MediaWiki WikiLambda extension
Loading...
Searching...
No Matches
MediaWiki\Extension\WikiLambda\ZObjects\ZObject Class Reference
+ Inheritance diagram for MediaWiki\Extension\WikiLambda\ZObjects\ZObject:

Public Member Functions

 __construct ( $type)
 Construct a new ZObject instance.
 
 isValid ()
 Validate this ZObject against our schema, to prevent creation and saving of invalid items.
 
 getValueByKey (string $key)
 Fetch value of given key from the current ZObject.
 
 setValueByKey (string $key, ZObject $value)
 Set a value of given key in the current ZObject.
 
 isBuiltin ()
 Returns whether this ZObject is a builtin class.
 
 isTypeReference ()
 Returns whether the object type is a ZReference that points to a type.
 
 isTypeFunctionCall ()
 Returns whether the object type is a ZFunctionCall that resolves to a type.
 
 getZTypeObject ()
 Returns either the ZReference or the ZFunctionCall that contain the type of this ZObject (Z1K1)
 
 getZType ()
 Returns a string with the Zid representing the type of this ZObject.
 
 getZValue ()
 Return the untyped content of this ZObject.
 
 getLinkedZObjects ()
 Return all ZObject Zids that are linked to the current ZObject.
 
 getSerialized ( $form=self::FORM_CANONICAL)
 Convert this ZObject into its serialized canonical representation.
 
 getHumanReadable ( $language=null)
 Convert this ZObject into human readable object by translating all keys and references into the preferred language or its fallbacks.
 
 __toString ()
 Over-ride the default __toString() method to serialise ZObjects into a JSON representation.
 

Static Public Member Functions

static getDefinition ()
 Provide this ZObject's schema.
 

Public Attributes

const FORM_CANONICAL = 1
 
const FORM_NORMAL = 2
 

Protected Attributes

 $type = null
 
 $data = []
 
 $linkedZObjects = []
 

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::__construct ( $type)

Construct a new ZObject instance.

This top-level class has a number of Type-specific sub- classes for built-in representations, and is mostly intended to represent instances of wiki-defined types.

This constructor should only be called by ZObjectFactory (and test code), and not directly. Validation of inputs to this and all other ZObject constructors is left to ZObjectFactory.

Parameters
ZObject$typeZReference or ZFunctionCall that resolves to the type of this ZObject

Reimplemented in MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString, MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualStringSet, MediaWiki\Extension\WikiLambda\ZObjects\ZKeyReference, MediaWiki\Extension\WikiLambda\ZObjects\ZReference, MediaWiki\Extension\WikiLambda\ZObjects\ZQuote, and MediaWiki\Extension\WikiLambda\ZObjects\ZString.

Member Function Documentation

◆ __toString()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::__toString ( )

Over-ride the default __toString() method to serialise ZObjects into a JSON representation.

Returns
string

◆ getDefinition()

◆ getHumanReadable()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::getHumanReadable ( $language = null)

Convert this ZObject into human readable object by translating all keys and references into the preferred language or its fallbacks.

Parameters
Language | null$language
Returns
\stdClass|array|string

◆ getLinkedZObjects()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::getLinkedZObjects ( )

Return all ZObject Zids that are linked to the current ZObject.

Returns
string[] An array of other ZObjects to which this ZObject links for injection into the MediaWiki system as if they were wiki links.

◆ getSerialized()

◆ getValueByKey()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::getValueByKey ( string $key)

Fetch value of given key from the current ZObject.

Parameters
string$keyThe key to search for.
Returns
ZObject|null The value of the supplied key as a ZObject, null if key is undefined.
+ Here is the caller graph for this function:

◆ getZType()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::getZType ( )

Returns a string with the Zid representing the type of this ZObject.

If it has an anonymous type given by a ZFunctionCall, this method returns the Function Zid

TODO (T301553): Return the output type of the Function instead of its identifier

Returns
string The type of this ZObject
+ Here is the caller graph for this function:

◆ getZTypeObject()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::getZTypeObject ( )

Returns either the ZReference or the ZFunctionCall that contain the type of this ZObject (Z1K1)

Returns
ZReference|ZFunctionCall The ZObject representing the type of this ZObject

◆ getZValue()

◆ isBuiltin()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::isBuiltin ( )

Returns whether this ZObject is a builtin class.

Returns
bool Whether this object is a built-in type or generic, or it's a direct instance of ZObject

◆ isTypeFunctionCall()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::isTypeFunctionCall ( )

Returns whether the object type is a ZFunctionCall that resolves to a type.

Returns
bool Whether the object type is a function call to a type

◆ isTypeReference()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::isTypeReference ( )

Returns whether the object type is a ZReference that points to a type.

Returns
bool Whether the object type is a reference to a type

◆ isValid()

◆ setValueByKey()

MediaWiki\Extension\WikiLambda\ZObjects\ZObject::setValueByKey ( string $key,
ZObject $value )

Set a value of given key in the current ZObject.

Parameters
string$keyThe key to set.
ZObject$valueThe value to set.

The documentation for this class was generated from the following file: