PHP Interface MetaModels\Attribute\IAttribute

To create Attribute instances, use a {@link Factory} This interface handles all general purpose attribute management and interfacing.
Show file Open project: metamodels/core Interface Usage Examples

Public Methods

Method Description
destroyAUX ( ) : void Delete all auxiliary data like a column in the MetaModel table or references in another table etc.
filterGreaterThan ( mixed $varValue, boolean $blnInclusive = false ) : string[] | null Filter all values greater than the passed value.
filterLessThan ( mixed $varValue, boolean $blnInclusive = false ) : string[] | null Filter all values less than the passed value.
filterNotEqual ( mixed $varValue ) : string[] | null Filter all values not having the passed value.
get ( string $strKey ) : mixed Retrieve a meta information setting.
getAttributeSettingNames ( ) : string[] Returns all valid settings for the attribute type.
getColName ( ) : string Queries the attribute for it's column name within it's MetaModel.
getDefaultRenderSettings ( ) : MetaModels\Render\Setting\Simple Retrieve an instance containing the default render settings for an attribute of this type.
getFieldDefinition ( array $arrOverrides = [] ) : array This generates the field definition for use in a DCA.
getFilterOptions ( string[] | null $idList, boolean $usedOnly, array | null &$arrCount = null ) : array Retrieve the filter options of this attribute.
getFilterUrlValue ( mixed $varValue ) : string Convert a native attribute value into a value to be used in a filter Url.
getItemDCA ( array $arrOverrides = [] ) : array This generates the field definition for use in a DCA.
getMetaModel ( ) : MetaModels\IMetaModel Queries the attribute for it's parent MetaModel instance.
getName ( ) : string Retrieve the human readable name (or title) from the attribute.
handleMetaChange ( string $strMetaName, mixed $varNewValue ) : MetaModels\Attribute\IAttribute Updates the meta information of the attribute.
initializeAUX ( ) : void Create auxiliary data like a column in the MetaModel table or references in another table etc.
modelSaved ( MetaModels\IItem $objItem ) : void Called by the MetaModel after an item has been saved.
parseValue ( array $arrRowData, string $strOutputFormat = 'text', MetaModels\Render\Setting\ISimple | null $objSettings = null ) : array Transform a value into real data.
searchFor ( string $strPattern ) : string[] | null Search all items that match the given expression.
set ( string $strKey, mixed $varValue ) : MetaModels\Attribute\IAttribute Override a meta information setting.
setDataFor ( mixed[] $arrValues ) : void This method is called to store the data for certain items to the database.
sortIds ( string[] $idList, string $strDirection ) : string[] Sorts the given array list by field value in the given direction.
valueToWidget ( mixed $varValue ) : mixed Convert native attribute value to widget value.
widgetToValue ( mixed $varValue, string $itemId ) : mixed Convert a value obtained from a widget to a native value of this attribute.

Method Details

destroyAUX() public method

Delete all auxiliary data like a column in the MetaModel table or references in another table etc.
public destroyAUX ( ) : void
return void

filterGreaterThan() public method

Filter all values greater than the passed value.
public filterGreaterThan ( mixed $varValue, boolean $blnInclusive = false ) : string[] | null
$varValue mixed The value to use as lower end.
$blnInclusive boolean If true, the passed value will be included, if false, it will be excluded.
return string[] | null The list of item ids of all items matching the condition or null if all match.

filterLessThan() public method

Filter all values less than the passed value.
public filterLessThan ( mixed $varValue, boolean $blnInclusive = false ) : string[] | null
$varValue mixed The value to use as upper end.
$blnInclusive boolean If true, the passed value will be included, if false, it will be excluded.
return string[] | null The list of item ids of all items matching the condition or null if all match.

filterNotEqual() public method

Filter all values not having the passed value.
public filterNotEqual ( mixed $varValue ) : string[] | null
$varValue mixed The value to use as upper end.
return string[] | null The list of item ids of all items matching the condition or null if all match.

get() public method

Retrieve a meta information setting.
public get ( string $strKey ) : mixed
$strKey string The meta information name that shall be retrieved.
return mixed

getAttributeSettingNames() public method

Returns all valid settings for the attribute type.
public getAttributeSettingNames ( ) : string[]
return string[] All valid setting names, this re-ensembles the columns in tl_metamodel_attribute this attribute class understands.

getColName() public method

Queries the attribute for it's column name within it's MetaModel.
public getColName ( ) : string
return string the attributes column name.

getDefaultRenderSettings() public method

Retrieve an instance containing the default render settings for an attribute of this type.
public getDefaultRenderSettings ( ) : MetaModels\Render\Setting\Simple
return MetaModels\Render\Setting\Simple

getFieldDefinition() public method

