PHP Interface MetaModels\Attribute\IAttribute

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

Méthodes publiques

Méthode 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 méthode

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

filterGreaterThan() public méthode

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.
Résultat string[] | null The list of item ids of all items matching the condition or null if all match.

filterLessThan() public méthode

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.
Résultat string[] | null The list of item ids of all items matching the condition or null if all match.

filterNotEqual() public méthode

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

get() public méthode

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

getAttributeSettingNames() public méthode

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

getColName() public méthode

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

getDefaultRenderSettings() public méthode

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

getFieldDefinition() public méthode

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().
Résultat array The DCA array to use as $GLOBALS['TL_DCA']['tablename']['fields']['attribute-name]

getFilterOptions() public méthode

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.
Résultat array All options matching the given conditions as name => value.

getFilterUrlValue() public méthode

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.
Résultat string

getItemDCA() public méthode

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.
Résultat array The DCA array to use as $GLOBALS['tablename']

getMetaModel() public méthode

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

getName() public méthode

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

handleMetaChange() public méthode

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.
Résultat MetaModels\Attribute\IAttribute The instance of this attribute, to support chaining.

initializeAUX() public méthode

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

modelSaved() public méthode

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

parseValue() public méthode

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.
Résultat array An array with all the converted data.

searchFor() public méthode

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.
Résultat string[] | null The list of item ids of all items matching the condition or null if all match.

set() public méthode

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.
Résultat MetaModels\Attribute\IAttribute Instance of this attribute, for chaining support.

setDataFor() public méthode

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.
Résultat void

sortIds() public méthode

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.
Résultat string[] The sorted array.

valueToWidget() public méthode

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.
Résultat mixed The resulting widget compatible value

widgetToValue() public méthode

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.
Résultat mixed The resulting native value