PHP Класс MetaModels\MetaModel

См. также: MetaModelFactory::byId() to instantiate a MetaModel by its ID.
См. также: MetaModelFactory::byTableName() to instantiate a MetaModel by its table name. This class handles all attribute definition instantiation and can be queried for a view instance to certain entries.
Наследование: implements metamodels\IMetaModel
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$arrAttributes array Association is $colName => object
$arrData array This is the data from tl_metamodel.
$serviceContainer metamodels\IMetaModelsServiceContainer The service container.

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

Метод Описание
__construct ( array $arrData ) Instantiate a MetaModel.
addAttribute ( MetaModels\Attribute\IAttribute $objAttribute )
delete ( metamodels\IItem $objItem )
findByFilter ( $objFilter, $strSortBy = '', $intOffset, $intLimit, $strSortOrder = 'ASC', $arrAttrOnly = [] )
findById ( $intId, $arrAttrOnly = [] )
findVariantBase ( $objFilter )
findVariants ( $arrIds, $objFilter )
findVariantsWithBase ( $arrIds, $objFilter )
get ( $strKey )
getActiveLanguage ( )
getAttribute ( $strAttributeName )
getAttributeById ( $intId )
getAttributeOptions ( $strAttribute, $objFilter = null )
getAttributes ( )
getAvailableLanguages ( )
getCount ( $objFilter )
getEmptyFilter ( )
getFallbackLanguage ( )
getIdsFromFilter ( $objFilter, $strSortBy = '', $intOffset, $intLimit, $strSortOrder = 'ASC' )
getInVariantAttributes ( )
getName ( )
getServiceContainer ( )
getTableName ( )
getView ( $intViewId )
hasAttribute ( $strAttributeName )
hasVariants ( )
isTranslated ( )
prepareFilter ( $intFilterSettings, $arrFilterUrl )
saveItem ( $objItem )
setServiceContainer ( metamodels\IMetaModelsServiceContainer $serviceContainer ) : MetaModel Set the service container.

Защищенные методы

Метод Описание
buildDatabaseParameterList ( array $parameters ) : string Build a list of the correct amount of "?" for use in a db query.
convertRowsToResult ( Database\Result $objRow, string[] $arrAttrOnly = [] ) : array Convert a database result to a result array.
copyFilter ( MetaModels\Filter\IFilter | null $objFilter ) : MetaModels\Filter\IFilter Clone the given filter or create an empty one if no filter has been passed.
createNewItem ( metamodels\IItem $item ) : void Create a new item in the database.
fetchAdditionalAttributes ( string[] $ids, array $result, string[] $attrOnly = [] ) : array This method is called to retrieve the data for certain items from the database.
fetchRows ( string[] $arrIds, string[] $arrAttrOnly = [] ) : array Fetch the "native" database rows with the given ids.
fetchTranslatedAttributeValues ( MetaModels\Attribute\ITranslated $attribute, string[] $ids ) : array This method is called to retrieve the data for certain items from the database.
getAttributeByNames ( string[] $attrNames = [] ) : MetaModels\Attribute\IAttribute[] Retrieve all attributes with the given names.
getAttributeImplementing ( string $interface ) : array Retrieve all attributes implementing the given interface.
getComplexAttributes ( ) : MetaModels\Attribute\IComplex[] This method retrieves all complex attributes from the current MetaModel.
getDatabase ( ) : Database Retrieve the database instance to use.
getItemsWithId ( int[] $arrIds, string[] $arrAttrOnly = [] ) : MetaModels\IItems This method is called to retrieve the data for certain items from the database.
getMatchingIds ( MetaModels\Filter\IFilter | null $objFilter ) : array Narrow down the list of Ids that match the given filter.
getSimpleAttributes ( ) : MetaModels\Attribute\ISimple[] This method retrieves all simple attributes from the current MetaModel.
getTranslatedAttributes ( ) : MetaModels\Attribute\ITranslated[] This method retrieves all translated attributes from the current MetaModel.
isComplexAttribute ( MetaModels\Attribute\IAttribute $objAttribute ) : boolean Determine if the given attribute is a complex one.
isSimpleAttribute ( MetaModels\Attribute\IAttribute $objAttribute ) : boolean Determine if the given attribute is a simple one.
isTranslatedAttribute ( MetaModels\Attribute\IAttribute $objAttribute ) : boolean Determine if the given attribute is a translated one.
saveAttribute ( MetaModels\Attribute\IAttribute $objAttribute, array $arrIds, mixed $varData, string $strLangCode ) : void Update an attribute for the given ids with the given data.
saveSimpleColumn ( string $strColumn, array $arrIds, mixed $varData ) : void Update the value of a native column for the given ids with the given data.
tryUnserialize ( string $value ) : mixed Try to unserialize a value.
updateVariants ( metamodels\IItem $item, string $activeLanguage, int[] $allIds, boolean $baseAttributes = false ) : void Update the variants with the value if needed.

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

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

