Semantic MediaWiki and related extensions
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
SMW\DataTypeRegistry Class Reference

Public Member Functions

 __construct (LocalLanguage $localLanguage)
 
 getDataItemId ( $typeId)
 
 getDataItemByType ( $typeId)
 
 isRegistered ( $typeId)
 
 isRecordType (string $typeId)
 
 isSubDataType ( $typeId)
 
 isBrowsableType ( $typeId)
 
 isEqualByType ( $srcType, $tagType)
 
 registerDataType ( $id, $className, $dataItemId, $label=false, $isSubDataType=false, $isBrowsableType=false)
 
 registerDataTypeAlias ( $typeId, $typeAlias)
 
 findTypeId ( $label)
 
 findTypeByLabel ( $label)
 
 findTypeByLabelAndLanguage ( $label, $languageCode=false)
 
 getFieldType ( $type)
 
 findTypeLabel ( $id)
 
 findCanonicalLabelById ( $id)
 
 getCanonicalDatatypeLabels ()
 
 getKnownTypeLabels ()
 
 getKnownTypeAliases ()
 
 getDefaultDataItemTypeId ( $diType)
 
 getDefaultDataItemByType ( $typeId)
 
 getDataTypeClassById ( $typeId)
 
 hasDataTypeClassById ( $typeId)
 
 registerCallable ( $typeId, $key, callable $callable)
 
 getCallablesByTypeId ( $typeId)
 
 clearCallables ()
 

Static Public Member Functions

static getInstance ()
 
static clear ()
 

Protected Member Functions

 initDatatypes (array $typeList)
 

Static Protected Attributes

static $instance = null
 

Detailed Description

DataTypes registry class

Registry class that manages datatypes, and provides various methods to access the information

GNU GPL v2+

Since
1.9
Author
Markus Krötzsch
Jeroen De Dauw
mwjames

Constructor & Destructor Documentation

◆ __construct()

SMW\DataTypeRegistry::__construct ( LocalLanguage  $localLanguage)
Since
1.9.0.2
Parameters
Lang$localLanguage

Member Function Documentation

◆ clear()

static SMW\DataTypeRegistry::clear ( )
static

Resets the DataTypeRegistry instance

Since
1.9

◆ clearCallables()

SMW\DataTypeRegistry::clearCallables ( )
Since
3.1

◆ findCanonicalLabelById()

SMW\DataTypeRegistry::findCanonicalLabelById (   $id)

Returns a label for a typeId that is independent from the user/content language

Since
2.3
Returns
string

◆ findTypeByLabel()

SMW\DataTypeRegistry::findTypeByLabel (   $label)

Look up the ID that identifies the datatype of the given label internally. This id is used for all internal operations. If the label does not belong to a known type, the empty string is returned.

Since
3.0
Parameters
string$label
Returns
string

◆ findTypeByLabelAndLanguage()

SMW\DataTypeRegistry::findTypeByLabelAndLanguage (   $label,
  $languageCode = false 
)
Since
2.5
Parameters
string$label
string | false$languageCode
Returns
string

◆ findTypeId()

SMW\DataTypeRegistry::findTypeId (   $label)

◆ findTypeLabel()

SMW\DataTypeRegistry::findTypeLabel (   $id)

Get the translated user label for a given internal ID. If the ID does not have a label associated with it in the current language, the empty string is returned. This is the case both for internal type ids and for invalid (unknown) type ids, so this method cannot be used to distinguish the two.

Parameters
string$id
Returns
string

◆ getCallablesByTypeId()

SMW\DataTypeRegistry::getCallablesByTypeId (   $typeId)
Since
3.1
Parameters
string$typeId
Returns
[]

◆ getCanonicalDatatypeLabels()

SMW\DataTypeRegistry::getCanonicalDatatypeLabels ( )
Since
2.4
Returns
array

◆ getDataItemByType()

SMW\DataTypeRegistry::getDataItemByType (   $typeId)

Get the preferred data item ID for a given type. The ID defines the appropriate data item class for processing data of this type. See DataItem for possible values.

Note
SMWDIContainer is a pseudo dataitem type that is used only in data input methods, but not for storing data. Types that work with SMWDIContainer use SMWDIWikiPage as their DI type. (Since SMW 1.8)
Parameters
$typeIdstring id string for the given type
Returns
integer data item ID

◆ getDataItemId()

SMW\DataTypeRegistry::getDataItemId (   $typeId)

