Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
302
Merge Requests
302
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
07030912
Commit
07030912
authored
Nov 07, 2012
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1828408
by Amitaibu: Fixed Re-add addTag() and AddMetaData() to EFQ.
parent
b6af60e1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
1 deletion
+88
-1
core/lib/Drupal/Core/Entity/Query/QueryBase.php
core/lib/Drupal/Core/Entity/Query/QueryBase.php
+44
-0
core/lib/Drupal/Core/Entity/Query/QueryInterface.php
core/lib/Drupal/Core/Entity/Query/QueryInterface.php
+3
-1
core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php
...sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php
+14
-0
core/modules/field/tests/modules/field_test/field_test.module
.../modules/field/tests/modules/field_test/field_test.module
+11
-0
core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
...system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
+16
-0
No files found.
core/lib/Drupal/Core/Entity/Query/QueryBase.php
View file @
07030912
...
...
@@ -239,4 +239,48 @@ public function tableSort(&$headers) {
function
__clone
()
{
$this
->
condition
=
clone
$this
->
condition
;
}
/**
* Implements Drupal\Core\Database\Query\AlterableInterface::addTag().
*/
public
function
addTag
(
$tag
)
{
$this
->
alterTags
[
$tag
]
=
1
;
return
$this
;
}
/**
* Implements Drupal\Core\Database\Query\AlterableInterface::hasTag().
*/
public
function
hasTag
(
$tag
)
{
return
isset
(
$this
->
alterTags
[
$tag
]);
}
/**
* Implements Drupal\Core\Database\Query\AlterableInterface::hasAllTags().
*/
public
function
hasAllTags
()
{
return
!
(
boolean
)
array_diff
(
func_get_args
(),
array_keys
(
$this
->
alterTags
));
}
/**
* Implements Drupal\Core\Database\Query\AlterableInterface::hasAnyTag().
*/
public
function
hasAnyTag
()
{
return
(
boolean
)
array_intersect
(
func_get_args
(),
array_keys
(
$this
->
alterTags
));
}
/**
* Implements Drupal\Core\Database\Query\AlterableInterface::addMetaData().
*/
public
function
addMetaData
(
$key
,
$object
)
{
$this
->
alterMetaData
[
$key
]
=
$object
;
return
$this
;
}
/**
* Implements Drupal\Core\Database\Query\AlterableInterface::getMetaData().
*/
public
function
getMetaData
(
$key
)
{
return
isset
(
$this
->
alterMetaData
[
$key
])
?
$this
->
alterMetaData
[
$key
]
:
NULL
;
}
}
core/lib/Drupal/Core/Entity/Query/QueryInterface.php
View file @
07030912
...
...
@@ -7,13 +7,15 @@
namespace
Drupal\Core\Entity\Query
;
use
Drupal\Core\Database\Query\AlterableInterface
;
/**
* Interface for entity queries.
*
* Never instantiate classes implementing this interface directly. Always use
* the QueryFactory class.
*/
interface
QueryInterface
{
interface
QueryInterface
extends
AlterableInterface
{
/**
* Gets the entity type for this query.
...
...
core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php
View file @
07030912
...
...
@@ -100,6 +100,20 @@ public function execute() {
}
$sqlQuery
->
addTag
(
'entity_query'
);
$sqlQuery
->
addTag
(
'entity_query_'
.
$this
->
entityType
);
// Add further tags added.
if
(
isset
(
$this
->
alterTags
))
{
foreach
(
$this
->
alterTags
as
$tag
=>
$value
)
{
$sqlQuery
->
addTag
(
$tag
);
}
}
// Add further metadata added.
if
(
isset
(
$this
->
alterMetaData
))
{
foreach
(
$this
->
alterMetaData
as
$key
=>
$value
)
{
$sqlQuery
->
addMetaData
(
$key
,
$value
);
}
}
// This now contains first the table containing entity properties and
// last the entity base table. They might be the same.
$sqlQuery
->
addMetaData
(
'entity_tables'
,
$entity_tables
);
...
...
core/modules/field/tests/modules/field_test/field_test.module
View file @
07030912
...
...
@@ -262,6 +262,17 @@ function field_test_query_efq_table_prefixing_test_alter(&$query) {
$query
->
join
(
'test_entity'
,
'te2'
,
'%alias.ftid = test_entity.ftid'
);
}
/**
* Implements hook_query_TAG_alter() for tag 'efq_metadata_test'.
*
* @see Drupal\system\Tests\Entity\EntityQueryTest::testMetaData()
*/
function
field_test_query_efq_metadata_test_alter
(
&
$query
)
{
global
$efq_test_metadata
;
$efq_test_metadata
=
$query
->
getMetadata
(
'foo'
);
}
/**
* Implements hook_field_formatter_settings_form_alter().
*/
...
...
core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
View file @
07030912
...
...
@@ -453,4 +453,20 @@ protected function assertBundleOrder($order) {
$this
->
assertTrue
(
$ok
,
format_string
(
"
$i
is after all entities in bundle2"
));
}
}
/**
* Test adding a tag and metadata to the Entity query object.
*
* The tags and metadata should propogate to the SQL query object.
*/
function
testMetaData
()
{
$query
=
entity_query
(
'test_entity'
);
$query
->
addTag
(
'efq_metadata_test'
)
->
addMetaData
(
'foo'
,
'bar'
)
->
execute
();
global
$efq_test_metadata
;
$this
->
assertEqual
(
$efq_test_metadata
,
'bar'
,
'Tag and metadata propogated to the SQL query object.'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment