TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Typo3DbQueryParser Class Reference

Public Member Functions

 injectDataMapper (\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper)
 
 injectEnvironmentService (\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
 
 convertQueryToDoctrineQueryBuilder (QueryInterface $query)
 

Protected Member Functions

 initializeQueryBuilder (Qom\SourceInterface $source)
 
 parseConstraint (Qom\ConstraintInterface $constraint, Qom\SourceInterface $source)
 
 parseOrderings (array $orderings, Qom\SourceInterface $source)
 
 addTypo3Constraints (QueryInterface $query)
 
 parseComparison (Qom\ComparisonInterface $comparison, Qom\SourceInterface $source)
 
 parseDynamicOperand (Qom\ComparisonInterface $comparison, Qom\SourceInterface $source)
 
 parseOperand (Qom\DynamicOperandInterface $operand, Qom\SourceInterface $source)
 
 addRecordTypeConstraint ($className)
 
 getAdditionalMatchFieldsStatement ($exprBuilder, $columnMap, $childTableAlias, $parentTable=null)
 
 getAdditionalWhereClause (QuerySettingsInterface $querySettings, $tableName, $tableAlias=null)
 
 getVisibilityConstraintStatement (QuerySettingsInterface $querySettings, $tableName, $tableAlias)
 
 getFrontendConstraintStatement ($tableName, $ignoreEnableFields, array $enableFieldsToBeIgnored=[], $includeDeleted)
 
 getBackendConstraintStatement ($tableName, $ignoreEnableFields, $includeDeleted)
 
 getSysLanguageStatement ($tableName, $tableAlias, $querySettings)
 
 getPageIdStatement ($tableName, $tableAlias, array $storagePageIds)
 
 parseJoin (Qom\JoinInterface $join, $leftTableAlias)
 
 getUniqueAlias ($tableName, $fullPropertyPath=null)
 
 addUnionStatement (&$className, &$tableName, &$propertyPath, &$fullPropertyPath)
 
 replaceTableNameWithAlias ($statement, $tableName, $tableAlias)
 
 getPageRepository ()
 

Protected Attributes

 $dataMapper
 
 $pageRepository
 
 $environmentService
 
 $queryBuilder
 
 $tablePropertyMap = []
 
 $tableAliasMap = []
 
 $unionTableAliasCache = []
 
 $tableName = ''
 

Detailed Description

QueryParser, converting the qom to string representation

Definition at line 36 of file Typo3DbQueryParser.php.

Member Function Documentation

addRecordTypeConstraint (   $className)
protected

Add a constraint to ensure that the record type of the returned tuples is matching the data type of the repository.

Parameters
string$classNameThe class name
Returns
void

Definition at line 498 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName.

Referenced by Typo3DbQueryParser\initializeQueryBuilder(), and Typo3DbQueryParser\parseJoin().

addTypo3Constraints ( QueryInterface  $query)
protected
addUnionStatement ( $className,
$tableName,
$propertyPath,
$fullPropertyPath 
)
protected

adds a union statement to the query, mostly for tables referenced in the where condition. The property for which the union statement is generated will be appended.

Parameters
string&$classNameThe name of the parent class, will be set to the child class after processing.
string&$tableNameThe name of the parent table, will be set to the table alias that is used in the union statement.
array&$propertyPathThe remaining property path, will be cut of by one part during the process.
string$fullPropertyPathThe full path the the current property, will be used to make table names unique.
Exceptions
TYPO3
InvalidRelationConfigurationException
MissingColumnMapException

Definition at line 882 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, Typo3DbQueryParser\getAdditionalMatchFieldsStatement(), Typo3DbQueryParser\getUniqueAlias(), ColumnMap\RELATION_HAS_AND_BELONGS_TO_MANY, ColumnMap\RELATION_HAS_MANY, and ColumnMap\RELATION_HAS_ONE.

Referenced by Typo3DbQueryParser\parseComparison(), Typo3DbQueryParser\parseOperand(), and Typo3DbQueryParser\parseOrderings().

convertQueryToDoctrineQueryBuilder ( QueryInterface  $query)
getAdditionalMatchFieldsStatement (   $exprBuilder,
  $columnMap,
  $childTableAlias,
  $parentTable = null 
)
protected

Builds a condition for filtering records by the configured match field, e.g. MM_match_fields, foreign_match_fields or foreign_table_field.

Parameters
ExpressionBuilder$exprBuilder
ColumnMap$columnMapThe column man for which the condition should be build.
string$childTableAliasThe alias of the child record table used in the query.
string$parentTableThe real name of the parent table (used for building the foreign_table_field condition).
Returns
string The match field conditions or an empty string.

Definition at line 540 of file Typo3DbQueryParser.php.

Referenced by Typo3DbQueryParser\addUnionStatement(), and Typo3DbQueryParser\parseComparison().

getAdditionalWhereClause ( QuerySettingsInterface  $querySettings,
  $tableName,
  $tableAlias = null 
)
protected

Adds additional WHERE statements according to the query settings.

Parameters
QuerySettingsInterface$querySettingsThe TYPO3 CMS specific query settings
string$tableNameThe table name to add the additional where clause for
string$tableAliasThe table alias used in the query.
Returns
array

Definition at line 572 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, Typo3DbQueryParser\getPageIdStatement(), QuerySettingsInterface\getRespectStoragePage(), QuerySettingsInterface\getRespectSysLanguage(), QuerySettingsInterface\getStoragePageIds(), and Typo3DbQueryParser\getSysLanguageStatement().

Referenced by Typo3DbQueryParser\addTypo3Constraints().

getBackendConstraintStatement (   $tableName,
  $ignoreEnableFields,
  $includeDeleted 
)
protected

Returns constraint statement for backend context

Parameters
string$tableName
bool$ignoreEnableFieldsA flag indicating whether the enable fields should be ignored
bool$includeDeletedA flag indicating whether deleted records should be included
Returns
string

Definition at line 657 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, BackendUtility\BEenableFields(), and BackendUtility\deleteClause().

Referenced by Typo3DbQueryParser\getVisibilityConstraintStatement().

getFrontendConstraintStatement (   $tableName,
  $ignoreEnableFields,
array  $enableFieldsToBeIgnored = [],
  $includeDeleted 
)
protected

Returns constraint statement for frontend context

Parameters
string$tableName
bool$ignoreEnableFieldsA flag indicating whether the enable fields should be ignored
array$enableFieldsToBeIgnoredIf $ignoreEnableFields is true, this array specifies enable fields to be ignored. If it is NULL or an empty array (default) all enable fields are ignored.
bool$includeDeletedA flag indicating whether deleted records should be included
Returns
string
Exceptions
InconsistentQuerySettingsException

Definition at line 631 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, and Typo3DbQueryParser\getPageRepository().

Referenced by Typo3DbQueryParser\getVisibilityConstraintStatement().

getPageIdStatement (   $tableName,
  $tableAlias,
array  $storagePageIds 
)
protected

Builds the page ID checking statement

Parameters
string$tableNameThe database table name
string$tableAliasThe table alias used in the query.
array$storagePageIdslist of storage page ids
Exceptions
InconsistentQuerySettingsException
Returns
string

Definition at line 760 of file Typo3DbQueryParser.php.

References $GLOBALS, and Typo3DbQueryParser\$tableName.

Referenced by Typo3DbQueryParser\getAdditionalWhereClause().

getPageRepository ( )
protected
getSysLanguageStatement (   $tableName,
  $tableAlias,
  $querySettings 
)
protected

Builds the language field statement

Parameters
string$tableNameThe database table name
string$tableAliasThe table alias used in the query.
QuerySettingsInterface$querySettingsThe TYPO3 CMS specific query settings
Returns
string

Definition at line 677 of file Typo3DbQueryParser.php.

References $GLOBALS, and Typo3DbQueryParser\$tableName.

Referenced by Typo3DbQueryParser\getAdditionalWhereClause().

getUniqueAlias (   $tableName,
  $fullPropertyPath = null 
)
protected

Generates a unique alias for the given table and the given property path. The property path will be mapped to the generated alias in the tablePropertyMap.

Parameters
string$tableNameThe name of the table for which the alias should be generated.
string$fullPropertyPathThe full property path that is related to the given table.
Returns
string The generated table alias.

Definition at line 848 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName.

Referenced by Typo3DbQueryParser\addUnionStatement(), Typo3DbQueryParser\initializeQueryBuilder(), and Typo3DbQueryParser\parseJoin().

getVisibilityConstraintStatement ( QuerySettingsInterface  $querySettings,
  $tableName,
  $tableAlias 
)
protected
initializeQueryBuilder ( Qom\SourceInterface  $source)
protected

Creates the queryBuilder object whether it is a regular select or a JOIN

Parameters
Qom\SourceInterface$sourceThe source
Returns
void

Definition at line 145 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, Typo3DbQueryParser\addRecordTypeConstraint(), Typo3DbQueryParser\getUniqueAlias(), GeneralUtility\makeInstance(), and Typo3DbQueryParser\parseJoin().

Referenced by Typo3DbQueryParser\convertQueryToDoctrineQueryBuilder().

injectDataMapper ( \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper  $dataMapper)
Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper$dataMapper

Definition at line 95 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$dataMapper.

injectEnvironmentService ( \TYPO3\CMS\Extbase\Service\EnvironmentService  $environmentService)
Parameters
\TYPO3\CMS\Extbase\Service\EnvironmentService$environmentService

Definition at line 103 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$environmentService.

parseComparison ( Qom\ComparisonInterface  $comparison,
Qom\SourceInterface  $source 
)
protected

Parse a Comparison into SQL and parameter arrays.

Parameters
Qom\ComparisonInterface$comparisonThe comparison to parse
Qom\SourceInterface$sourceThe source
Exceptions
RuntimeException
TYPO3
Returns
string

Definition at line 298 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, Typo3DbQueryParser\addUnionStatement(), Typo3DbQueryParser\getAdditionalMatchFieldsStatement(), ColumnMap\getTypeOfRelation(), QueryInterface\OPERATOR_CONTAINS, Typo3DbQueryParser\parseDynamicOperand(), ColumnMap\RELATION_HAS_AND_BELONGS_TO_MANY, and ColumnMap\RELATION_HAS_MANY.

Referenced by Typo3DbQueryParser\parseConstraint().

parseConstraint ( Qom\ConstraintInterface  $constraint,
Qom\SourceInterface  $source 
)
protected

Transforms a constraint into SQL and parameter arrays

Parameters
Qom\ConstraintInterface$constraintThe constraint
Qom\SourceInterface$sourceThe source
Returns
CompositeExpression|string
Exceptions
RuntimeException

Definition at line 188 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\parseComparison().

Referenced by Typo3DbQueryParser\convertQueryToDoctrineQueryBuilder().

parseJoin ( Qom\JoinInterface  $join,
  $leftTableAlias 
)
protected

Transforms a Join into SQL and parameter arrays

Parameters
Qom\JoinInterface$joinThe join
string$leftTableAliasThe alias from the table to main
Returns
void

Definition at line 805 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\addRecordTypeConstraint(), and Typo3DbQueryParser\getUniqueAlias().

Referenced by Typo3DbQueryParser\initializeQueryBuilder().

parseOperand ( Qom\DynamicOperandInterface  $operand,
Qom\SourceInterface  $source 
)
protected
Parameters
Qom\DynamicOperandInterface$operand
Qom\SourceInterface$sourceThe source
Returns
string
Exceptions
InvalidArgumentException

Definition at line 464 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, and Typo3DbQueryParser\addUnionStatement().

Referenced by Typo3DbQueryParser\parseDynamicOperand().

parseOrderings ( array  $orderings,
Qom\SourceInterface  $source 
)
protected

Transforms orderings into SQL.

Parameters
array$orderingsAn array of orderings (Qom)
Qom\SourceInterface$sourceThe source
Exceptions
UnsupportedOrderException
Returns
void

Definition at line 233 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, Typo3DbQueryParser\addUnionStatement(), QueryInterface\ORDER_ASCENDING, and QueryInterface\ORDER_DESCENDING.

Referenced by Typo3DbQueryParser\convertQueryToDoctrineQueryBuilder().

replaceTableNameWithAlias (   $statement,
  $tableName,
  $tableAlias 
)
protected

If the table name does not match the table alias all occurrences of "tableName." are replaced with "tableAlias." in the given SQL statement.

Parameters
string$statementThe SQL statement in which the values are replaced.
string$tableNameThe table name that is replaced.
string$tableAliasThe table alias that replaced the table name.
Returns
string The modified SQL statement.

Definition at line 982 of file Typo3DbQueryParser.php.

References Typo3DbQueryParser\$tableName, and GeneralUtility\makeInstance().

Referenced by Typo3DbQueryParser\getVisibilityConstraintStatement().

Member Data Documentation

$dataMapper
protected

Definition at line 41 of file Typo3DbQueryParser.php.

Referenced by Typo3DbQueryParser\injectDataMapper().

$environmentService
protected

Definition at line 53 of file Typo3DbQueryParser.php.

Referenced by Typo3DbQueryParser\injectEnvironmentService().

$pageRepository
protected

Definition at line 48 of file Typo3DbQueryParser.php.

Referenced by Typo3DbQueryParser\getPageRepository().

$queryBuilder
protected
$tableAliasMap = []
protected

Definition at line 78 of file Typo3DbQueryParser.php.

$tablePropertyMap = []
protected

Definition at line 70 of file Typo3DbQueryParser.php.

$unionTableAliasCache = []
protected

Definition at line 85 of file Typo3DbQueryParser.php.