Contao Utils Bundle

ModelUtil
in package

Table of Contents

Properties

$framework  : ContaoFrameworkInterface

Methods

__construct()  : mixed
addPublishedCheckToModelArrays()  : mixed
Adds an published check to your model query.
findModelInstanceByIdOrAlias()  : Model|null
Returns multiple model instances by given table and id or alias.
findModelInstanceByPk()  : Model|null
Find a single model instance for given table by its primary key (id).
findModelInstancesBy()  : array<string|int, Model>|Collection|null
Returns model instances by given table and search criteria.
findMultipleModelInstancesByIds()  : Collection|array<string|int, Model>|Model|null
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, T>
Returns an array of a model instance's parents in ascending order, i.e. the root parent comes first.

Properties

$framework

protected ContaoFrameworkInterface $framework

Methods

__construct()

public __construct(ContaoFramework $contaoFramework) : mixed
Parameters
$contaoFramework : ContaoFramework

addPublishedCheckToModelArrays()

Adds an published check to your model query.

public addPublishedCheckToModelArrays(string $table, array<string|int, mixed> &$columns[, array<string|int, mixed> $options = [] ]) : mixed

Options:

  • publishedField: (string) The name of the published field. Default: "published"
  • startField: (string) The name of the start field. Default: "start"
  • stopField: (string) The name of the stop field. Default: "stop"
  • invertPublishedField: (bool) Set to true, if the published field should be evaluated inverted (for "hidden" or "invisible" fields. Default: false
  • invertStartStopFields: (bool) Set to true, if the start and stop fields should be evaluated in an inverted manner. Default: false
  • ignoreFePreview: (bool) Set to true, frontend preview should be ignored. Default: false
Parameters
$table : string

The table name

$columns : array<string|int, mixed>

The columns array

$options : array<string|int, mixed> = []

pass additional options

findModelInstanceByIdOrAlias()

Returns multiple model instances by given table and id or alias.

public findModelInstanceByIdOrAlias(string $table, mixed $idOrAlias[, array<string|int, mixed> $options = [] ]) : Model|null
Parameters
$table : string
$idOrAlias : mixed
$options : array<string|int, mixed> = []
Return values
Model|null

findModelInstanceByPk()

Find a single model instance for given table by its primary key (id).

public findModelInstanceByPk(string $table, mixed $pk[, array<string|int, mixed> $options = [] ]) : Model|null
Parameters
$table : string

The table

$pk : mixed

The property value

$options : array<string|int, mixed> = []

An optional options array

Return values
Model|null

The model or null if the result is empty

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

Options:

  • skipReplaceInsertTags: (bool) Skip the replacement of inserttags. Default: false
Parameters
$table : string
$columns : mixed
$values : mixed
$options : array<string|int, mixed> = []
Return values
array<string|int, Model>|Collection|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 = [] ]) : Collection|array<string|int, Model>|Model|null
Parameters
$table : string
$ids : array<string|int, mixed>
$options : array<string|int, mixed> = []
Return values
Collection|array<string|int, Model>|Model|null

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

Options:

  • skipReplaceInsertTags: (bool) Skip the replacement of inserttags. Default: false
Parameters
$table : string
$columns : array<string|int, mixed>
$values : array<string|int, mixed>
$options : array<string|int, mixed> = []

findParentsRecursively()

Returns an array of a model instance's parents in ascending order, i.e. the root parent comes first.

public findParentsRecursively(T $instance[, string $parentProperty = 'pid' ]) : array<string|int, T>
Parameters
$instance : T
$parentProperty : string = 'pid'
Tags
template

T of Model

Return values
array<string|int, T>

        
On this page

Search results