It also sets the proper language variables (if not already set per dca-config.php or similar). Using the optional override parameter, settings known by this attribute can be overridden for the generating of the output array.
public getFieldDefinition ( array $arrOverrides = [] ) : array
$arrOverrides array The values to override, for a list of valid parameters, call getAttributeSettingNames().
return array The DCA array to use as $GLOBALS['TL_DCA']['tablename']['fields']['attribute-name]

getFilterOptions() public method

Retrieve values for use in filter options, that will be understood by DC_ filter panels and frontend filter select boxes. One can influence the amount of returned entries with the two parameters. For the id list, the value "null" represents (as everywhere in MetaModels) all entries. An empty array will return no entries at all. The parameter "used only" determines, if only really attached values shall be returned. This is only relevant, when using "null" as id list for attributes that have pre configured values like select lists and tags i.e.
public getFilterOptions ( string[] | null $idList, boolean $usedOnly, array | null &$arrCount = null ) : array
$idList string[] | null The ids of items that the values shall be fetched from (If empty or null, all items).
$usedOnly boolean Determines if only "used" values shall be returned.
$arrCount array | null Array for the counted values.
return array All options matching the given conditions as name => value.

getFilterUrlValue() public method

Convert a native attribute value into a value to be used in a filter Url.
public getFilterUrlValue ( mixed $varValue ) : string
$varValue mixed The source value.
return string

getItemDCA() public method

The result contains all relevant settings for this field in an DCA for the given table and MAY override anything like palettes, sub palettes, field definitions etc. Due to the fact that it calls getFieldDefinition() internally, the result at least contains the sub array 'fields' with the information of this field's settings.
Deprecation: Use DataDefinition builders in DC_General 2.0.0
public getItemDCA ( array $arrOverrides = [] ) : array
$arrOverrides array See documentation in getFieldDefinition() method.
return array The DCA array to use as $GLOBALS['tablename']

getMetaModel() public method

Queries the attribute for it's parent MetaModel instance.
public getMetaModel ( ) : MetaModels\IMetaModel
return MetaModels\IMetaModel the MetaModel instance.

getName() public method

If the MetaModel is translated, the currently active language is used, with properly falling back to the defined fallback language.
public getName ( ) : string
return string the human readable name

handleMetaChange() public method

This tells the attribute to perform any actions that must be done to correctly initialize the new value and to perform any action to undo the changes that had been done for the previous value. i.e.: when an attribute type needs columns in an an auxiliary table, these will have to be updated herein. This method may throw an exception, when the new value is invalid or any problems appear, the Attribute will then keep the old meta value.
public handleMetaChange ( string $strMetaName, mixed $varNewValue ) : MetaModels\Attribute\IAttribute
$strMetaName string Name of the meta information that shall be updated.
$varNewValue mixed The new value for this meta information.
return MetaModels\Attribute\IAttribute The instance of this attribute, to support chaining.

initializeAUX() public method

Create auxiliary data like a column in the MetaModel table or references in another table etc.
public initializeAUX ( ) : void
return void

modelSaved() public method

Useful for alias fields, edit counters etc.
public modelSaved ( MetaModels\IItem $objItem ) : void
$objItem MetaModels\IItem The item that has just been saved.
return void

parseValue() public method

The returned array at least transports an string in the key 'text' which SHOULD be useful when being echo'ed in a template and the raw value in the section 'raw'. Each attribute class MAY return as many other values in this array with custom keys as it wants.
public parseValue ( array $arrRowData, string $strOutputFormat = 'text', MetaModels\Render\Setting\ISimple | null $objSettings = null ) : array
$arrRowData array The (native) row data from the MetaModel table.
$strOutputFormat string The desired output format.
$objSettings MetaModels\Render\Setting\ISimple | null Custom settings to be passed to the renderer.
return array An array with all the converted data.

searchFor() public method

The standard wildcards * (many characters) and ? (a single character) are supported.
public searchFor ( string $strPattern ) : string[] | null
$strPattern string The text to search for. This may contain wildcards.
return string[] | null The list of item ids of all items matching the condition or null if all match.

set() public method

All changes to an attribute via set() are considered to be non persistent and therefore will not update any structural information or auxiliary properties that might be needed within the attribute type. For persistent updates, use {@link IAttribute::handleMetaChange()} instead.
public set ( string $strKey, mixed $varValue ) : MetaModels\Attribute\IAttribute
$strKey string The meta information name that shall be set.
$varValue mixed The value to set.
return MetaModels\Attribute\IAttribute Instance of this attribute, for chaining support.

setDataFor() public method

This method is called to store the data for certain items to the database.
public setDataFor ( mixed[] $arrValues ) : void
$arrValues mixed[] The values to be stored into database. Mapping is item id=>value.
return void

sortIds() public method

Sorts the given array list by field value in the given direction.
public sortIds ( string[] $idList, string $strDirection ) : string[]
$idList string[] A list of Ids from the MetaModel table.
$strDirection string The direction for sorting. either 'ASC' or 'DESC', as in plain SQL.
return string[] The sorted array.

valueToWidget() public method

This is used for transferring a native attribute value to a value that the widget, generated from the information obtained via {@link IAttribute::getFieldDefinition()} can handle.
public valueToWidget ( mixed $varValue ) : mixed
$varValue mixed The value to be transformed.
return mixed The resulting widget compatible value

widgetToValue() public method

This is used for transferring a value that has been retrieved from a widget into native attribute value.
public widgetToValue ( mixed $varValue, string $itemId ) : mixed
$varValue mixed The value to be transformed.
$itemId string The id of the item the value belongs to.
return mixed The resulting native value