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

Public Member Functions

 clear ()
 
 newDataValueByType ($typeId, $valueString=false, $caption=false, DIProperty $property=null, $contextPage=null)
 
 newDataValueByItem (DataItem $dataItem, DIProperty $property=null, $caption=false)
 
 newDataValueByProperty (DIProperty $property, $valueString=false, $caption=false, $contextPage=null)
 
 newDataValueByText ($propertyName, $valueString, $caption=false, DIWikiPage $contextPage=null)
 
 newPropertyValueByLabel ($propertyLabel, $caption=false, DIWikiPage $contextPage=null)
 
 newErrorValue ($typeid, $errormsg= '', $uservalue= '', $caption=false)
 
 newPropertyValue ($propertyName, $valueString, $caption=false, DIWikiPage $contextPage=null)
 

Static Public Member Functions

static getInstance ()
 
static newDataItemValue (DataItem $dataItem, DIProperty $property=null, $caption=false)
 Deprecated methods. More...
 
static newPropertyObjectValue (DIProperty $property, $valueString=false, $caption=false, $contextPage=null)
 
static newTypeIdValue ($typeId, $valueString=false, $caption=false, DIProperty $property=null, $contextPage=null)
 
static registerDatatype ($id, $className, $dataItemId, $label=false)
 
static registerDatatypeAlias ($id, $label)
 
static findTypeID ($label)
 
static findTypeLabel ($id)
 
static getKnownTypeLabels ()
 
static getDataItemId ($typeId)
 

Protected Member Functions

 __construct (DataTypeRegistry $dataTypeRegistry, DataValueServiceFactory $dataValueServiceFactory)
 

Detailed Description

Factory class for creating SMWDataValue objects for supplied types or properties and data values.

The class has the main entry point newTypeIdValue(), which creates a new datavalue object, possibly with preset user values, captions and property names. To create suitable datavalues for a given property, the method newDataValueByProperty() can be used.

GNU GPL v2+

Since
1.9
Author
Markus Krötzsch
Jeroen De Dauw
mwjames

Constructor & Destructor Documentation

SMW\DataValueFactory::__construct ( DataTypeRegistry  $dataTypeRegistry,
DataValueServiceFactory  $dataValueServiceFactory 
)
protected
Since
1.9
Parameters
DataTypeRegistry$dataTypeRegistry
DataValueServiceFactory$dataValueServiceFactory

Member Function Documentation

SMW\DataValueFactory::clear ( )
Since
2.4
static SMW\DataValueFactory::findTypeID (   $label)
static
static SMW\DataValueFactory::findTypeLabel (   $id)
static
static SMW\DataValueFactory::getDataItemId (   $typeId)
static
static SMW\DataValueFactory::getInstance ( )
static
Since
1.9
Returns
DataValueFactory
static SMW\DataValueFactory::getKnownTypeLabels ( )
static
static SMW\DataValueFactory::newDataItemValue ( DataItem  $dataItem,
DIProperty  $property = null,
  $caption = false 
)
static

Deprecated methods.

Deprecated:
since 2.4, use DataValueFactory::newDataValueByItem
Returns
DataValue
SMW\DataValueFactory::newDataValueByItem ( DataItem  $dataItem,
DIProperty  $property = null,
  $caption = false 
)

Create a value for a data item.

Parameters
$dataItemDataItem
$propertymixed null or SMWDIProperty property object for which this value is made
$captionmixed user-defined caption, or false if none given
Returns
DataValue
SMW\DataValueFactory::newDataValueByProperty ( DIProperty  $property,
  $valueString = false,
  $caption = false,
  $contextPage = null 
)

Create a value for the given property, provided as an SMWDIProperty object. If no value is given, an empty container is created, the value of which can be set later on.

Parameters
$propertySMWDIProperty property object for which this value is made
$valueStringmixed user value string, or false if unknown
$captionmixed user-defined caption, or false if none given
$contextPageSMWDIWikiPage that provides a context for parsing the value string, or null
Returns
DataValue
SMW\DataValueFactory::newDataValueByText (   $propertyName,
  $valueString,
  $caption = false,
DIWikiPage  $contextPage = null 
)

This factory method returns a data value object from a given property, value string. It is intended to be used on user input to allow to turn a property and value string into a data value object.

Since
1.9
Parameters
string$propertyNameproperty string
string$valueStringuser value string
mixed$captionuser-defined caption
SMWDIWikiPage | null$contextPagecontext for parsing the value string
Returns
DataValue
SMW\DataValueFactory::newDataValueByType (   $typeId,
  $valueString = false,
  $caption = false,
DIProperty  $property = null,
  $contextPage = null 
)

Create a value from a type id. If no $value is given, an empty container is created, the value of which can be set later on.

Parameters
$typeIdstring id string for the given type
$valueStringmixed user value string, or false if unknown
$captionmixed user-defined caption, or false if none given
$propertySMWDIProperty property object for which this value is made, or null
$contextPageSMWDIWikiPage that provides a context for parsing the value string, or null
Returns
DataValue
SMW\DataValueFactory::newErrorValue (   $typeid,
  $errormsg = '',
  $uservalue = '',
  $caption = false 
)
Since
2.5
Parameters
string$typeid
string | array$errormsg
string$uservalue
string$caption
Returns
ErrorValue
static SMW\DataValueFactory::newPropertyObjectValue ( DIProperty  $property,
  $valueString = false,
  $caption = false,
  $contextPage = null 
)
static
Deprecated:
since 2.4, use DataValueFactory::newDataValueByProperty
Returns
DataValue
SMW\DataValueFactory::newPropertyValue (   $propertyName,
  $valueString,
  $caption = false,
DIWikiPage  $contextPage = null 
)
Deprecated:
since 2.4, use DataTypeRegistry::newDataValueByText
Returns
DataValue
SMW\DataValueFactory::newPropertyValueByLabel (   $propertyLabel,
  $caption = false,
DIWikiPage  $contextPage = null 
)
Since
2.4
Parameters
string$propertyLabel
string | false$caption
DIWikiPage | null$contextPage
Returns
DataValue
static SMW\DataValueFactory::newTypeIdValue (   $typeId,
  $valueString = false,
  $caption = false,
DIProperty  $property = null,
  $contextPage = null 
)
static
Deprecated:
since 2.4, use DataValueFactory::newDataValueByType
Returns
DataValue
static SMW\DataValueFactory::registerDatatype (   $id,
  $className,
  $dataItemId,
  $label = false 
)
static
static SMW\DataValueFactory::registerDatatypeAlias (   $id,
  $label 
)
static

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