Class DefaultDataProvider.

Default implementation for a data provider using the Contao default database as backend.
SuppressWarnings (PHPMD.ExcessiveClassComplexity) - There is no way to reduce this class more without reducing the interface.

 Methods

Create a new instance of the data provider.

__construct() 

{@inheritDoc}

delete($item) 

Parameters

$item

Exceptions

\ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralRuntimeException When an unusable object has been passed.

Create an instance of the default database driven uuid generator.

enableDefaultUuidGenerator() : \ContaoCommunityAlliance\DcGeneral\Data\DefaultDataProvider

Exceptions

\RuntimeException When already an id generator has been set on the instance.

Returns

{@inheritDoc}

fetch(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) 

Parameters

$objConfig

{@inheritDoc}

fetchAll(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) 

Parameters

$objConfig

{@inheritDoc}

fieldExists($strField) 

Parameters

$strField

Retrieve the current active version for a row.

getActiveVersion(mixed $mixID) : mixed

Parameters

$mixID

mixed

The ID of the row.

Returns

mixedThe current version number of the requested row.

{@inheritDoc}

getCount(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) 

Parameters

$objConfig

{@inheritDoc}

getEmptyCollection() 

{@inheritDoc}

getEmptyConfig() 

{@inheritDoc}

getEmptyFilterOptionCollection() 

{@inheritDoc}

getEmptyModel() 

{@inheritDoc}

getFilterOptions(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) 

Parameters

$objConfig

Exceptions

\ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralRuntimeException if improper values have been passed (i.e. not exactly one field requested).

Get the property name that shall get updated with the current time stamp when saving to the database.

getTimeStampProperty() : string | null

Returns

stringnull

{@inheritDoc}

getVersion($mixID, $mixVersion) 

Parameters

$mixID

$mixVersion

Return a list with all versions for the row with the given Id.

getVersions(mixed $mixID, boolean $blnOnlyActive) : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

Parameters

$mixID

mixed

The ID of the row.

$blnOnlyActive

boolean

If true, only active versions will get returned, if false all version will get returned.

Returns

{@inheritDoc}

isUniqueValue($strField, $varNew, $intId) 

Parameters

$strField

$varNew

$intId

{@inheritDoc}

resetFallback($strField) 

Parameters

$strField

Check if two models have the same values in all properties.

sameModels(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel1, \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel2) : boolean

Parameters

$objModel1

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The first model to compare.

$objModel2

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The second model to compare.

Returns

booleanTrue - If both models are same, false if not.

{@inheritDoc}

save(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objItem) 

Parameters

$objItem

{@inheritDoc}

saveEach(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $objItems) 

Parameters

$objItems

Save a new version of a row.

saveVersion(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel, string $strUsername) : void

Parameters

$objModel

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The model for which a new version shall be created.

$strUsername

string

The username to attach to the version as creator.

{@inheritDoc}

setBaseConfig(array $arrConfig) 

Parameters

$arrConfig

Exceptions

\ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralRuntimeException When no source has been defined.

Set the id generator to use.

setIdGenerator(\ContaoCommunityAlliance\DcGeneral\Data\IdGeneratorInterface $idGenerator) : \ContaoCommunityAlliance\DcGeneral\Data\DefaultDataProvider

Set the property name that shall get updated with the current time stamp when saving to the database.

setTimeStampProperty(boolean $timeStampField) : \ContaoCommunityAlliance\DcGeneral\Data\DefaultDataProvider

Parameters

$timeStampField

boolean

The property name or empty to clear.

Returns

Set a version as active.

setVersionActive(mixed $mixID, mixed $mixVersion) : void

Parameters

$mixID

mixed

The ID of the row.

$mixVersion

mixed

The version number to set active.

Build the field list.

buildFieldQuery(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) : string
Returns all values from $objConfig->getFields() as comma separated list.

Parameters

$objConfig

\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface

The configuration to use.

Returns

string

Build the WHERE conditions via calculateSubfilter().

buildFilterQuery(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig, array $arrParams) : string

Parameters

$objConfig

\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface

The configuration to use.

$arrParams

array

The query parameters will get stored into this array.

Returns

stringThe combined WHERE conditions.

Build the order by part of a query.

buildSortingQuery(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) : string

Parameters

$objConfig

\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface

The configuration to use.

Returns

string

Build the WHERE clause for a configuration.

buildWhereQuery(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig, array $arrParams) : string

Parameters

$objConfig

\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface

The configuration to use.

$arrParams

array

The query parameters will get stored into this array.

Returns

stringThe combined WHERE clause (including the word "WHERE").

Combine a filter in standard filter array notation.

calculateSubfilter(array $arrFilter, array $arrParams) : string
Supported operations are: operation needed arguments argument type. AND 'children' array OR 'children' array = 'property' string (the name of a property) 'value' literal > 'property' string (the name of a property) 'value' literal < 'property' string (the name of a property) 'value' literal IN 'property' string (the name of a property) 'values' array of literal LIKE 'property' string (the name of a property) 'value' literal - Wildcards * (Many) ? (One)

Parameters

$arrFilter

array

The filter to be combined to a valid SQL filter query.

$arrParams

array

The query parameters will get stored into this array.

Exceptions

\ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralRuntimeException If an invalid filter entry is encountered.

Returns

stringThe combined WHERE conditions.

Convert a model into a property array to be used in insert and update queries.

convertModelToDataPropertyArray(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $model) : array

Parameters

$model

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The model to convert into an property array.

Returns

array

Create a model from a database result.

createModelFromDatabaseResult(\Database\Result $dbResult) : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

Parameters

$dbResult

\Database\Result

The database result to create a model from.

Returns

Build an AND or OR query.

getAndOrFilter(array $operation, array $params) : string

Parameters

$operation

array

The operation to convert.

$params

array

The parameter array for the resulting query.

Returns

string

Build the sub query for a comparing operator like =,<,>.

getFilterForComparingOperator(array $operation, array $params) : string

Parameters

$operation

array

The operation to apply.

$params

array

The parameters of the entire query.

Returns

string

Return the filter query for a "foo IN ('a', 'b')" filter.

getFilterForInList(array $operation, array $params) : string

Parameters

$operation

array

The operation to apply.

$params

array

The parameters of the entire query.

Returns

string

Return the filter query for a "foo LIKE '%ba_r%'" filter.

getFilterForLike(array $operation, array $params) : string
The searched value may contain the wildcards '*' and '?' which will get converted to proper SQL.

Parameters

$operation

array

The operation to apply.

$params

array

The parameters of the entire query.

Returns

string

Insert the model into the database.

insertModelIntoDatabase(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $model) : void

Parameters

$model

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The model to insert into the database.

Store an undo entry in the table tl_undo.

insertUndo(string $strSourceSQL, string $strSaveSQL, string $strTable) : void
Currently this only supports delete queries.

Parameters

$strSourceSQL

string

The SQL used to perform the action to be undone.

$strSaveSQL

string

The SQL query to retrieve the current entries.

$strTable

string

The table to be affected by the action.

Update the model in the database.

updateModelInDatabase(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $model) : void

Parameters

$model

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The model to update the database.

 Properties

 

The id generator to use (if any).

$idGenerator : \ContaoCommunityAlliance\DcGeneral\Data\IdGeneratorInterface
 

The Database instance.

$objDatabase : \Database
 

Name of current source.

$strSource : string
 

The property that shall get populated with the current timestamp when saving data.

$timeStampProperty : string