Overview

Namespaces

  • DcGeneral
    • Clipboard
    • Contao
      • Callback
      • Compatibility
      • DataDefinition
        • Definition
      • Dca
        • Builder
          • Legacy
        • Definition
        • Palette
        • Populator
      • Event
      • View
        • Contao2BackendView
          • Event
    • Controller
    • Data
    • DataDefinition
      • Builder
      • Definition
        • Properties
        • View
          • Panel
      • ModelRelationship
      • Palette
        • Builder
          • Event
        • Condition
          • Palette
          • Property
    • EnvironmentPopulator
    • Event
    • Exception
    • Factory
      • Event
    • Panel
    • View
      • Event

Classes

  • AbstractModel
  • DCGE
  • DefaultCollection
  • DefaultConfig
  • DefaultDataProvider
  • DefaultLanguageInformation
  • DefaultLanguageInformationCollection
  • DefaultModel
  • MultiLanguageDataProvider
  • NoOpDataProvider
  • PropertyValueBag
  • TableRowsAsRecordsDataProvider

Interfaces

  • CollectionInterface
  • ConfigInterface
  • DataProviderInterface
  • LanguageInformationCollectionInterface
  • LanguageInformationInterface
  • ModelInterface
  • MultiLanguageDataProviderInterface
  • PropertyValueBagInterface
  • VersionModelInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Class DefaultDataProvider

Class DefaultDataProvider.

Default implementation for a data provider using the Contao default database as backend.

DcGeneral\Data\DefaultDataProvider implements DcGeneral\Data\DataProviderInterface

Direct known subclasses

DcGeneral\Data\MultiLanguageDataProvider, DcGeneral\Data\TableRowsAsRecordsDataProvider
Namespace: DcGeneral\Data
Package: DcGeneral\Data
Located at Data/DefaultDataProvider.php
Methods summary
public
# __construct( )

Create a new instance of the data provider.

Create a new instance of the data provider.

public
# setBaseConfig( array $arrConfig )

Set base config with source and other necessary parameter.

Set base config with source and other necessary parameter.

Parameters

$arrConfig
array
$arrConfig The configuration to use.

Throws

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

Implementation of

DcGeneral\Data\DataProviderInterface::setBaseConfig()
public DcGeneral\Data\ConfigInterface
# getEmptyConfig( )

Return an empty configuration object.

Return an empty configuration object.

Returns

DcGeneral\Data\ConfigInterface

Implementation of

DcGeneral\Data\DataProviderInterface::getEmptyConfig()
public DcGeneral\Data\ModelInterface
# getEmptyModel( )

Fetch an empty single record (new model).

Fetch an empty single record (new model).

Returns

DcGeneral\Data\ModelInterface

Implementation of

DcGeneral\Data\DataProviderInterface::getEmptyModel()
public DcGeneral\Data\CollectionInterface
# getEmptyCollection( )

Fetch an empty single collection (new model list).

Fetch an empty single collection (new model list).

Returns

DcGeneral\Data\CollectionInterface

Implementation of

DcGeneral\Data\DataProviderInterface::getEmptyCollection()
protected string
# buildFieldQuery( DcGeneral\Data\ConfigInterface $objConfig )

Build the field list.

Build the field list.

Returns all values from $objConfig->getFields() as comma separated list.

Parameters

$objConfig
DcGeneral\Data\ConfigInterface
$objConfig The configuration to use.

Returns

string
protected string
# getAndOrFilter( array $operation, array & $params )

Build an AND or OR query.

Build an AND or OR query.

Parameters

$operation
array
$operation The operation to convert.
$params
array
$params The parameter array for the resulting query.

Returns

string
protected string
# getFilterForComparingOperator( array $operation, array & $params )

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

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

Parameters

$operation
array
$operation The operation to apply.
$params
array
$params The parameters of the entire query.

Returns

string
protected string
# getFilterForInList( array $operation, array & $params )

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

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

Parameters

$operation
array
$operation The operation to apply.
$params
array
$params The parameters of the entire query.

Returns

string
protected string
# getFilterForLike( array $operation, array & $params )

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

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

The searched value may contain the wildcards '*' and '?' which will get converted to proper SQL.

Parameters

