Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
4c834544
Commit
4c834544
authored
Dec 22, 2013
by
webchick
Browse files
Issue
#2156835
by chx: ConfigStorageController is not using entity query for loadByProperties.
parent
06d4c62f
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
View file @
4c834544
...
...
@@ -185,19 +185,6 @@ public function deleteRevision($revision_id) {
return
NULL
;
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::loadByProperties().
*/
public
function
loadByProperties
(
array
$values
=
array
())
{
$entities
=
$this
->
loadMultiple
();
foreach
(
$values
as
$key
=>
$value
)
{
$entities
=
array_filter
(
$entities
,
function
(
$entity
)
use
(
$key
,
$value
)
{
return
$value
===
$entity
->
get
(
$key
);
});
}
return
$entities
;
}
/**
* Returns an entity query instance.
*
...
...
core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php
View file @
4c834544
...
...
@@ -6,6 +6,7 @@
*/
namespace
Drupal\Core\Entity
;
use
Drupal\Core\Entity\Query\QueryInterface
;
/**
* A base entity storage controller class.
...
...
@@ -178,4 +179,30 @@ protected function postLoad(array &$queried_entities) {
}
}
/**
* Builds an entity query.
*
* @param \Drupal\Core\Entity\Query\QueryInterface $entity_query
* EntityQuery instance.
* @param array $values
* An associative array of properties of the entity, where the keys are the
* property names and the values are the values those properties must have.
*/
protected
function
buildPropertyQuery
(
QueryInterface
$entity_query
,
array
$values
)
{
foreach
(
$values
as
$name
=>
$value
)
{
$entity_query
->
condition
(
$name
,
$value
);
}
}
/**
* {@inheritdoc}
*/
public
function
loadByProperties
(
array
$values
=
array
())
{
// Build a query to fetch the entity IDs.
$entity_query
=
\
Drupal
::
entityQuery
(
$this
->
entityType
);
$this
->
buildPropertyQuery
(
$entity_query
,
$values
);
$result
=
$entity_query
->
execute
();
return
$result
?
$this
->
loadMultiple
(
$result
)
:
array
();
}
}
core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php
View file @
4c834544
...
...
@@ -417,24 +417,7 @@ public function deleteRevision($revision_id) {
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::loadByProperties().
*/
public
function
loadByProperties
(
array
$values
=
array
())
{
// Build a query to fetch the entity IDs.
$entity_query
=
\
Drupal
::
entityQuery
(
$this
->
entityType
);
$this
->
buildPropertyQuery
(
$entity_query
,
$values
);
$result
=
$entity_query
->
execute
();
return
$result
?
$this
->
loadMultiple
(
$result
)
:
array
();
}
/**
* Builds an entity query.
*
* @param \Drupal\Core\Entity\Query\QueryInterface $entity_query
* EntityQuery instance.
* @param array $values
* An associative array of properties of the entity, where the keys are the
* property names and the values are the values those properties must have.
* {@inheritdoc}
*/
protected
function
buildPropertyQuery
(
QueryInterface
$entity_query
,
array
$values
)
{
if
(
$this
->
dataTable
)
{
...
...
@@ -452,9 +435,7 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value
}
}
foreach
(
$values
as
$name
=>
$value
)
{
$entity_query
->
condition
(
$name
,
$value
);
}
parent
::
buildPropertyQuery
(
$entity_query
,
$values
);
}
/**
...
...
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