PHP Интерфейс MetaModels\Attribute\IAttribute

To create Attribute instances, use a {@link Factory} This interface handles all general purpose attribute management and interfacing.
Показать файл Открыть проект Примеры использования интерфейса

Открытые методы

Метод Описание
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.

Описание методов

destroyAUX() публичный Метод

Delete all auxiliary data like a column in the MetaModel table or references in another table etc.
public destroyAUX ( ) : void
Результат void

filterGreaterThan() публичный Метод

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.
Результат string[] | null The list of item ids of all items matching the condition or null if all match.

filterLessThan() публичный Метод

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.
Результат string[] | null The list of item ids of all items matching the condition or null if all match.

filterNotEqual() публичный Метод

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

get() публичный Метод

Retrieve a meta information setting.
public get ( string $strKey ) : mixed
$strKey string The meta information name that shall be retrieved.
Результат mixed

getAttributeSettingNames() публичный Метод

Returns all valid settings for the attribute type.
public getAttributeSettingNames ( ) : string[]
Результат string[] All valid setting names, this re-ensembles the columns in tl_metamodel_attribute this attribute class understands.

getColName() публичный Метод

Queries the attribute for it's column name within it's MetaModel.
public getColName ( ) : string
Результат string the attributes column name.

getDefaultRenderSettings() публичный Метод

Retrieve an instance containing the default render settings for an attribute of this type.
public getDefaultRenderSettings ( ) : MetaModels\Render\Setting\Simple
Результат MetaModels\Render\Setting\Simple

getFieldDefinition() публичный Метод

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().
Результат array The DCA array to use as $GLOBALS['TL_DCA']['tablename']['fields']['attribute-name]

getFilterOptions() публичный Метод

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.
Результат array All options matching the given conditions as name => value.

getFilterUrlValue() публичный Метод

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.
Результат string

getItemDCA() публичный Метод

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.
Устаревший: Use DataDefinition builders in DC_General 2.0.0
public getItemDCA ( array $arrOverrides = [] ) : array
$arrOverrides array See documentation in getFieldDefinition() method.
Результат array The DCA array to use as $GLOBALS['tablename']

getMetaModel() публичный Метод

Queries the attribute for it's parent MetaModel instance.
public getMetaModel ( ) : MetaModels\IMetaModel
Результат MetaModels\IMetaModel the MetaModel instance.

getName() публичный Метод

If the MetaModel is translated, the currently active language is used, with properly falling back to the defined fallback language.
public getName ( ) : string
Результат string the human readable name

handleMetaChange() публичный Метод

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.
Результат MetaModels\Attribute\IAttribute The instance of this attribute, to support chaining.

initializeAUX() публичный Метод

Create auxiliary data like a column in the MetaModel table or references in another table etc.
public initializeAUX ( ) : void
Результат void

modelSaved() публичный Метод

Useful for alias fields, edit counters etc.
public modelSaved ( MetaModels\IItem $objItem ) : void
$objItem MetaModels\IItem The item that has just been saved.
Результат void

parseValue() публичный Метод

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.
Результат array An array with all the converted data.

searchFor() публичный Метод

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.
Результат string[] | null The list of item ids of all items matching the condition or null if all match.

set() публичный Метод

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.
Результат MetaModels\Attribute\IAttribute Instance of this attribute, for chaining support.

setDataFor() публичный Метод

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.
Результат void

sortIds() публичный Метод

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.
Результат string[] The sorted array.

valueToWidget() публичный Метод

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.
Результат mixed The resulting widget compatible value

widgetToValue() публичный Метод

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.
Результат mixed The resulting native value