$operation
array
$operation The operation to apply.
$params
array
$params The parameters of the entire query.

Returns

string
protected string
# calculateSubfilter( array $arrFilter, array & $arrParams )

Combine a filter in standard filter array notation.

Combine a filter in standard filter array notation.

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
$arrFilter The filter to be combined to a valid SQL filter query.
$arrParams
array
$arrParams The query parameters will get stored into this array.

Returns

string
The combined WHERE conditions.

Throws

DcGeneral\Exception\DcGeneralRuntimeException
If an invalid filter entry is encountered.
protected string
# buildWhereQuery( DcGeneral\Data\ConfigInterface $objConfig, array & $arrParams = null )

Build the WHERE clause for a configuration.

Build the WHERE clause for a configuration.

Parameters

$objConfig
DcGeneral\Data\ConfigInterface
$objConfig The configuration to use.
$arrParams
array
$arrParams The query parameters will get stored into this array.

Returns

string
The combined WHERE clause (including the word "WHERE").
protected string
# buildFilterQuery( DcGeneral\Data\ConfigInterface $objConfig, array & $arrParams = null )

Build the WHERE conditions via calculateSubfilter().

Build the WHERE conditions via calculateSubfilter().

Parameters

$objConfig
DcGeneral\Data\ConfigInterface
$objConfig The configuration to use.
$arrParams
array
$arrParams The query parameters will get stored into this array.

Returns

string
The combined WHERE conditions.
protected string
# buildSortingQuery( DcGeneral\Data\ConfigInterface $objConfig )

Build the order by part of a query.

Build the order by part of a query.

Parameters

$objConfig
DcGeneral\Data\ConfigInterface
$objConfig The configuration to use.

Returns

string
public
# delete( mixed $item )

Delete an item.

Delete an item.

Parameters

$item
mixed
$item Id or the model itself, to delete.

Throws

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

Implementation of

DcGeneral\Data\DataProviderInterface::delete()
protected DcGeneral\Data\ModelInterface
# createModelFromDatabaseResult( Database\Result $dbResult )

Create a model from a database result.

Create a model from a database result.

Parameters

$dbResult
Database\Result
$dbResult The database result to create a model from.

Returns

DcGeneral\Data\ModelInterface
public DcGeneral\Data\ModelInterface
# fetch( DcGeneral\Data\ConfigInterface $objConfig )

Fetch a single or first record by id or filter.

Fetch a single or first record by id or filter.

Parameters

$objConfig
DcGeneral\Data\ConfigInterface
$objConfig The configuration to use.

Returns

DcGeneral\Data\ModelInterface

Implementation of

DcGeneral\Data\DataProviderInterface::fetch()
public DcGeneral\Data\CollectionInterface|array
# fetchAll( DcGeneral\Data\ConfigInterface $objConfig )

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

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

Parameters

$objConfig
DcGeneral\Data\ConfigInterface
$objConfig The configuration to use.

Returns

DcGeneral\Data\CollectionInterface|array

Implementation of

DcGeneral\Data\DataProviderInterface::fetchAll()
public DcGeneral\Data\CollectionInterface
# getFilterOptions( DcGeneral\Data\ConfigInterface $objConfig )

Retrieve all unique values for the given property.

Retrieve all unique values for the given property.

Parameters

$objConfig
DcGeneral\Data\ConfigInterface
$objConfig The filter config options.

Returns

DcGeneral\Data\CollectionInterface

Throws

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

Implementation of

DcGeneral\Data\DataProviderInterface::getFilterOptions()
public integer
# getCount( DcGeneral\Data\ConfigInterface $objConfig )

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

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

Parameters

$objConfig
DcGeneral\Data\ConfigInterface
$objConfig The configuration to use.

Returns

integer

Implementation of

DcGeneral\Data\DataProviderInterface::getCount()
public boolean
# isUniqueValue( string $strField, mixed $varNew, integer $intId = null )

Check if the value is unique in the data provider.

Check if the value is unique in the data provider.

Parameters

$strField
string
$strField The field in which to test.
$varNew
mixed
$varNew The value about to be saved.
$intId
integer
$intId 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

Implementation of

DcGeneral\Data\DataProviderInterface::isUniqueValue()
public
# resetFallback( string $strField )

