Commit bea3588b authored by alexpott's avatar alexpott

Issue #1957148 by damiankloip | Berdir: Replace entity_query() with Drupal::entityQuery().

parent 2fbb2642
...@@ -735,40 +735,6 @@ function entity_get_render_display(EntityInterface $entity, $view_mode) { ...@@ -735,40 +735,6 @@ function entity_get_render_display(EntityInterface $entity, $view_mode) {
return $display; return $display;
} }
/**
* Returns the entity query object for this entity type.
*
* @param $entity_type
* The entity type, e.g. node, for which the query object should be
* returned.
* @param $conjunction
* AND if all conditions in the query need to apply, OR if any of them is
* enough. Optional, defaults to AND.
*
* @return \Drupal\Core\Entity\Query\QueryInterface
* The query object that can query the given entity type.
*/
function entity_query($entity_type, $conjunction = 'AND') {
return drupal_container()->get('entity.query')->get($entity_type, $conjunction);
}
/**
* Returns the entity query aggregate object for this entity type.
*
* @param $entity_type
* The entity type, e.g. node, for which the query object should be
* returned.
* @param $conjunction
* AND if all conditions in the query need to apply, OR if any of them is
* enough. Optional, defaults to AND.
*
* @return \Drupal\Core\Entity\Query\QueryInterface
* The query object that can query the given entity type.
*/
function entity_query_aggregate($entity_type, $conjunction = 'AND') {
return drupal_container()->get('entity.query')->getAggregate($entity_type, $conjunction);
}
/** /**
* Generic access callback for entity pages. * Generic access callback for entity pages.
* *
......
...@@ -1276,7 +1276,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = ...@@ -1276,7 +1276,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
// Collect all the links set to be expanded, and then add all of // Collect all the links set to be expanded, and then add all of
// their children to the list as well. // their children to the list as well.
do { do {
$query = entity_query('menu_link') $query = Drupal::entityQuery('menu_link')
->condition('menu_name', $menu_name) ->condition('menu_name', $menu_name)
->condition('expanded', 1) ->condition('expanded', 1)
->condition('has_children', 1) ->condition('has_children', 1)
...@@ -1371,7 +1371,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) { ...@@ -1371,7 +1371,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
} }
if (!isset($trees[$tree_cid])) { if (!isset($trees[$tree_cid])) {
$query = entity_query('menu_link'); $query = Drupal::entityQuery('menu_link');
for ($i = 1; $i <= MENU_MAX_DEPTH; $i++) { for ($i = 1; $i <= MENU_MAX_DEPTH; $i++) {
$query->sort('p' . $i, 'ASC'); $query->sort('p' . $i, 'ASC');
} }
...@@ -2830,7 +2830,7 @@ function _menu_navigation_links_rebuild($menu) { ...@@ -2830,7 +2830,7 @@ function _menu_navigation_links_rebuild($menu) {
} }
// Find any item whose router path does not exist any more. // Find any item whose router path does not exist any more.
$query = entity_query('menu_link') $query = Drupal::entityQuery('menu_link')
->condition('router_path', $paths, 'NOT IN') ->condition('router_path', $paths, 'NOT IN')
->condition('external', 0) ->condition('external', 0)
->condition('updated', 0) ->condition('updated', 0)
...@@ -2857,7 +2857,7 @@ function _menu_navigation_links_rebuild($menu) { ...@@ -2857,7 +2857,7 @@ function _menu_navigation_links_rebuild($menu) {
function menu_load_links($menu_name) { function menu_load_links($menu_name) {
$links = array(); $links = array();
$query = entity_query('menu_link') $query = Drupal::entityQuery('menu_link')
->condition('menu_name', $menu_name) ->condition('menu_name', $menu_name)
// Order by weight so as to be helpful for menus that are only one level // Order by weight so as to be helpful for menus that are only one level
// deep. // deep.
......
...@@ -292,6 +292,23 @@ public static function entityQuery($entity_type, $conjunction = 'AND') { ...@@ -292,6 +292,23 @@ public static function entityQuery($entity_type, $conjunction = 'AND') {
return static::$container->get('entity.query')->get($entity_type, $conjunction); return static::$container->get('entity.query')->get($entity_type, $conjunction);
} }
/**
* Returns the entity query aggregate object for this entity type.
*
* @param $entity_type
* The entity type, e.g. node, for which the query object should be
* returned.
* @param $conjunction
* AND if all conditions in the query need to apply, OR if any of them is
* enough. Optional, defaults to AND.
*
* @return \Drupal\Core\Entity\Query\QueryInterface
* The query object that can query the given entity type.
*/
public static function entityQueryAggregate($entity_type, $conjunction = 'AND') {
return static::$container->get('entity.query')->getAggregate($entity_type, $conjunction);
}
/** /**
* Returns the flood instance. * Returns the flood instance.
* *
......
...@@ -290,7 +290,7 @@ public function deleteRevision($revision_id) { ...@@ -290,7 +290,7 @@ public function deleteRevision($revision_id) {
*/ */
public function loadByProperties(array $values = array()) { public function loadByProperties(array $values = array()) {
// Build a query to fetch the entity IDs. // Build a query to fetch the entity IDs.
$entity_query = entity_query($this->entityType); $entity_query = \Drupal::entityQuery($this->entityType);
$this->buildPropertyQuery($entity_query, $values); $this->buildPropertyQuery($entity_query, $values);
$result = $entity_query->execute(); $result = $entity_query->execute();
return $result ? $this->load($result) : array(); return $result ? $this->load($result) : array();
......
...@@ -37,7 +37,7 @@ public function getEntityType(); ...@@ -37,7 +37,7 @@ public function getEntityType();
* For example, to find all entities containing both the Turkish 'merhaba' * For example, to find all entities containing both the Turkish 'merhaba'
* and the Polish 'siema' within a 'greetings' text field: * and the Polish 'siema' within a 'greetings' text field:
* @code * @code
* $entity_ids = entity_query($entity_type) * $entity_ids = Drupal::entityQuery($entity_type)
* ->condition('greetings', 'merhaba', '=', 'tr'); * ->condition('greetings', 'merhaba', '=', 'tr');
* ->condition('greetings.value', 'siema', '=', 'pl'); * ->condition('greetings.value', 'siema', '=', 'pl');
* ->execute(); * ->execute();
...@@ -198,7 +198,7 @@ public function conditionGroupFactory($conjunction = 'AND'); ...@@ -198,7 +198,7 @@ public function conditionGroupFactory($conjunction = 'AND');
* field containing 'shape' and 'color' columns. To find all drawings * field containing 'shape' and 'color' columns. To find all drawings
* containing both a red triangle and a blue circle: * containing both a red triangle and a blue circle:
* @code * @code
* $query = entity_query('drawing'); * $query = Drupal::entityQuery('drawing');
* $group = $query->andConditionGroup() * $group = $query->andConditionGroup()
* ->condition('figures.color', 'red') * ->condition('figures.color', 'red')
* ->condition('figures.shape', 'triangle'); * ->condition('figures.shape', 'triangle');
...@@ -221,7 +221,7 @@ public function andConditionGroup(); ...@@ -221,7 +221,7 @@ public function andConditionGroup();
* containing 'building_type' and 'color' columns. To find all green and * containing 'building_type' and 'color' columns. To find all green and
* red bikesheds: * red bikesheds:
* @code * @code
* $query = entity_query('map'); * $query = Drupal::entityQuery('map');
* $group = $query->orConditionGroup() * $group = $query->orConditionGroup()
* ->condition('attributes.color', 'red') * ->condition('attributes.color', 'red')
* ->condition('attributes.color', 'green'); * ->condition('attributes.color', 'green');
......
...@@ -67,7 +67,7 @@ function custom_block_type_delete_form($form, &$form_state, CustomBlockType $blo ...@@ -67,7 +67,7 @@ function custom_block_type_delete_form($form, &$form_state, CustomBlockType $blo
$message = t('Are you sure you want to delete %label?', array('%label' => $block_type->label())); $message = t('Are you sure you want to delete %label?', array('%label' => $block_type->label()));
$blocks = entity_query('custom_block')->condition('type', $block_type->id())->execute(); $blocks = Drupal::entityQuery('custom_block')->condition('type', $block_type->id())->execute();
if (!empty($blocks)) { if (!empty($blocks)) {
drupal_set_title($message, PASS_THROUGH); drupal_set_title($message, PASS_THROUGH);
$caption = '<p>' . format_plural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $block_type->label())) . '</p>'; $caption = '<p>' . format_plural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $block_type->label())) . '</p>';
......
...@@ -57,7 +57,7 @@ public function testHookCustomBlockLoad() { ...@@ -57,7 +57,7 @@ public function testHookCustomBlockLoad() {
// Now, as part of the same page request, load a set of custom_blocks that contain // Now, as part of the same page request, load a set of custom_blocks that contain
// both basic and other bundle, and make sure the parameters passed to // both basic and other bundle, and make sure the parameters passed to
// custom_block_test_custom_block_load() are correctly updated. // custom_block_test_custom_block_load() are correctly updated.
$custom_blocks = entity_load_multiple('custom_block', entity_query('custom_block')->execute(), TRUE); $custom_blocks = entity_load_multiple('custom_block', \Drupal::entityQuery('custom_block')->execute(), TRUE);
$loaded_custom_block = end($custom_blocks); $loaded_custom_block = end($custom_blocks);
$this->assertEqual($loaded_custom_block->custom_block_test_loaded_ids, array( $this->assertEqual($loaded_custom_block->custom_block_test_loaded_ids, array(
$custom_block1->id->value, $custom_block1->id->value,
......
...@@ -39,7 +39,7 @@ public function testPageEdit() { ...@@ -39,7 +39,7 @@ public function testPageEdit() {
$this->drupalPost('block/add/basic', $edit, t('Save')); $this->drupalPost('block/add/basic', $edit, t('Save'));
// Check that the block exists in the database. // Check that the block exists in the database.
$blocks = entity_query('custom_block')->condition('info', $edit['info'])->execute(); $blocks = \Drupal::entityQuery('custom_block')->condition('info', $edit['info'])->execute();
$block = entity_load('custom_block', reset($blocks)); $block = entity_load('custom_block', reset($blocks));
$this->assertTrue($block, 'Custom block found in database.'); $this->assertTrue($block, 'Custom block found in database.');
......
...@@ -267,7 +267,7 @@ public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { ...@@ -267,7 +267,7 @@ public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$target_type = $this->field['settings']['target_type']; $target_type = $this->field['settings']['target_type'];
$entity_info = entity_get_info($target_type); $entity_info = entity_get_info($target_type);
$query = entity_query($target_type); $query = \Drupal::entityQuery($target_type);
if (!empty($this->instance['settings']['handler_settings']['target_bundles'])) { if (!empty($this->instance['settings']['handler_settings']['target_bundles'])) {
$query->condition($entity_info['entity_keys']['bundle'], $this->instance['settings']['handler_settings']['target_bundles'], 'IN'); $query->condition($entity_info['entity_keys']['bundle'], $this->instance['settings']['handler_settings']['target_bundles'], 'IN');
} }
......
...@@ -78,7 +78,7 @@ public function testAutoCreate() { ...@@ -78,7 +78,7 @@ public function testAutoCreate() {
$new_title = $this->randomName(); $new_title = $this->randomName();
// Assert referenced node does not exist. // Assert referenced node does not exist.
$base_query = entity_query('node'); $base_query = \Drupal::entityQuery('node');
$base_query $base_query
->condition('type', $this->referenced_type) ->condition('type', $this->referenced_type)
->condition('title', $new_title); ->condition('title', $new_title);
...@@ -100,7 +100,7 @@ public function testAutoCreate() { ...@@ -100,7 +100,7 @@ public function testAutoCreate() {
$referenced_nid = key($result); $referenced_nid = key($result);
// Assert the referenced node is associated with referencing node. // Assert the referenced node is associated with referencing node.
$result = entity_query('node') $result = \Drupal::entityQuery('node')
->condition('type', $this->referencing_type) ->condition('type', $this->referencing_type)
->execute(); ->execute();
......
...@@ -854,7 +854,7 @@ function field_purge_batch($batch_size) { ...@@ -854,7 +854,7 @@ function field_purge_batch($batch_size) {
// Retrieve all deleted field instances. We cannot use field_info_instances() // Retrieve all deleted field instances. We cannot use field_info_instances()
// because that function does not return deleted instances. // because that function does not return deleted instances.
$instances = field_read_instances(array('deleted' => 1), array('include_deleted' => 1)); $instances = field_read_instances(array('deleted' => 1), array('include_deleted' => 1));
$factory = drupal_container()->get('entity.query'); $factory = Drupal::service('entity.query');
$info = entity_get_info(); $info = entity_get_info();
foreach ($instances as $instance) { foreach ($instances as $instance) {
$entity_type = $instance['entity_type']; $entity_type = $instance['entity_type'];
......
...@@ -1005,7 +1005,7 @@ function field_get_items(EntityInterface $entity, $field_name, $langcode = NULL) ...@@ -1005,7 +1005,7 @@ function field_get_items(EntityInterface $entity, $field_name, $langcode = NULL)
function field_has_data($field) { function field_has_data($field) {
$field = field_info_field_by_id($field['id']); $field = field_info_field_by_id($field['id']);
$columns = array_keys($field['columns']); $columns = array_keys($field['columns']);
$factory = drupal_container()->get('entity.query'); $factory = Drupal::service('entity.query');
foreach ($field['bundles'] as $entity_type => $bundle) { foreach ($field['bundles'] as $entity_type => $bundle) {
// Entity Query throws an exception if there is no base table. // Entity Query throws an exception if there is no base table.
$entity_info = entity_get_info($entity_type); $entity_info = entity_get_info($entity_type);
......
...@@ -151,7 +151,7 @@ function testDeleteFieldInstance() { ...@@ -151,7 +151,7 @@ function testDeleteFieldInstance() {
$bundle = reset($this->bundles); $bundle = reset($this->bundles);
$field = reset($this->fields); $field = reset($this->fields);
$field_name = $field['field_name']; $field_name = $field['field_name'];
$factory = drupal_container()->get('entity.query'); $factory = \Drupal::service('entity.query');
// There are 10 entities of this bundle. // There are 10 entities of this bundle.
$found = $factory->get('test_entity') $found = $factory->get('test_entity')
...@@ -223,7 +223,7 @@ function testPurgeInstance() { ...@@ -223,7 +223,7 @@ function testPurgeInstance() {
field_purge_batch($batch_size); field_purge_batch($batch_size);
// There are $count deleted entities left. // There are $count deleted entities left.
$found = entity_query('test_entity') $found = \Drupal::entityQuery('test_entity')
->condition('fttype', $bundle) ->condition('fttype', $bundle)
->condition($field['field_name'] . '.deleted', 1) ->condition($field['field_name'] . '.deleted', 1)
->execute(); ->execute();
......
...@@ -549,7 +549,7 @@ private function getStandardMenuLink() { ...@@ -549,7 +549,7 @@ private function getStandardMenuLink() {
$mlid = 0; $mlid = 0;
// Retrieve menu link id of the Log out menu link, which will always be on // Retrieve menu link id of the Log out menu link, which will always be on
// the front page. // the front page.
$query = entity_query('menu_link') $query = \Drupal::entityQuery('menu_link')
->condition('module', 'system') ->condition('module', 'system')
->condition('router_path', 'user/logout'); ->condition('router_path', 'user/logout');
$result = $query->execute(); $result = $query->execute();
......
...@@ -74,7 +74,7 @@ function menu_overview_form($form, &$form_state) { ...@@ -74,7 +74,7 @@ function menu_overview_form($form, &$form_state) {
$form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/menu.admin.css'); $form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/menu.admin.css');
$links = array(); $links = array();
$query = entity_query('menu_link') $query = Drupal::entityQuery('menu_link')
->condition('menu_name', $form_state['menu']->id()); ->condition('menu_name', $form_state['menu']->id());
for ($i = 1; $i <= MENU_MAX_DEPTH; $i++) { for ($i = 1; $i <= MENU_MAX_DEPTH; $i++) {
$query->sort('p' . $i, 'ASC'); $query->sort('p' . $i, 'ASC');
...@@ -379,7 +379,7 @@ function menu_edit_menu_name_exists($value) { ...@@ -379,7 +379,7 @@ function menu_edit_menu_name_exists($value) {
$custom_exists = entity_load('menu', $value); $custom_exists = entity_load('menu', $value);
// 'menu-' is added to the menu name to avoid name-space conflicts. // 'menu-' is added to the menu name to avoid name-space conflicts.
$value = 'menu-' . $value; $value = 'menu-' . $value;
$link_exists = entity_query('menu_link')->condition('menu_name', $value)->range(0,1)->count()->execute(); $link_exists = Drupal::entityQuery('menu_link')->condition('menu_name', $value)->range(0,1)->count()->execute();
return $custom_exists || $link_exists; return $custom_exists || $link_exists;
} }
......
...@@ -210,7 +210,7 @@ function menu_enable() { ...@@ -210,7 +210,7 @@ function menu_enable() {
$link->link_title = $menu->label(); $link->link_title = $menu->label();
$link->link_path = 'admin/structure/menu/manage/' . $menu->id(); $link->link_path = 'admin/structure/menu/manage/' . $menu->id();
$query = entity_query('menu_link') $query = Drupal::entityQuery('menu_link')
->condition('link_path', $link->link_path) ->condition('link_path', $link->link_path)
->condition('plid', $link->plid); ->condition('plid', $link->plid);
$result = $query->execute(); $result = $query->execute();
...@@ -467,7 +467,7 @@ function menu_node_save(EntityInterface $node) { ...@@ -467,7 +467,7 @@ function menu_node_save(EntityInterface $node) {
*/ */
function menu_node_predelete(EntityInterface $node) { function menu_node_predelete(EntityInterface $node) {
// Delete all menu module links that point to this node. // Delete all menu module links that point to this node.
$query = entity_query('menu_link') $query = Drupal::entityQuery('menu_link')
->condition('link_path', 'node/' . $node->nid) ->condition('link_path', 'node/' . $node->nid)
->condition('module', 'menu'); ->condition('module', 'menu');
$result = $query->execute(); $result = $query->execute();
...@@ -490,7 +490,7 @@ function menu_node_prepare(EntityInterface $node) { ...@@ -490,7 +490,7 @@ function menu_node_prepare(EntityInterface $node) {
// Give priority to the default menu // Give priority to the default menu
$type_menus = variable_get('menu_options_' . $node->type, array('main' => 'main')); $type_menus = variable_get('menu_options_' . $node->type, array('main' => 'main'));
if (in_array($menu_name, $type_menus)) { if (in_array($menu_name, $type_menus)) {
$query = entity_query('menu_link') $query = Drupal::entityQuery('menu_link')
->condition('link_path', 'node/' . $node->nid) ->condition('link_path', 'node/' . $node->nid)
->condition('menu_name', $menu_name) ->condition('menu_name', $menu_name)
->condition('module', 'menu') ->condition('module', 'menu')
...@@ -502,7 +502,7 @@ function menu_node_prepare(EntityInterface $node) { ...@@ -502,7 +502,7 @@ function menu_node_prepare(EntityInterface $node) {
} }
// Check all allowed menus if a link does not exist in the default menu. // Check all allowed menus if a link does not exist in the default menu.
if (!$mlid && !empty($type_menus)) { if (!$mlid && !empty($type_menus)) {
$query = entity_query('menu_link') $query = Drupal::entityQuery('menu_link')
->condition('link_path', 'node/' . $node->nid) ->condition('link_path', 'node/' . $node->nid)
->condition('menu_name', array_values($type_menus), 'IN') ->condition('menu_name', array_values($type_menus), 'IN')
->condition('module', 'menu') ->condition('module', 'menu')
......
...@@ -349,7 +349,7 @@ protected function updateParentalStatus(EntityInterface $entity, $exclude = FALS ...@@ -349,7 +349,7 @@ protected function updateParentalStatus(EntityInterface $entity, $exclude = FALS
// If plid == 0, there is nothing to update. // If plid == 0, there is nothing to update.
if ($entity->plid) { if ($entity->plid) {
// Check if at least one visible child exists in the table. // Check if at least one visible child exists in the table.
$query = entity_query($this->entityType); $query = \Drupal::entityQuery($this->entityType);
$query $query
->condition('menu_name', $entity->menu_name) ->condition('menu_name', $entity->menu_name)
->condition('hidden', 0) ->condition('hidden', 0)
...@@ -433,7 +433,7 @@ protected function findParent(EntityInterface $entity, array $parent_candidates ...@@ -433,7 +433,7 @@ protected function findParent(EntityInterface $entity, array $parent_candidates
$parent = FALSE; $parent = FALSE;
$parent_path = substr($parent_path, 0, strrpos($parent_path, '/')); $parent_path = substr($parent_path, 0, strrpos($parent_path, '/'));
$query = entity_query($this->entityType); $query = \Drupal::entityQuery($this->entityType);
$query $query
->condition('mlid', $entity->id(), '<>') ->condition('mlid', $entity->id(), '<>')
->condition('module', 'system') ->condition('module', 'system')
...@@ -569,7 +569,7 @@ protected function moveChildren(EntityInterface $entity) { ...@@ -569,7 +569,7 @@ protected function moveChildren(EntityInterface $entity) {
* The unique name of a menu. * The unique name of a menu.
*/ */
public function countMenuLinks($menu_name) { public function countMenuLinks($menu_name) {
$query = entity_query($this->entityType); $query = \Drupal::entityQuery($this->entityType);
$query $query
->condition('menu_name', $menu_name) ->condition('menu_name', $menu_name)
->count(); ->count();
......
...@@ -89,7 +89,7 @@ function menu_link_delete_multiple(array $mlids, $force = FALSE, $prevent_repare ...@@ -89,7 +89,7 @@ function menu_link_delete_multiple(array $mlids, $force = FALSE, $prevent_repare
$controller = drupal_container()->get('plugin.manager.entity') $controller = drupal_container()->get('plugin.manager.entity')
->getStorageController('menu_link'); ->getStorageController('menu_link');
if (!$force) { if (!$force) {
$entity_query = entity_query('menu_link'); $entity_query = Drupal::entityQuery('menu_link');
$group = $entity_query->orConditionGroup() $group = $entity_query->orConditionGroup()
->condition('module', 'system', '<>') ->condition('module', 'system', '<>')
->condition('updated', 0, '<>'); ->condition('updated', 0, '<>');
...@@ -178,7 +178,7 @@ function menu_link_maintain($module, $op, $link_path, $link_title = NULL) { ...@@ -178,7 +178,7 @@ function menu_link_maintain($module, $op, $link_path, $link_title = NULL) {
break; break;
case 'delete': case 'delete':
$result = entity_query('menu_link')->condition('link_path', $link_path)->execute(); $result = Drupal::entityQuery('menu_link')->condition('link_path', $link_path)->execute();
if (!empty($result)) { if (!empty($result)) {
menu_link_delete_multiple($result); menu_link_delete_multiple($result);
} }
......
...@@ -154,7 +154,7 @@ function node_access_test_page() { ...@@ -154,7 +154,7 @@ function node_access_test_page() {
function node_access_entity_test_page() { function node_access_entity_test_page() {
$output = ''; $output = '';
try { try {
$result = entity_query('node') $result = Drupal::entityQuery('node')
->condition('body.value', 'A', 'STARTS_WITH') ->condition('body.value', 'A', 'STARTS_WITH')
->execute(); ->execute();
if (!empty($result)) { if (!empty($result)) {
......
...@@ -389,7 +389,7 @@ function options_field_update_forbid($field, $prior_field, $has_data) { ...@@ -389,7 +389,7 @@ function options_field_update_forbid($field, $prior_field, $has_data) {
function _options_values_in_use($field, $values) { function _options_values_in_use($field, $values) {
if ($values) { if ($values) {
$field = field_info_field_by_id($field['id']); $field = field_info_field_by_id($field['id']);
$factory = drupal_container()->get('entity.query'); $factory = Drupal::service('entity.query');
foreach ($field['bundles'] as $entity_type => $bundle) { foreach ($field['bundles'] as $entity_type => $bundle) {
$result = $factory->get($entity_type) $result = $factory->get($entity_type)
->condition($field['field_name'] . '.value', $values) ->condition($field['field_name'] . '.value', $values)
......
...@@ -115,7 +115,7 @@ function testEnableModulesInstallContainer() { ...@@ -115,7 +115,7 @@ function testEnableModulesInstallContainer() {
$this->installSchema('node', array('node_type', 'node')); $this->installSchema('node', array('node_type', 'node'));
// Perform an entity query against node. // Perform an entity query against node.
$query = entity_query('node'); $query = \Drupal::entityQuery('node');
// Disable node access checks, since User module is not enabled. // Disable node access checks, since User module is not enabled.
$query->accessCheck(FALSE); $query->accessCheck(FALSE);
$query->condition('nid', 1); $query->condition('nid', 1);
......
...@@ -533,12 +533,12 @@ function testEntityNGRollback() { ...@@ -533,12 +533,12 @@ function testEntityNGRollback() {
if (Database::getConnection()->supportsTransactions()) { if (Database::getConnection()->supportsTransactions()) {
// Check that the block does not exist in the database. // Check that the block does not exist in the database.
$ids = entity_query('entity_test')->condition('name', 'fail_insert')->execute(); $ids = \Drupal::entityQuery('entity_test')->condition('name', 'fail_insert')->execute();
$this->assertTrue(empty($ids), 'Transactions supported, and entity not found in database.'); $this->assertTrue(empty($ids), 'Transactions supported, and entity not found in database.');
} }
else { else {
// Check that the block exists in the database. // Check that the block exists in the database.
$ids = entity_query('entity_test')->condition('name', 'fail_insert')->execute(); $ids = \Drupal::entityQuery('entity_test')->condition('name', 'fail_insert')->execute();
$this->assertFalse(empty($ids), 'Transactions not supported, and entity found in database.'); $this->assertFalse(empty($ids), 'Transactions not supported, and entity found in database.');
} }
} }
......
...@@ -115,7 +115,7 @@ public function setUp() { ...@@ -115,7 +115,7 @@ public function setUp() {
$entity->save(); $entity->save();
$this->entities[] = $entity; $this->entities[] = $entity;
} }
$this->factory = drupal_container()->get('entity.query'); $this->factory = \Drupal::service('entity.query');
} }
/** /**
......
...@@ -126,7 +126,7 @@ function setUp() { ...@@ -126,7 +126,7 @@ function setUp() {
} }
$this->figures = $figures; $this->figures = $figures;
$this->greetings = $greetings; $this->greetings = $greetings;
$this->factory = drupal_container()->get('entity.query'); $this->factory = \Drupal::service('entity.query');
} }
/** /**
...@@ -459,7 +459,7 @@ protected function assertBundleOrder($order) { ...@@ -459,7 +459,7 @@ protected function assertBundleOrder($order) {
* The tags and metadata should propogate to the SQL query object. * The tags and metadata should propogate to the SQL query object.
*/ */
function testMetaData() { function