◆ getDataTypeClassById()

SMW\DataTypeRegistry::getDataTypeClassById (   $typeId)

Returns a class based on a typeId

Since
1.9
Parameters
string$typeId
Returns
string|null

◆ getDefaultDataItemByType()

SMW\DataTypeRegistry::getDefaultDataItemByType (   $typeId)

Returns a default DataItem for a matchable type ID

Since
2.5
Parameters
string$diType
Returns
string|null

◆ getDefaultDataItemTypeId()

SMW\DataTypeRegistry::getDefaultDataItemTypeId (   $diType)

◆ getFieldType()

SMW\DataTypeRegistry::getFieldType (   $type)
Since
3.0
Parameters
string$type
Returns
string

◆ getInstance()

static SMW\DataTypeRegistry::getInstance ( )
static

Returns a DataTypeRegistry instance

Since
1.9
Returns
DataTypeRegistry

◆ getKnownTypeAliases()

SMW\DataTypeRegistry::getKnownTypeAliases ( )
Since
2.1
Returns
array

◆ getKnownTypeLabels()

SMW\DataTypeRegistry::getKnownTypeLabels ( )

Return an array of all labels that a user might specify as the type of a property, and that are internal (i.e. not user defined). No labels are returned for internal types without user labels (e.g. the special types for some special properties), and for user defined types.

Returns
array

◆ hasDataTypeClassById()

SMW\DataTypeRegistry::hasDataTypeClassById (   $typeId)

Whether a datatype class is registered for a particular typeId

Since
1.9
Parameters
string$typeId
Returns
boolean

◆ initDatatypes()

SMW\DataTypeRegistry::initDatatypes ( array  $typeList)
protected

Gather all available datatypes and label<=>id<=>datatype associations. This method is called before most methods of this factory.

◆ isBrowsableType()

SMW\DataTypeRegistry::isBrowsableType (   $typeId)
Since
3.0
Parameters
string$typeId
Returns
boolean

◆ isEqualByType()

SMW\DataTypeRegistry::isEqualByType (   $srcType,
  $tagType 
)
Since
2.5
Parameters
string$srcType
string$tagType
Returns
boolean

◆ isRecordType()

SMW\DataTypeRegistry::isRecordType ( string  $typeId)
Since
3.2
Parameters
string$typeId
Returns
boolean

◆ isRegistered()

SMW\DataTypeRegistry::isRegistered (   $typeId)
Since
2.0
Parameters
string
Returns
boolean

◆ isSubDataType()

SMW\DataTypeRegistry::isSubDataType (   $typeId)
Since
2.4
Parameters
string$typeId
Returns
boolean

◆ registerCallable()

SMW\DataTypeRegistry::registerCallable (   $typeId,
  $key,
callable  $callable 
)

This function allows for registered types to add additional data or functions required by an individual DataValue of that type.

Register the data: $dataTypeRegistry = DataTypeRegistry::getInstance();

$dataTypeRegistry->registerDataType( '__foo', ... ); $dataTypeRegistry->registerCallable( '__foo', 'my.function', ... ); ...

Access the data: $dataValueFactory = DataValueFactory::getInstance();

$dataValue = $dataValueFactory->newDataValueByType( '__foo' ); $dataValue->getCallable( 'my.function' ) ...

Since
3.1
Parameters
string$typeId
string$key
callable$callable
Exceptions
RuntimeException

◆ registerDataType()

SMW\DataTypeRegistry::registerDataType (   $id,
  $className,
  $dataItemId,
  $label = false,
  $isSubDataType = false,
  $isBrowsableType = false 
)

A function for registering/overwriting datatypes for SMW. Should be called from within the hook 'smwInitDatatypes'.

Parameters
$idstring type ID for which this datatype is registered
$classNamestring name of the according subclass of SMWDataValue
$dataItemIdinteger ID of the data item class that this data value uses, see DataItem
$labelmixed string label or false for types that cannot be accessed by users
boolean$isSubDataType
boolean$isBrowsableType

◆ registerDataTypeAlias()

SMW\DataTypeRegistry::registerDataTypeAlias (   $typeId,
  $typeAlias 
)

Add a new alias label to an existing datatype id. Note that every ID should have a primary label, either provided by SMW or registered with registerDataType(). This function should be called from within the hook 'smwInitDatatypes'.

Parameters
string$typeId
string$typeAlias

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

About | General disclaimer | Privacy policy