Instantiate a MetaModel.
public __construct ( array $arrData )
$arrData array The information array, for information on the available columns, refer to documentation of table tl_metamodel.

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

public addAttribute ( MetaModels\Attribute\IAttribute $objAttribute )
$objAttribute MetaModels\Attribute\IAttribute

buildDatabaseParameterList() защищенный Метод

Build a list of the correct amount of "?" for use in a db query.
protected buildDatabaseParameterList ( array $parameters ) : string
$parameters array The parameters.
Результат string

convertRowsToResult() защищенный Метод

Convert a database result to a result array.
protected convertRowsToResult ( Database\Result $objRow, string[] $arrAttrOnly = [] ) : array
$objRow Database\Result The database result.
$arrAttrOnly string[] The list of attributes to return, if any.
Результат array

copyFilter() защищенный Метод

Clone the given filter or create an empty one if no filter has been passed.
protected copyFilter ( MetaModels\Filter\IFilter | null $objFilter ) : MetaModels\Filter\IFilter
$objFilter MetaModels\Filter\IFilter | null The filter to clone.
Результат MetaModels\Filter\IFilter the cloned filter.

createNewItem() защищенный Метод

Create a new item in the database.
protected createNewItem ( metamodels\IItem $item ) : void
$item metamodels\IItem The item to be created.
Результат void

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

public delete ( metamodels\IItem $objItem )
$objItem metamodels\IItem

fetchAdditionalAttributes() защищенный Метод

This method is called to retrieve the data for certain items from the database.
protected fetchAdditionalAttributes ( string[] $ids, array $result, string[] $attrOnly = [] ) : array
$ids string[] The ids of the items to retrieve the order of ids is used for sorting of the return values.
$result array The current values.
$attrOnly string[] Names of the attributes that shall be contained in the result, defaults to array() which means all attributes.
Результат array an array of all matched items, sorted by the id list.

fetchRows() защищенный Метод

Fetch the "native" database rows with the given ids.
protected fetchRows ( string[] $arrIds, string[] $arrAttrOnly = [] ) : array
$arrIds string[] The ids of the items to retrieve the order of ids is used for sorting of the return values.
$arrAttrOnly string[] Names of the attributes that shall be contained in the result, defaults to array() which means all attributes.
Результат array an array containing the database rows with each column "deserialized".

fetchTranslatedAttributeValues() защищенный Метод

This method is called to retrieve the data for certain items from the database.
protected fetchTranslatedAttributeValues ( MetaModels\Attribute\ITranslated $attribute, string[] $ids ) : array
$attribute MetaModels\Attribute\ITranslated The attribute to fetch the values for.
$ids string[] The ids of the items to retrieve the order of ids is used for sorting of the return values.
Результат array an array of all matched items, sorted by the id list.

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

public findByFilter ( $objFilter, $strSortBy = '', $intOffset, $intLimit, $strSortOrder = 'ASC', $arrAttrOnly = [] )

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

public findById ( $intId, $arrAttrOnly = [] )

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

public findVariantBase ( $objFilter )

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

public findVariants ( $arrIds, $objFilter )

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

public findVariantsWithBase ( $arrIds, $objFilter )

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

public get ( $strKey )

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

The value is taken from $GLOBALS['TL_LANGUAGE']
public getActiveLanguage ( )

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

public getAttribute ( $strAttributeName )

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

public getAttributeById ( $intId )

getAttributeByNames() защищенный Метод

Retrieve all attributes with the given names.
protected getAttributeByNames ( string[] $attrNames = [] ) : MetaModels\Attribute\IAttribute[]
$attrNames string[] The attribute names, if empty all attributes will be returned.
Результат MetaModels\Attribute\IAttribute[]

getAttributeImplementing() защищенный Метод

Retrieve all attributes implementing the given interface.
protected getAttributeImplementing ( string $interface ) : array
$interface string The interface name.
Результат array

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

public getAttributeOptions ( $strAttribute, $objFilter = null )

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

public getAttributes ( )

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

getComplexAttributes() защищенный Метод

This method retrieves all complex attributes from the current MetaModel.
protected getComplexAttributes ( ) : MetaModels\Attribute\IComplex[]
Результат MetaModels\Attribute\IComplex[] all complex attributes defined for this instance.

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

public getCount ( $objFilter )

getDatabase() защищенный Метод

Retrieve the database instance to use.
protected getDatabase ( ) : Database
Результат Contao\Database

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

public getEmptyFilter ( )

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

public getFallbackLanguage ( )

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

