Interface DataProviderInterface.

This interface describes a data provider in DcGeneral.

 Methods

Delete an item.

delete(mixed $item) : void
The given value may be either integer, string or an instance of Model

Parameters

$item

mixed

Id or the model itself, to delete.

Exceptions

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

Fetch a single or first record by id or filter.

fetch(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface
If the model shall be retrieved by id, use $objConfig->setId() to populate the config with an Id. If the model shall be retrieved by filter, use $objConfig->setFilter() to populate the config with a filter.

Parameters

$objConfig

\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface

The configuration to use.

Returns

Fetch all records (optional filtered, sorted and limited).

fetchAll(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface | \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface[] | string[]
This returns a collection of all models matching the config object. If idOnly is true, an array containing all matching ids is returned.

Parameters

$objConfig

\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface

The configuration to use.

Returns

Check if a property with the given name exists in the data provider.

fieldExists(string $strField) : boolean

Parameters

$strField

string

The name of the property to search.

Returns

boolean

Retrieve the current active version for a model.

getActiveVersion(mixed $mixID) : mixed

Parameters

$mixID

mixed

The ID of the model.

Returns

mixedThe current version number of the requested row.

Return the amount of total items (filtering may be used in the config).

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

Parameters

$objConfig

\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface

The configuration to use.

Returns

int

Fetch an empty single collection (new model list).

getEmptyCollection() : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

Fetch an empty single filter option collection (new model list).

getEmptyFilterOptionCollection() : \ContaoCommunityAlliance\DcGeneral\Data\FilterOptionCollectionInterface

Fetch an empty single record (new model).

getEmptyModel() : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

Retrieve all unique values for the given property.

getFilterOptions(\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface $objConfig) : \ContaoCommunityAlliance\DcGeneral\Data\FilterOptionCollectionInterface
The result set will be an array containing all unique values contained in the data provider. Note: this only re-ensembles really used values for at least one data set. The only information being interpreted from the passed config object is the first property to fetch and the filter definition.

Parameters

$objConfig

\ContaoCommunityAlliance\DcGeneral\Data\ConfigInterface

The filter config options.

Returns

Return a model based of the version information.

getVersion(mixed $mixID, mixed $mixVersion) : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

Parameters

$mixID

mixed

The ID of the record.

$mixVersion

mixed

The ID of the version.

Returns

Return a list with all versions for the model 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

Check if the value is unique in the data provider.

isUniqueValue(string $strField, mixed $varNew, int $intId) : boolean

Parameters

$strField

string

The field in which to test.

$varNew

mixed

The value about to be saved.

$intId

int

The (optional) id of the item currently in scope - pass null for new items. Documentation: Evaluation - unique => If true the field value cannot be saved if it exists already.

Returns

boolean

Reset the fallback field.

resetFallback(string $strField) : void
This clears the given property in all items in the data provider to an empty value. Documentation: Evaluation - fallback => If true the field can only be assigned once per table.

Parameters

$strField

string

The field to reset.

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.

Save an item to the data provider.

save(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objItem) : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface
If the item does not have an Id yet, the save operation will add it as a new row to the database and populate the Id of the model accordingly.

Parameters

Returns

Save a collection of items to the data provider.

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

Parameters

$objItems

\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

The collection containing all items to be saved.

Save a new version of a model.

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.

Set base config with source and other necessary parameter.

setBaseConfig(array $arrConfig) : void

Parameters

$arrConfig

array

The configuration to use.

Exceptions

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

Set a version as active.

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

Parameters

$mixID

mixed

The ID of the model.

$mixVersion

mixed

The version number to set active.