Reset the fallback field.

Reset the fallback field.

Parameters

$strField
string
$strField The field to reset.

Implementation of

DcGeneral\Data\DataProviderInterface::resetFallback()
public DcGeneral\Data\ModelInterface
# save( DcGeneral\Data\ModelInterface $objItem )

Save an item to the data provider.

Save an item to the data provider.

Parameters

$objItem
DcGeneral\Data\ModelInterface
$objItem The model to save back.

Returns

DcGeneral\Data\ModelInterface
The passed model.

Implementation of

DcGeneral\Data\DataProviderInterface::save()
public
# saveEach( DcGeneral\Data\CollectionInterface $objItems )

Save a collection of items to the data provider.

Save a collection of items to the data provider.

Parameters

$objItems
DcGeneral\Data\CollectionInterface
$objItems The collection containing all items to be saved.

Implementation of

DcGeneral\Data\DataProviderInterface::saveEach()
public boolean
# fieldExists( string $strField )

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

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

Parameters

$strField
string
$strField The name of the property to search.

Returns

boolean

Implementation of

DcGeneral\Data\DataProviderInterface::fieldExists()
public DcGeneral\Data\ModelInterface
# getVersion( mixed $mixID, mixed $mixVersion )

Return a model based of the version information.

Return a model based of the version information.

Parameters

$mixID
mixed
$mixID The ID of the record.
$mixVersion
mixed
$mixVersion The ID of the version.

Returns

DcGeneral\Data\ModelInterface

Implementation of

DcGeneral\Data\DataProviderInterface::getVersion()
public DcGeneral\Data\CollectionInterface
# getVersions( mixed $mixID, boolean $blnOnlyActive = false )

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

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

Parameters

$mixID
mixed
$mixID The ID of the row.
$blnOnlyActive
boolean
$blnOnlyActive If true, only active versions will get returned, if false all version will get returned.

Returns

DcGeneral\Data\CollectionInterface

Implementation of

DcGeneral\Data\DataProviderInterface::getVersions()
public
# saveVersion( DcGeneral\Data\ModelInterface $objModel, string $strUsername )

Save a new version of a row.

Save a new version of a row.

Parameters

$objModel
DcGeneral\Data\ModelInterface
$objModel The model for which a new version shall be created.
$strUsername
string
$strUsername The username to attach to the version as creator.

Implementation of

DcGeneral\Data\DataProviderInterface::saveVersion()
public
# setVersionActive( mixed $mixID, mixed $mixVersion )

Set a version as active.

Set a version as active.

Parameters

$mixID
mixed
$mixID The ID of the row.
$mixVersion
mixed
$mixVersion The version number to set active.

Implementation of

DcGeneral\Data\DataProviderInterface::setVersionActive()
public mixed
# getActiveVersion( mixed $mixID )

Retrieve the current active version for a row.

Retrieve the current active version for a row.

Parameters

$mixID
mixed
$mixID The ID of the row.

Returns

mixed
The current version number of the requested row.

Implementation of

DcGeneral\Data\DataProviderInterface::getActiveVersion()
public boolean
# sameModels( DcGeneral\Data\ModelInterface $objModel1, DcGeneral\Data\ModelInterface $objModel2 )

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

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

Parameters

$objModel1
DcGeneral\Data\ModelInterface
$objModel1 The first model to compare.
$objModel2
DcGeneral\Data\ModelInterface
$objModel2 The second model to compare.

Returns

boolean
True - If both models are same, false if not.

Implementation of

DcGeneral\Data\DataProviderInterface::sameModels()
protected
# insertUndo( string $strSourceSQL, string $strSaveSQL, string $strTable )

Store an undo entry in the table tl_undo.

Store an undo entry in the table tl_undo.

Currently this only supports delete queries.

Parameters

$strSourceSQL
string
$strSourceSQL The SQL used to perform the action to be undone.
$strSaveSQL
string
$strSaveSQL The SQL query to retrieve the current entries.
$strTable
string
$strTable The table to be affected by the action.
Properties summary
protected string $strSource null
#

Name of current source.

Name of current source.

protected Database $objDatabase null
#

The Database instance.

The Database instance.

Todo:

Use DI container for database instance.
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0