public getIdsFromFilter ( $objFilter, $strSortBy = '', $intOffset, $intLimit, $strSortOrder = 'ASC' )

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

getItemsWithId() защищенный Метод

This method is called to retrieve the data for certain items from the database.
protected getItemsWithId ( int[] $arrIds, string[] $arrAttrOnly = [] ) : MetaModels\IItems
$arrIds int[] The ids of the items to retrieve the order of ids is used for sorting of the return values.
$arrAttrOnly string[] Names of the attributes that shall be contained in the result, defaults to array() which means all attributes.
Результат MetaModels\IItems a collection of all matched items, sorted by the id list.

getMatchingIds() защищенный Метод

Narrow down the list of Ids that match the given filter.
protected getMatchingIds ( MetaModels\Filter\IFilter | null $objFilter ) : array
$objFilter MetaModels\Filter\IFilter | null The filter to search the matching ids for.
Результат array all matching Ids.

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

public getName ( )

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

public getServiceContainer ( )

getSimpleAttributes() защищенный Метод

This method retrieves all simple attributes from the current MetaModel.
protected getSimpleAttributes ( ) : MetaModels\Attribute\ISimple[]
Результат MetaModels\Attribute\ISimple[] all simple attributes defined for this instance.

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

public getTableName ( )

getTranslatedAttributes() защищенный Метод

This method retrieves all translated attributes from the current MetaModel.
protected getTranslatedAttributes ( ) : MetaModels\Attribute\ITranslated[]
Результат MetaModels\Attribute\ITranslated[] all translated attributes defined for this instance.

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

public getView ( $intViewId )

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

public hasAttribute ( $strAttributeName )

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

public hasVariants ( )

isComplexAttribute() защищенный Метод

Determine if the given attribute is a complex one.
protected isComplexAttribute ( MetaModels\Attribute\IAttribute $objAttribute ) : boolean
$objAttribute MetaModels\Attribute\IAttribute The attribute to test.
Результат boolean true if it is complex, false otherwise.

isSimpleAttribute() защищенный Метод

Determine if the given attribute is a simple one.
protected isSimpleAttribute ( MetaModels\Attribute\IAttribute $objAttribute ) : boolean
$objAttribute MetaModels\Attribute\IAttribute The attribute to test.
Результат boolean true if it is simple, false otherwise.

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

public isTranslated ( )

isTranslatedAttribute() защищенный Метод

Determine if the given attribute is a translated one.
protected isTranslatedAttribute ( MetaModels\Attribute\IAttribute $objAttribute ) : boolean
$objAttribute MetaModels\Attribute\IAttribute The attribute to test.
Результат boolean true if it is translated, false otherwise.

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

public prepareFilter ( $intFilterSettings, $arrFilterUrl )

saveAttribute() защищенный Метод

Update an attribute for the given ids with the given data.
protected saveAttribute ( MetaModels\Attribute\IAttribute $objAttribute, array $arrIds, mixed $varData, string $strLangCode ) : void
$objAttribute MetaModels\Attribute\IAttribute The attribute to save.
$arrIds array The ids of the rows that shall be updated.
$varData mixed The data to save in raw data.
$strLangCode string The language code to save.
Результат void

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

public saveItem ( $objItem )

saveSimpleColumn() защищенный Метод

Update the value of a native column for the given ids with the given data.
protected saveSimpleColumn ( string $strColumn, array $arrIds, mixed $varData ) : void
$strColumn string The column name to update (i.e. tstamp).
$arrIds array The ids of the rows that shall be updated.
$varData mixed The data to save. If this is an array, it is automatically serialized.
Результат void

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

Set the service container.
public setServiceContainer ( metamodels\IMetaModelsServiceContainer $serviceContainer ) : MetaModel
$serviceContainer metamodels\IMetaModelsServiceContainer The service container.
Результат MetaModel

tryUnserialize() защищенный Метод

Try to unserialize a value.
protected tryUnserialize ( string $value ) : mixed
$value string The string to process.
Результат mixed

updateVariants() защищенный Метод

Update the variants with the value if needed.
protected updateVariants ( metamodels\IItem $item, string $activeLanguage, int[] $allIds, boolean $baseAttributes = false ) : void
$item metamodels\IItem The item to save.
$activeLanguage string The language the values are in.
$allIds int[] The ids of all variants.
$baseAttributes boolean If also the base attributes get updated as well.
Результат void

Описание свойств

$arrAttributes защищенное свойство

Association is $colName => object
protected array $arrAttributes
Результат array

$arrData защищенное свойство

This is the data from tl_metamodel.
protected array $arrData
Результат array

$serviceContainer защищенное свойство

The service container.
protected IMetaModelsServiceContainer,metamodels $serviceContainer
Результат metamodels\IMetaModelsServiceContainer