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

 addCallable ( $key, callable $callable)
 
 clearCallable ( $key)
 
 clear ()
 
 setFeatureSet ( $featureSet)
 
 setDefaultOutputFormatters (array $defaultOutputFormatters)
 
 newDataValueByType ( $typeId, $valueString=false, $caption=false, DIProperty $property=null, $contextPage=null)
 
 newDataValueByItem (DataItem $dataItem, DIProperty $property=null, $caption=false, $contextPage=null)
 
 newDataValueByProperty (DIProperty $property, $valueString=false, $caption=false, $contextPage=null)
 
 newDataValueByText ( $propertyName, $valueString, $caption=false, DIWikiPage $contextPage=null)
 
 newPropertyValueByLabel ( $propertyLabel, $caption=false, DIWikiPage $contextPage=null)
 
 newPropertyValueByItem (DIProperty $property, $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)
 

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

◆ __construct()

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

Member Function Documentation

◆ addCallable()

SMW\DataValueFactory::addCallable (   $key,
callable  $callable 
)
Since
3.1
Parameters
string$key
callable$callable
Exceptions
RuntimeException

◆ clear()

SMW\DataValueFactory::clear ( )
Since
2.4

◆ clearCallable()

SMW\DataValueFactory::clearCallable (   $key)
Since
3.1
Parameters
string$key

◆ getInstance()

static SMW\DataValueFactory::getInstance ( )
static
Since
1.9
Returns
DataValueFactory

◆ newDataItemValue()

static SMW\DataValueFactory::newDataItemValue ( DataItem  $dataItem,
DIProperty  $property = null,
  $caption = false 
)
static

Deprecated methods.

Deprecated:
since 2.4, use DataValueFactory::newDataValueByItem
Returns
DataValue

◆ newDataValueByItem()

SMW\DataValueFactory::newDataValueByItem ( DataItem  $dataItem,
DIProperty  $property = null,
  $caption = false,
  $contextPage = null 
)

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
DIWikiPage | null$contextPage
Returns
DataValue

◆ newDataValueByProperty()

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

◆ newDataValueByText()

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

◆ newDataValueByType()

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
string$typeIdid string for the given type
string | false$valueStringuser value string, or false if unknown
string | false$captionuser-defined caption, or false if none given
DIProperty | null$propertyproperty object for which this value is made, or null
DIWikiPage | null$contextPagethat provides a context for parsing the value string, or null
Returns
DataValue

◆ newErrorValue()

SMW\DataValueFactory::newErrorValue (   $typeid,
  $errormsg = '',
  $uservalue = '',
  $caption = false 
)
Since
2.5
Parameters
string$typeid
string | array$errormsg
string$uservalue
string$caption
Returns
ErrorValue

◆ newPropertyObjectValue()

static SMW\DataValueFactory::newPropertyObjectValue ( DIProperty  $property,
  $valueString = false,
  $caption = false,
  $contextPage = null 
)
static
Deprecated:
since 2.4, use DataValueFactory::newDataValueByProperty
Returns
DataValue

◆ newPropertyValue()

SMW\DataValueFactory::newPropertyValue (   $propertyName,
  $valueString,
  $caption = false,
DIWikiPage  $contextPage = null 
)
Deprecated:
since 2.4, use DataTypeRegistry::newDataValueByText
Returns
DataValue

◆ newPropertyValueByItem()

SMW\DataValueFactory::newPropertyValueByItem ( DIProperty  $property,
  $caption = false,
DIWikiPage  $contextPage = null 
)
Since
3.1
Parameters
DIProperty$property
string | false$caption
DIWikiPage | null$contextPage
Returns
DataValue

◆ newPropertyValueByLabel()

SMW\DataValueFactory::newPropertyValueByLabel (   $propertyLabel,
  $caption = false,
DIWikiPage  $contextPage = null 
)
Since
2.4
Parameters
string$propertyLabel
string | false$caption
DIWikiPage | null$contextPage
Returns
DataValue

◆ newTypeIdValue()

static SMW\DataValueFactory::newTypeIdValue (   $typeId,
  $valueString = false,
  $caption = false,
DIProperty  $property = null,
  $contextPage = null 
)
static
Deprecated:
since 2.4, use DataValueFactory::newDataValueByType
Returns
DataValue

◆ setDefaultOutputFormatters()

SMW\DataValueFactory::setDefaultOutputFormatters ( array  $defaultOutputFormatters)
Since
3.0
Parameters
array$defaultOutputFormatters

◆ setFeatureSet()

SMW\DataValueFactory::setFeatureSet (   $featureSet)
Since
3.1
Parameters
integer$featureSet

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

About | General disclaimer | Privacy policy