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 (ExtraneousLanguage $extraneousLanguage)
 
 getDataItemId ($typeId)
 
 getDataItemByType ($typeId)
 
 isKnownByType ($typeId)
 
 isSubDataType ($typeId)
 
 isEqualByType ($srcType, $tagType)
 
 registerDataType ($id, $className, $dataItemId, $label=false, $isSubDataType=false)
 
 registerDataTypeAlias ($typeId, $typeAlias)
 
 findTypeId ($label)
 
 findTypeByLanguage ($label, $languageCode=false)
 
 findTypeLabel ($id)
 
 findCanonicalLabelById ($id)
 
 getCanonicalDatatypeLabels ()
 
 getKnownTypeLabels ()
 
 getKnownTypeAliases ()
 
 getDefaultDataItemTypeId ($diType)
 
 getDefaultDataItemByType ($typeId)
 
 getDataTypeClassById ($typeId)
 
 hasDataTypeClassById ($typeId)
 
 registerExtraneousFunction ($name,\Closure $callback)
 
 getExtraneousFunctions ()
 
 getOptions ()
 
 setOption ($key, $value)
 

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

SMW\DataTypeRegistry::__construct ( ExtraneousLanguage  $extraneousLanguage)
Since
1.9.0.2
Parameters
ExtraneousLanguage$extraneousLanguage

Member Function Documentation

static SMW\DataTypeRegistry::clear ( )
static

Resets the DataTypeRegistry instance

Since
1.9
SMW\DataTypeRegistry::findCanonicalLabelById (   $id)

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

Since
2.3
Returns
string
SMW\DataTypeRegistry::findTypeByLanguage (   $label,
  $languageCode = false 
)
Since
2.5
Parameters
string$label
string | false$languageCode
Returns
string
SMW\DataTypeRegistry::findTypeId (   $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.

The lookup is case insensitive.

Parameters
string$label
Returns
string
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
SMW\DataTypeRegistry::getCanonicalDatatypeLabels ( )
Since
2.4
Returns
array
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
SMW\DataTypeRegistry::getDataItemId (   $typeId)
SMW\DataTypeRegistry::getDataTypeClassById (   $typeId)

Returns a class based on a typeId

Since
1.9
Parameters
string$typeId
Returns
string|null
SMW\DataTypeRegistry::getDefaultDataItemByType (   $typeId)

Returns a default DataItem for a matchable type ID

Since
2.5
Parameters
string$diType
Returns
string|null
SMW\DataTypeRegistry::getDefaultDataItemTypeId (   $diType)
SMW\DataTypeRegistry::getExtraneousFunctions ( )
Since
2.3
Returns
Closure[]
static SMW\DataTypeRegistry::getInstance ( )
static

Returns a DataTypeRegistry instance

Since
1.9
Returns
DataTypeRegistry
SMW\DataTypeRegistry::getKnownTypeAliases ( )
Since
2.1
Returns
array
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
SMW\DataTypeRegistry::getOptions ( )
Since
2.4
Returns
Options
SMW\DataTypeRegistry::hasDataTypeClassById (   $typeId)

Whether a datatype class is registered for a particular typeId

Since
1.9
Parameters
string$typeId
Returns
boolean
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.

SMW\DataTypeRegistry::isEqualByType (   $srcType,
  $tagType 
)
Since
2.5
Parameters
string$srcType
string$tagType
Returns
boolean
SMW\DataTypeRegistry::isKnownByType (   $typeId)
Since
2.0
Parameters
string
Returns
boolean
SMW\DataTypeRegistry::isSubDataType (   $typeId)
Since
2.4
Parameters
string$typeId
Returns
boolean
SMW\DataTypeRegistry::registerDataType (   $id,
  $className,
  $dataItemId,
  $label = false,
  $isSubDataType = 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
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
SMW\DataTypeRegistry::registerExtraneousFunction (   $name,
\Closure  $callback 
)

Inject services and objects that are planned to be used during the invocation of a DataValue

Since
2.3
Parameters
string$name
\Closure$callback
SMW\DataTypeRegistry::setOption (   $key,
  $value 
)
Since
2.4
Parameters
string$key
string$value

Member Data Documentation

SMW\DataTypeRegistry::$instance = null
staticprotected

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