‪TYPO3CMS  9.5
TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser Class Reference

Public Member Functions

 injectObjectManager (ObjectManagerInterface $objectManager)
 
 initializeObject ()
 
 injectEnvironmentService (EnvironmentService $environmentService)
 
 injectConfigurationManager (ConfigurationManagerInterface $configurationManager)
 
bool isDistinctQuerySuggested ()
 
QueryBuilder convertQueryToDoctrineQueryBuilder (QueryInterface $query)
 

Protected Member Functions

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

Protected Attributes

DataMapper $dataMapper
 
PageRepository $pageRepository
 
EnvironmentService $environmentService
 
ConfigurationManagerInterface $configurationManager
 
QueryBuilder $queryBuilder
 
array $tablePropertyMap = array( )
 
array $tableAliasMap = array( )
 
array $unionTableAliasCache = array( )
 
string $tableName = ''
 
bool $suggestDistinctQuery = false
 
ObjectManagerInterface $objectManager
 

Detailed Description

QueryParser, converting the qom to string representation

only to be used within Extbase, not part of TYPO3 Core API.

Definition at line 47 of file Typo3DbQueryParser.php.

Member Function Documentation

◆ addRecordTypeConstraint()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::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$className‪The class name

Definition at line 607 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\initializeQueryBuilder(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseJoin().

◆ addTypo3Constraints()

◆ addUnionStatement()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::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&$className‪The name of the parent class, will be set to the child class after processing.
string&$tableName‪The name of the parent table, will be set to the table alias that is used in the union statement.
string&$propertyPath‪The remaining property path, will be cut of by one part during the process.
string$fullPropertyPath‪The full path the the current property, will be used to make table names unique.
Exceptions
Exception
InvalidRelationConfigurationException
MissingColumnMapException

Definition at line 1076 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName, TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getAdditionalMatchFieldsStatement(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getUniqueAlias(), TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap\RELATION_HAS_AND_BELONGS_TO_MANY, TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap\RELATION_HAS_MANY, and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap\RELATION_HAS_ONE.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseComparison(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseOperand(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseOrderings().

◆ convertQueryToDoctrineQueryBuilder()

◆ createTypedNamedParameter()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::createTypedNamedParameter (   $value,
int  $forceType = null 
)
protected

Create a named parameter for the QueryBuilder and guess the parameter type based on the output of DataMapper::getPlainValue(). The type of the named parameter can be forced to one of the \PDO::PARAM_* types by specifying the $forceType argument.

Parameters
mixed$value‪The input value that should be sent to the database
int | null$forceType‪The \PDO::PARAM_* type that should be forced
Returns
‪string The placeholder string to be used in the query
See also
‪\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getPlainValue()

Definition at line 550 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject\_hasProperty(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getParameterType().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseDynamicOperand().

◆ getAdditionalMatchFieldsStatement()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::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$columnMap‪The column man for which the condition should be build.
string$childTableAlias‪The alias of the child record table used in the query.
string$parentTable‪The 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 649 of file Typo3DbQueryParser.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addUnionStatement(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseComparison().

◆ getAdditionalWhereClause()

array TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getAdditionalWhereClause ( QuerySettingsInterface  $querySettings,
  $tableName,
  $tableAlias = null 
)
protected

◆ getBackendConstraintStatement()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getBackendConstraintStatement (   $tableName,
  $ignoreEnableFields,
  $includeDeleted 
)
protected

Returns constraint statement for backend context

Parameters
string$tableName
bool$ignoreEnableFields‪A flag indicating whether the enable fields should be ignored
bool$includeDeleted‪A flag indicating whether deleted records should be included
Returns
‪string

Definition at line 770 of file Typo3DbQueryParser.php.

References $GLOBALS, TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName, and TYPO3\CMS\Backend\Utility\BackendUtility\BEenableFields().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getVisibilityConstraintStatement().

◆ getFrontendConstraintStatement()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getFrontendConstraintStatement (   $tableName,
  $ignoreEnableFields,
array  $enableFieldsToBeIgnored = [],
  $includeDeleted 
)
protected

Returns constraint statement for frontend context

Parameters
string$tableName
bool$ignoreEnableFields‪A flag indicating whether the enable fields should be ignored
array$enableFieldsToBeIgnored‪If $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$includeDeleted‪A flag indicating whether deleted records should be included
Returns
‪string
Exceptions
InconsistentQuerySettingsException

Definition at line 744 of file Typo3DbQueryParser.php.

References $GLOBALS, TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName, TYPO3\CMS\Frontend\Page\PageRepository\enableFields(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getPageRepository().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getVisibilityConstraintStatement().

◆ getLanguageStatement()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getLanguageStatement (   $tableName,
  $tableAlias,
QuerySettingsInterface  $querySettings 
)
protected

Builds the language field statement

Parameters
string$tableName‪The database table name
string$tableAlias‪The table alias used in the query.
QuerySettingsInterface$querySettings‪The TYPO3 CMS specific query settings
Returns
‪string

Definition at line 870 of file Typo3DbQueryParser.php.

References $GLOBALS, TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName, TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface\getLanguageOverlayMode(), and TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface\getLanguageUid().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getAdditionalWhereClause().

◆ getPageIdStatement()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getPageIdStatement (   $tableName,
  $tableAlias,
array  $storagePageIds 
)
protected

Builds the page ID checking statement

Parameters
string$tableName‪The database table name
string$tableAlias‪The table alias used in the query.
array$storagePageIds‪list of storage page ids
Returns
‪string
Exceptions
InconsistentQuerySettingsException

Definition at line 957 of file Typo3DbQueryParser.php.

References $GLOBALS, and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getAdditionalWhereClause().

◆ getPageRepository()

PageRepository TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getPageRepository ( )
protected

◆ getParameterType()

int TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getParameterType (   $value)
protected

Maps plain value of operand to PDO types to help Doctrine and/or the database driver process the value correctly when building the query.

Parameters
mixed$value‪The parameter value
Returns
‪int
Exceptions

Definition at line 524 of file Typo3DbQueryParser.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\createTypedNamedParameter().

◆ getSysLanguageStatement()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getSysLanguageStatement (   $tableName,
  $tableAlias,
  $querySettings 
)
protected

Builds the language field statement in a legacy way (when consistentTranslationOverlayHandling flag is disabled)

Parameters
string$tableName‪The database table name
string$tableAlias‪The table alias used in the query.
QuerySettingsInterface$querySettings‪The TYPO3 CMS specific query settings
Returns
‪string

Definition at line 790 of file Typo3DbQueryParser.php.

References $GLOBALS, and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getAdditionalWhereClause().

◆ getUniqueAlias()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::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$tableName‪The name of the table for which the alias should be generated.
string$fullPropertyPath‪The full property path that is related to the given table.
Returns
‪string The generated table alias.

Definition at line 1042 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addUnionStatement(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\initializeQueryBuilder(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseJoin().

◆ getVisibilityConstraintStatement()

◆ initializeObject()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::initializeObject ( )

Object initialization called when object is created with ObjectManager, after constructor

Definition at line 118 of file Typo3DbQueryParser.php.

◆ initializeQueryBuilder()

◆ injectConfigurationManager()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::injectConfigurationManager ( ConfigurationManagerInterface  $configurationManager)
Parameters
ConfigurationManagerInterface$configurationManager

Definition at line 134 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$configurationManager.

◆ injectEnvironmentService()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::injectEnvironmentService ( EnvironmentService  $environmentService)
Parameters
EnvironmentService$environmentService

Definition at line 126 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$environmentService.

◆ injectObjectManager()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::injectObjectManager ( ObjectManagerInterface  $objectManager)
Parameters
ObjectManagerInterface$objectManager

Definition at line 110 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$objectManager.

◆ isDistinctQuerySuggested()

bool TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::isDistinctQuerySuggested ( )

Whether using a distinct query is suggested. This information is defined during parsing of the current query for RELATION_HAS_MANY & RELATION_HAS_AND_BELONGS_TO_MANY relations.

Returns
‪bool

Definition at line 146 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$suggestDistinctQuery.

◆ parseComparison()

◆ parseConstraint()

CompositeExpression string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseConstraint ( Qom\ConstraintInterface  $constraint,
Qom\SourceInterface  $source 
)
protected

Transforms a constraint into SQL and parameter arrays

Parameters
Qom\ConstraintInterface$constraint‪The constraint
Qom\SourceInterface$source‪The source
Returns
‪CompositeExpression|string
Exceptions

Definition at line 235 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseComparison().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\convertQueryToDoctrineQueryBuilder().

◆ parseDynamicOperand()

◆ parseJoin()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseJoin ( Qom\JoinInterface  $join,
  $leftTableAlias 
)
protected

Transforms a Join into SQL and parameter arrays

Parameters
Qom\JoinInterface$join‪The join
string$leftTableAlias‪The alias from the table to main

Definition at line 1000 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addRecordTypeConstraint(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getUniqueAlias().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\initializeQueryBuilder().

◆ parseOperand()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseOperand ( Qom\DynamicOperandInterface  $operand,
Qom\SourceInterface  $source 
)
protected
Parameters
Qom\DynamicOperandInterface$operand
Qom\SourceInterface$source‪The source
Returns
‪string
Exceptions

Definition at line 574 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName, and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addUnionStatement().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseDynamicOperand().

◆ parseOrderings()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseOrderings ( array  $orderings,
Qom\SourceInterface  $source 
)
protected

◆ replaceTableNameWithAlias()

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::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$statement‪The SQL statement in which the values are replaced.
string$tableName‪The table name that is replaced.
string$tableAlias‪The table alias that replaced the table name.
Returns
‪string The modified SQL statement.

Definition at line 1183 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$tableName.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getVisibilityConstraintStatement().

Member Data Documentation

◆ $configurationManager

ConfigurationManagerInterface TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$configurationManager
protected

◆ $dataMapper

DataMapper TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$dataMapper
protected

Definition at line 51 of file Typo3DbQueryParser.php.

◆ $environmentService

EnvironmentService TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$environmentService
protected

◆ $objectManager

ObjectManagerInterface TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$objectManager
protected

◆ $pageRepository

PageRepository TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$pageRepository
protected

The TYPO3 page repository. Used for language and workspace overlay

Definition at line 57 of file Typo3DbQueryParser.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getPageRepository().

◆ $queryBuilder

QueryBuilder TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$queryBuilder
protected

Instance of the Doctrine query builder

Definition at line 71 of file Typo3DbQueryParser.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\convertQueryToDoctrineQueryBuilder().

◆ $suggestDistinctQuery

bool TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$suggestDistinctQuery = false
protected

◆ $tableAliasMap

array TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$tableAliasMap = array( )
protected

Maps tablenames to their aliases to be used in where clauses etc. Mainly used for joins on the same table etc.

Definition at line 87 of file Typo3DbQueryParser.php.

◆ $tableName

string TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$tableName = ''
protected

◆ $tablePropertyMap

array TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$tablePropertyMap = array( )
protected

Maps domain model properties to their corresponding table aliases that are used in the query, e.g.:

'property1' => 'tableName', 'property1.property2' => 'tableName1',

Definition at line 80 of file Typo3DbQueryParser.php.

◆ $unionTableAliasCache

array TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$unionTableAliasCache = array( )
protected

Stores all tables used in for SQL joins

Definition at line 93 of file Typo3DbQueryParser.php.