class Query
Same name in this branch
- 9 core/lib/Drupal/Core/Config/Entity/Query/Query.php \Drupal\Core\Config\Entity\Query\Query
- 9 core/lib/Drupal/Core/Database/Query/Query.php \Drupal\Core\Database\Query\Query
- 9 core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query
- 9 core/lib/Drupal/Core/Entity/Query/Null/Query.php \Drupal\Core\Entity\Query\Null\Query
- 9 core/lib/Drupal/Core/Entity/KeyValueStore/Query/Query.php \Drupal\Core\Entity\KeyValueStore\Query\Query
Same name and namespace in other branches
- 11.x core/modules/workspaces/src/EntityQuery/Query.php \Drupal\workspaces\EntityQuery\Query
- 11.x core/lib/Drupal/Core/Config/Entity/Query/Query.php \Drupal\Core\Config\Entity\Query\Query
- 11.x core/lib/Drupal/Core/Database/Query/Query.php \Drupal\Core\Database\Query\Query
- 11.x core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query
- 11.x core/lib/Drupal/Core/Entity/Query/Null/Query.php \Drupal\Core\Entity\Query\Null\Query
- 11.x core/lib/Drupal/Core/Entity/KeyValueStore/Query/Query.php \Drupal\Core\Entity\KeyValueStore\Query\Query
- 7.x includes/database/query.inc \Query
- 10 core/modules/workspaces/src/EntityQuery/Query.php \Drupal\workspaces\EntityQuery\Query
- 10 core/lib/Drupal/Core/Config/Entity/Query/Query.php \Drupal\Core\Config\Entity\Query\Query
- 10 core/lib/Drupal/Core/Database/Query/Query.php \Drupal\Core\Database\Query\Query
- 10 core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query
- 10 core/lib/Drupal/Core/Entity/Query/Null/Query.php \Drupal\Core\Entity\Query\Null\Query
- 10 core/lib/Drupal/Core/Entity/KeyValueStore/Query/Query.php \Drupal\Core\Entity\KeyValueStore\Query\Query
- 8.9.x core/modules/workspaces/src/EntityQuery/Query.php \Drupal\workspaces\EntityQuery\Query
- 8.9.x core/lib/Drupal/Core/Config/Entity/Query/Query.php \Drupal\Core\Config\Entity\Query\Query
- 8.9.x core/lib/Drupal/Core/Database/Query/Query.php \Drupal\Core\Database\Query\Query
- 8.9.x core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query
- 8.9.x core/lib/Drupal/Core/Entity/Query/Null/Query.php \Drupal\Core\Entity\Query\Null\Query
- 8.9.x core/lib/Drupal/Core/Entity/KeyValueStore/Query/Query.php \Drupal\Core\Entity\KeyValueStore\Query\Query
Alters entity queries to use a workspace revision instead of the default one.
Hierarchy
- class \Drupal\Core\Entity\Query\QueryBase implements \Drupal\Core\Entity\Query\QueryInterface
- class \Drupal\Core\Entity\Query\Sql\Query implements \Drupal\Core\Entity\Query\QueryInterface extends \Drupal\Core\Entity\Query\QueryBase
- class \Drupal\workspaces\EntityQuery\Query uses \Drupal\workspaces\EntityQuery\QueryTrait extends \Drupal\Core\Entity\Query\Sql\Query
- class \Drupal\Core\Entity\Query\Sql\Query implements \Drupal\Core\Entity\Query\QueryInterface extends \Drupal\Core\Entity\Query\QueryBase
Expanded class hierarchy of Query
94 string references to 'Query'
- AjaxFormCacheTest::testQueryString in core/
tests/ Drupal/ FunctionalJavascriptTests/ Ajax/ AjaxFormCacheTest.php - Tests AJAX forms on pages with a query string.
- BasicTest::testWizardDefaultValues in core/
modules/ views/ tests/ src/ Functional/ Wizard/ BasicTest.php - Tests default plugin values are populated from the wizard form.
- batch_process in core/
includes/ form.inc - Processes the batch.
- BlockContentTest::getExpectedDocument in core/
modules/ jsonapi/ tests/ src/ Functional/ BlockContentTest.php - Returns the expected JSON:API document for the entity.
- bootstrap.inc in core/
includes/ bootstrap.inc - Functions that need to be loaded on every Drupal request.
File
-
core/
modules/ workspaces/ src/ EntityQuery/ Query.php, line 10
Namespace
Drupal\workspaces\EntityQueryView source
class Query extends BaseQuery {
use QueryTrait {
prepare as traitPrepare;
}
/**
* {@inheritdoc}
*/
public function prepare() {
$this->traitPrepare();
// If the prepare() method from the trait decided that we need to alter this
// query, we need to re-define the key fields for fetchAllKeyed() as SQL
// expressions.
if ($this->sqlQuery
->getMetaData('active_workspace_id')) {
$id_field = $this->entityType
->getKey('id');
$revision_field = $this->entityType
->getKey('revision');
// Since the query is against the base table, we have to take into account
// that the revision ID might come from the workspace_association
// relationship, and, as a consequence, the revision ID field is no longer
// a simple SQL field but an expression.
$this->sqlFields = [];
$this->sqlQuery
->addExpression("COALESCE([workspace_association].[target_entity_revision_id], [base_table].[{$revision_field}])", $revision_field);
$this->sqlQuery
->addExpression("[base_table].[{$id_field}]", $id_field);
$this->sqlGroupBy['workspace_association.target_entity_revision_id'] = 'workspace_association.target_entity_revision_id';
$this->sqlGroupBy["base_table.{$id_field}"] = "base_table.{$id_field}";
$this->sqlGroupBy["base_table.{$revision_field}"] = "base_table.{$revision_field}";
}
return $this;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.