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
{@inheritDoc}
fetch(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig)
{@inheritDoc}
fetchAll(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig)
{@inheritDoc}
fieldExists($strField)
Retrieve the current active version for a row.
getActiveVersion(mixed $mixID) : mixed
Parameters
$mixID
mixed
The ID of the row.
Returns
mixed
The current version number of the requested row.
{@inheritDoc}
getCount(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig)
{@inheritDoc}
getEmptyCollection()
{@inheritDoc}
getEmptyConfig()
{@inheritDoc}
getEmptyFilterOptionCollection()
{@inheritDoc}
getEmptyModel()
{@inheritDoc}
getFilterOptions(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig)
Parameters
$objConfig
Exceptions
Get the property name that shall get updated with the current time stamp when saving to the database.
getTimeStampProperty() : string | null
{@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)
Check if two models have the same values in all properties.
sameModels(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel1, \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel2) : boolean
Parameters
Returns
boolean
True - If both models are same, false if not.
{@inheritDoc}
save(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objItem)
{@inheritDoc}
saveEach(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $objItems)
Save a new version of a row.
saveVersion(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel, string $strUsername) : void
Parameters
$strUsername
string
The username to attach to the version as creator.
{@inheritDoc}
setBaseConfig(array $arrConfig)
Parameters
$arrConfig
Exceptions
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
Returns
string
Build the WHERE conditions via calculateSubfilter().
buildFilterQuery(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig, array $arrParams) : string
Parameters
$arrParams
array
The query parameters will get stored into this array.
Returns
string
The combined WHERE conditions.
Build the order by part of a query.
buildSortingQuery(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) : string
Parameters
Returns
string
Build the WHERE clause for a configuration.
buildWhereQuery(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig, array $arrParams) : string
Parameters
$arrParams
array
The query parameters will get stored into this array.
Returns
string
The 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
Returns
string
The 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
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
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
Properties
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