ModelUtil
in package
Table of Contents
Properties
- $dcaUtil : DcaUtil
- $formUtil : FormUtil
- $framework : ContaoFrameworkInterface
- $kernelBundles : array<string|int, mixed>
- $requestStack : RequestStack
- $session : SessionInterface
Methods
- __construct() : mixed
- addPublishedCheckToModelArrays() : mixed
- callModelMethod() : mixed
- computeStringPattern() : mixed
- findAllModelInstances() : Collection|null
- Find all model instances for a given table.
- findModelInstanceByIdOrAlias() : mixed
- Returns multiple model instances by given table and id or alias.
- findModelInstanceByPk() : mixed
- Returns a model instance if for a given table and id(primary key).
- findModelInstancesBy() : array<string|int, Model>|Collection|null
- Returns model instances by given table and search criteria.
- findModulePages() : array<string|int, mixed>|Collection|PageModel|array<string|int, PageModel>|null
- Find module pages.
- findMultipleModelInstancesByIds() : mixed
- Returns multiple model instances by given table and ids.
- findOneModelInstanceBy() : mixed
- Return a single model instance by table and search criteria.
- findParentsRecursively() : array<string|int, mixed>
- Returns an array of a model instance's parents in ascending order, i.e. the root parent comes first.
- findRootParentRecursively() : Model
- Recursively finds the root parent.
- fixTablePrefixForDcMultilingual() : array<string|int, mixed>|mixed
- Fixes existing table prefixed already aliased in MultilingualQueryBuilder::buildQueryBuilderForFind().
- getCurrentDcMultilingualLanguage() : bool|mixed
- Get the current dc_multilingual language even DC_Multilingual::edit() didn't run.
- getDcMultilingualRootPageLanguages() : array<string|int, mixed>
- Get the list of languages based on root pages.
- getDcMultilingualTranslatableLanguages() : mixed
- getDcMultilingualTranslationRecord() : mixed
- getModelInstanceFieldValue() : mixed|null
- Get model instance value for given field.
- getModelInstanceIfId() : Model|mixed
- hasValueChanged() : bool
- Determine if given value is newer than DataContainer value.
- setDefaultsFromDca() : Model
- Set the entity defaults from dca config (for new model entry).
Properties
$dcaUtil
protected
DcaUtil
$dcaUtil
$formUtil
protected
FormUtil
$formUtil
$framework
protected
ContaoFrameworkInterface
$framework
$kernelBundles
protected
array<string|int, mixed>
$kernelBundles
$requestStack
protected
RequestStack
$requestStack
$session
protected
SessionInterface
$session
Methods
__construct()
public
__construct(DcaUtil $dcaUtil, ContaoFrameworkInterface $contaoFramework, SessionInterface $session, RequestStack $requestStack, FormUtil $formUtil, array<string|int, mixed> $kernelBundles) : mixed
Parameters
addPublishedCheckToModelArrays()
public
addPublishedCheckToModelArrays(string $table, string $publishedField, string $startField, string $stopField, array<string|int, mixed> &$columns[, array<string|int, mixed> $options = [] ]) : mixed
Use Utils service instead
Parameters
- $table : string
- $publishedField : string
- $startField : string
- $stopField : string
- $columns : array<string|int, mixed>
- $options : array<string|int, mixed> = []
Tags
callModelMethod()
public
callModelMethod(string $table, string $method, mixed ...$args) : mixed
Parameters
- $table : string
- $method : string
- $args : mixed
computeStringPattern()
public
computeStringPattern(string $pattern, Model|object $instance, string $table[, array<string|int, mixed> $specialValueConfig = [] ]) : mixed
Parameters
- $pattern : string
- $instance : Model|object
- $table : string
- $specialValueConfig : array<string|int, mixed> = []
findAllModelInstances()
Find all model instances for a given table.
public
findAllModelInstances(string $table[, array<string|int, mixed> $arrOptions = [] ]) : Collection|null
Parameters
- $table : string
-
The table name
- $arrOptions : array<string|int, mixed> = []
-
Additional query options
Return values
Collection|nullfindModelInstanceByIdOrAlias()
Returns multiple model instances by given table and id or alias.
public
findModelInstanceByIdOrAlias(string $table, mixed $idOrAlias[, array<string|int, mixed> $options = [] ]) : mixed
Use Utils service instead
Parameters
- $table : string
- $idOrAlias : mixed
- $options : array<string|int, mixed> = []
Tags
findModelInstanceByPk()
Returns a model instance if for a given table and id(primary key).
public
findModelInstanceByPk(string $table, mixed $pk[, array<string|int, mixed> $options = [] ]) : mixed
Use Utils service instead
Return null, if model type or model instance with given id not exist.
Parameters
- $table : string
- $pk : mixed
- $options : array<string|int, mixed> = []
Tags
findModelInstancesBy()
Returns model instances by given table and search criteria.
public
findModelInstancesBy(string $table, mixed $columns, mixed $values[, array<string|int, mixed> $options = [] ]) : array<string|int, Model>|Collection|null
Use Utils service instead
Parameters
- $table : string
- $columns : mixed
- $values : mixed
- $options : array<string|int, mixed> = []
Tags
Return values
array<string|int, Model>|Collection|nullfindModulePages()
Find module pages.
public
findModulePages(ModuleModel $module[, bool $collection = false ][, bool $useCache = true ]) : array<string|int, mixed>|Collection|PageModel|array<string|int, PageModel>|null
Returns page ids or models, where a frontend module is integrated
Also search within blocks (heimrichhannot/contao-blocks)
Parameters
- $module : ModuleModel
- $collection : bool = false
-
Return PageModel Collection if true. Default: false
- $useCache : bool = true
-
If true, a filesystem cache will be used to save pages ids. Default: true
Return values
array<string|int, mixed>|Collection|PageModel|array<string|int, PageModel>|null —An array of page Ids (can be empty if no page found!), a PageModel collection or null
findMultipleModelInstancesByIds()
Returns multiple model instances by given table and ids.
public
findMultipleModelInstancesByIds(string $table, array<string|int, mixed> $ids[, array<string|int, mixed> $options = [] ]) : mixed
Use Utils service instead
Parameters
- $table : string
- $ids : array<string|int, mixed>
- $options : array<string|int, mixed> = []
Tags
findOneModelInstanceBy()
Return a single model instance by table and search criteria.
public
findOneModelInstanceBy(string $table, array<string|int, mixed> $columns, array<string|int, mixed> $values[, array<string|int, mixed> $options = [] ]) : mixed
Use Utils service instead
Parameters
- $table : string
- $columns : array<string|int, mixed>
- $values : array<string|int, mixed>
- $options : array<string|int, mixed> = []
Tags
findParentsRecursively()
Returns an array of a model instance's parents in ascending order, i.e. the root parent comes first.
public
findParentsRecursively(string $parentProperty, string $table, Model $instance) : array<string|int, mixed>
Use Utils service instead
Parameters
- $parentProperty : string
- $table : string
- $instance : Model
Return values
array<string|int, mixed>findRootParentRecursively()
Recursively finds the root parent.
public
findRootParentRecursively(string $parentProperty, string $table, Model $instance[, bool $returnInstanceIfNoParent = true ]) : Model
Parameters
- $parentProperty : string
- $table : string
- $instance : Model
- $returnInstanceIfNoParent : bool = true
Return values
ModelfixTablePrefixForDcMultilingual()
Fixes existing table prefixed already aliased in MultilingualQueryBuilder::buildQueryBuilderForFind().
public
fixTablePrefixForDcMultilingual(string $table, mixed &$columns[, array<string|int, mixed> &$options = [] ]) : array<string|int, mixed>|mixed
Parameters
- $table : string
- $columns : mixed
- $options : array<string|int, mixed> = []
Return values
array<string|int, mixed>|mixedgetCurrentDcMultilingualLanguage()
Get the current dc_multilingual language even DC_Multilingual::edit() didn't run.
public
getCurrentDcMultilingualLanguage(string $table, int $id) : bool|mixed
This can be used in onload_callbacks for example since here DC_Multilingual::edit() didn't run, yet.
Parameters
- $table : string
- $id : int
Return values
bool|mixedgetDcMultilingualRootPageLanguages()
Get the list of languages based on root pages.
public
getDcMultilingualRootPageLanguages() : array<string|int, mixed>
Return values
array<string|int, mixed>getDcMultilingualTranslatableLanguages()
public
getDcMultilingualTranslatableLanguages(string $table) : mixed
Parameters
- $table : string
getDcMultilingualTranslationRecord()
public
getDcMultilingualTranslationRecord(mixed $table, mixed $id[, mixed $language = null ]) : mixed
Parameters
- $table : mixed
- $id : mixed
- $language : mixed = null
getModelInstanceFieldValue()
Get model instance value for given field.
public
getModelInstanceFieldValue(string $field, string $table, int $id) : mixed|null
Parameters
- $field : string
- $table : string
- $id : int
Return values
mixed|nullgetModelInstanceIfId()
public
getModelInstanceIfId(mixed $instance, mixed $table) : Model|mixed
Parameters
- $instance : mixed
- $table : mixed
Return values
Model|mixedhasValueChanged()
Determine if given value is newer than DataContainer value.
public
hasValueChanged(mixed $newValue, DataContainer $dc) : bool
Parameters
- $newValue : mixed
- $dc : DataContainer
Return values
boolsetDefaultsFromDca()
Set the entity defaults from dca config (for new model entry).
public
setDefaultsFromDca(Model $objModel) : Model
Use DcaUtil::setDefaultsFromDca instead
Parameters
- $objModel : Model
Tags
Return values
Model —The modified model, containing the default values from all dca fields