diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 0bbbf28..57e470d 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -5,6 +5,7 @@ * Used to aggregate syndicated content (RSS, RDF, and Atom). */ +use Drupal\aggregator\Entity\Feed; use Drupal\aggregator\FeedInterface; use Drupal\Component\Plugin\Exception\PluginException; @@ -265,9 +266,12 @@ function aggregator_refresh(FeedInterface $feed) { * * @return \Drupal\aggregator\FeedInterface * An object describing the feed. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\aggregator\Entity\Feed::load(). */ function aggregator_feed_load($fid) { - return entity_load('aggregator_feed', $fid); + return Feed::load($fid); } /** diff --git a/core/modules/block/block.module b/core/modules/block/block.module index f54f958..878b19c 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -6,6 +6,7 @@ */ use Drupal\block\BlockInterface; +use Drupal\block\Entity\Block; use Drupal\Component\Plugin\Exception\PluginException; use Symfony\Cmf\Component\Routing\RouteObjectInterface; @@ -321,9 +322,12 @@ function block_list($region) { * * @return \Drupal\block\Entity\Block * The loaded block object. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\block\Entity\Block::load(). */ function block_load($entity_id) { - return entity_load('block', $entity_id); + return Block::load($entity_id); } /** diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index bfe5a39..edbc366 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -58,9 +58,12 @@ function custom_block_theme($existing, $type, $theme, $path) { * * @return \Drupal\custom_block\Entity\CustomBlockType|null * A CustomBlockType object or NULL if the requested $id does not exist. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\custom_block\Entity\CustomBlockType::load(). */ function custom_block_type_load($id) { - return entity_load('custom_block_type', $id); + return CustomBlockType::load($id); } /** @@ -71,9 +74,12 @@ function custom_block_type_load($id) { * * @return \Drupal\custom_block\Entity\CustomBlock|null * A CustomBlock object or NULL if the requested $id does not exist. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\custom_block\Entity\CustomBlock::load(). */ function custom_block_load($id) { - return entity_load('custom_block', $id); + return CustomBlock::load($id); } /** diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module index be06abd..f2212ad 100644 --- a/core/modules/breakpoint/breakpoint.module +++ b/core/modules/breakpoint/breakpoint.module @@ -49,9 +49,12 @@ function breakpoint_help($path, $arg) { * * @todo Remove this in a follow-up issue. * @see http://drupal.org/node/1798214 + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\breakpoint\Entity\Breakpoint::load(). */ function breakpoint_load($id) { - return entity_load('breakpoint', $id); + return Breakpoint::load($id); } /** @@ -62,7 +65,7 @@ function breakpoint_load($id) { */ function breakpoint_group_select_options() { $options = array(); - $breakpoint_groups = entity_load_multiple('breakpoint_group'); + $breakpoint_groups = BreakpointGroup::loadMultiple(); foreach ($breakpoint_groups as $breakpoint_group) { $options[$breakpoint_group->id()] = $breakpoint_group->label(); } @@ -78,7 +81,7 @@ function breakpoint_group_select_options() { */ function breakpoint_select_options() { $options = array(); - $breakpoints = entity_load_multiple('breakpoint'); + $breakpoints = Breakpoint::loadMultiple(); foreach ($breakpoints as $breakpoint) { $options[$breakpoint->id()] = $breakpoint->label() . ' (' . $breakpoint->source . ' - ' . $breakpoint->sourceType . ') [' . $breakpoint->mediaQuery . ']'; } diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php index 738f3b2..7ee4241 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php @@ -140,7 +140,7 @@ public function isValid() { */ public function addBreakpointFromMediaQuery($name, $media_query) { // Use the existing breakpoint if it exists. - $breakpoint = entity_load('breakpoint', $this->sourceType . '.' . $this->name . '.' . $name); + $breakpoint = Breakpoint::load($this->sourceType . '.' . $this->name . '.' . $name); if (!$breakpoint) { // Build a new breakpoint. $breakpoint = entity_create('breakpoint', array( @@ -174,7 +174,7 @@ public function addBreakpoints($breakpoints) { public function getBreakpoints() { if (empty($this->breakpoints)) { foreach ($this->breakpoint_ids as $breakpoint_id) { - $breakpoint = breakpoint_load($breakpoint_id); + $breakpoint = Breakpoint::load($breakpoint_id); if ($breakpoint) { $this->breakpoints[$breakpoint_id] = $breakpoint; } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 07b177e..1ebafa8 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -11,6 +11,7 @@ */ use Drupal\comment\CommentInterface; +use Drupal\comment\Entity\Comment; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Entity\EntityInterface; @@ -1098,8 +1099,8 @@ function comment_user_predelete($account) { /** * Loads comment entities from the database. * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use entity_load_multiple('comment', $cids). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\comment\Entity\Comment::loadMultiple(). * * @param array $cids * (optional) An array of entity IDs. If omitted, all entities are loaded. @@ -1113,7 +1114,10 @@ function comment_user_predelete($account) { * @see \Drupal\Core\Entity\Query\QueryInterface */ function comment_load_multiple(array $cids = NULL, $reset = FALSE) { - return entity_load_multiple('comment', $cids, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('comment')->resetCache($cids); + } + return Comment::loadMultiple($cids); } /** @@ -1126,9 +1130,15 @@ function comment_load_multiple(array $cids = NULL, $reset = FALSE) { * * @return \Drupal\comment\CommentInterface * The comment object. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\comment\Entity\Comment::load(). */ function comment_load($cid, $reset = FALSE) { - return entity_load('comment', $cid, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('comment')->resetCache(array($cid)); + } + return Comment::load($cid); } /** diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 3894e8f..d446c5d 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -5,6 +5,8 @@ * Enables the use of personal and site-wide contact forms. */ +use Drupal\contact\Entity\Category; + /** * Implements hook_help(). */ @@ -153,9 +155,12 @@ function contact_field_extra_fields() { * * @return \Drupal\contact\Entity\Category|null * A Category object or NULL if the requested $id does not exist. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\contact\Entity\Category::load(). */ function contact_category_load($id) { - return entity_load('contact_category', $id); + return Category::load($id); } /** diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 67e5452..18fec78 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -80,13 +80,19 @@ function file_element_info() { * @return array * An array of file entities, indexed by fid. * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\file\Entity\File::loadMultiple(). + * * @see hook_file_load() * @see file_load() * @see entity_load() * @see \Drupal\Core\Entity\Query\EntityQueryInterface */ function file_load_multiple(array $fids = NULL, $reset = FALSE) { - return entity_load_multiple('file', $fids, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('file')->resetCache($fids); + } + return File::loadMultiple($fids); } /** @@ -100,11 +106,17 @@ function file_load_multiple(array $fids = NULL, $reset = FALSE) { * @return \Drupal\file\FileInterface * A file entity or NULL if the file was not found. * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\file\Entity\File::load(). + * * @see hook_file_load() * @see file_load_multiple() */ function file_load($fid, $reset = FALSE) { - return entity_load('file', $fid, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('file')->resetCache(array($fid)); + } + return File::load($fid); } /** diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 472cad4..aaa3deb 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -12,6 +12,7 @@ use Drupal\file\Entity\File; use Drupal\field\FieldConfigInterface; use Drupal\field\FieldInstanceConfigInterface; +use Drupal\image\Entity\ImageStyle; /** * Image style constant for user presets in the database. @@ -265,9 +266,12 @@ function image_path_flush($path) { * * @param string $name * The ID of the ImageStyle object to load. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\image\Entity\ImageStyle::load(). */ function image_style_load($name) { - return entity_load('image_style', $name); + return ImageStyle::load($name); } /** diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index fa5d8c5..1572797 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -130,9 +130,12 @@ function menu_theme() { * The unique name of a custom menu to load. * @return * Array defining the custom menu, or NULL if the menu doesn't exist. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\system\Entity\Menu::load(). */ function menu_load($menu_name) { - return entity_load('menu', $menu_name); + return Menu::load($menu_name); } /** diff --git a/core/modules/menu_link/menu_link.module b/core/modules/menu_link/menu_link.module index dc86f4c..c68e395 100644 --- a/core/modules/menu_link/menu_link.module +++ b/core/modules/menu_link/menu_link.module @@ -46,9 +46,15 @@ function menu_link_uri(MenuLink $menu_link) { * * @return \Drupal\menu_link\Entity\MenuLink|null * A menu link entity, or NULL if there is no entity with the given ID. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\menu_link\Entity\MenuLink::load(). */ function menu_link_load($mlid = NULL, $reset = FALSE) { - return entity_load('menu_link', $mlid, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('menu_link')->resetCache(array($mlid)); + } + return MenuLink::load($mlid); } /** @@ -64,9 +70,15 @@ function menu_link_load($mlid = NULL, $reset = FALSE) { * * @see menu_link_load() * @see entity_load_multiple() + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\menu_link\Entity\MenuLink::loadMultiple(). */ function menu_link_load_multiple(array $mlids = NULL, $reset = FALSE) { - return entity_load_multiple('menu_link', $mlids, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('menu_link')->resetCache($mlids); + } + return MenuLink::loadMultiple($mlids); } /** diff --git a/core/modules/node/node.module b/core/modules/node/node.module index ba5151f..d365a8a 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -14,6 +14,8 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Database\Query\SelectInterface; +use Drupal\node\Entity\Node; +use Drupal\node\Entity\NodeType; use Drupal\node\NodeTypeInterface; use Drupal\node\NodeInterface; use Drupal\Core\Entity\EntityInterface; @@ -301,10 +303,13 @@ function node_mark($nid, $timestamp) { * @return array * An array of node type entities, keyed by ID. * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\node\Entity\NodeType::loadMultiple(). + * * @see node_type_load() */ function node_type_get_types() { - return entity_load_multiple('node_type'); + return NodeType::loadMultiple(); } /** @@ -374,9 +379,12 @@ function node_type_get_description(NodeTypeInterface $node_type) { * * @return \Drupal\node\NodeTypeInterface * A node type object or NULL if $name does not exist. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\node\Entity\NodeType::load(). */ function node_type_load($name) { - return entity_load('node_type', $name); + return NodeType::load($name); } /** @@ -511,11 +519,17 @@ function node_type_update_nodes($old_id, $new_id) { * @return \Drupal\node\NodeInterface[] * An array of node entities indexed by nid. * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\node\Entity\Node::loadMultiple(). + * * @see entity_load_multiple() * @see \Drupal\Core\Entity\Query\EntityQueryInterface */ function node_load_multiple(array $nids = NULL, $reset = FALSE) { - return entity_load_multiple('node', $nids, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('node')->resetCache($nids); + } + return Node::loadMultiple($nids); } /** @@ -529,9 +543,15 @@ function node_load_multiple(array $nids = NULL, $reset = FALSE) { * * @return \Drupal\node\NodeInterface|null * A fully-populated node entity, or NULL if the node is not found. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\node\Entity\Node::load(). */ function node_load($nid = NULL, $reset = FALSE) { - return entity_load('node', $nid, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('node')->resetCache(array($nid)); + } + return Node::load($nid); } /** diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index 6865a81..7fdbcd2 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -5,6 +5,7 @@ * Responsive image display formatter for image fields. */ +use Drupal\breakpoint\Entity\Breakpoint; use Drupal\responsive_image\Entity\ResponsiveImageMapping; use \Drupal\Core\Template\Attribute; @@ -92,13 +93,15 @@ function responsive_image_menu_link_defaults() { * @return \Drupal\responsive_image\ResponsiveImageMappingInterface * The entity object, or NULL if there is no entity with the given id. * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\responsive_image\Entity\ResponsiveImageMapping::load(). + * * @todo Needed for menu_callback * * @see http://drupal.org/node/1798214 - * */ function responsive_image_mapping_load($id) { - return entity_load('responsive_image_mapping', $id); + return ResponsiveImageMapping::load($id); } /** @@ -230,7 +233,7 @@ function theme_responsive_image($variables) { // All breakpoints and multipliers. foreach ($variables['breakpoints'] as $breakpoint_name => $multipliers) { - $breakpoint = breakpoint_load($breakpoint_name); + $breakpoint = Breakpoint::load($breakpoint_name); if ($breakpoint) { $new_sources = array(); foreach ($multipliers as $multiplier => $image_style) { diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 95dd6de..6a9a427 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -7,6 +7,7 @@ use Drupal\Core\Routing\UrlMatcher; use Drupal\Core\Url; +use Drupal\shortcut\Entity\ShortcutSet; use Drupal\shortcut\ShortcutSetInterface; use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\HttpFoundation\Request; @@ -144,9 +145,12 @@ function shortcut_set_switch_access($account = NULL) { * - 'id': The internal name of the shortcut set. * - 'label': The title of the shortcut set. * If the shortcut set does not exist, the function returns NULL. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\shortcut\Entity\ShortcutSet::load(). */ function shortcut_set_load($id) { - return entity_load('shortcut_set', $id); + return ShortcutSet::load($id); } /** diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 62952af..faf41ee 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -650,8 +650,8 @@ function taxonomy_term_load_multiple_by_name($name, $vocabulary = NULL) { * @see entity_load_multiple() * @see \Drupal\Core\Entity\Query\EntityQueryInterface * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use entity_load_multiple('taxonomy_term', $tids). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\taxonomy\Entity\Term::loadMultiple(). * * @param array $tids * (optional) An array of entity IDs. If omitted, all entities are loaded. @@ -661,7 +661,7 @@ function taxonomy_term_load_multiple_by_name($name, $vocabulary = NULL) { * found, an empty array is returned. */ function taxonomy_term_load_multiple(array $tids = NULL) { - return entity_load_multiple('taxonomy_term', $tids); + return Term::loadMultiple($tids); } /** @@ -673,8 +673,8 @@ function taxonomy_term_load_multiple(array $tids = NULL) { * * @see entity_load_multiple() * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use entity_load_multiple('taxonomy_vocabulary', $vids). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\taxonomy\Entity\Vocabulary::loadMultiple(). * * @param array $vids * (optional) An array of entity IDs. If omitted, all entities are loaded. @@ -683,14 +683,14 @@ function taxonomy_term_load_multiple(array $tids = NULL) { * An array of vocabulary objects, indexed by vid. */ function taxonomy_vocabulary_load_multiple(array $vids = NULL) { - return entity_load_multiple('taxonomy_vocabulary', $vids); + return Vocabulary::loadMultiple($vids); } /** * Return the taxonomy vocabulary entity matching a vocabulary ID. * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use entity_load('taxonomy_vocabulary', $vid). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\taxonomy\Entity\Vocabulary::load(). * * @param int $vid * The vocabulary's ID. @@ -700,14 +700,14 @@ function taxonomy_vocabulary_load_multiple(array $vids = NULL) { * statically cached. */ function taxonomy_vocabulary_load($vid) { - return entity_load('taxonomy_vocabulary', $vid); + return Vocabulary::load($vid); } /** * Return the taxonomy term entity matching a term ID. * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use entity_load('taxonomy_term', $tid). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\taxonomy\Entity\Term::load(). * * @param $tid * A term's ID @@ -720,7 +720,7 @@ function taxonomy_term_load($tid) { if (!is_numeric($tid)) { return NULL; } - return entity_load('taxonomy_term', $tid); + return Term::load($tid); } /** diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 6330fcb..4b9c3ae 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -6,6 +6,7 @@ use Drupal\Core\Session\AccountInterface; use \Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\file\Entity\File; +use Drupal\user\Entity\Role; use Drupal\user\Entity\User; use Drupal\user\UserInterface; use Drupal\user\RoleInterface; @@ -261,9 +262,15 @@ function user_field_extra_fields() { * @see user_load_by_mail() * @see user_load_by_name() * @see \Drupal\Core\Entity\Query\QueryInterface + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\user\Entity\User::loadMultiple(). */ function user_load_multiple(array $uids = NULL, $reset = FALSE) { - return entity_load_multiple('user', $uids, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('user')->resetCache($uids); + } + return User::loadMultiple($uids); } /** @@ -288,10 +295,16 @@ function user_load_multiple(array $uids = NULL, $reset = FALSE) { * A fully-loaded user object upon successful user load, or NULL if the user * cannot be loaded. * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\user\Entity\User::load(). + * * @see user_load_multiple() */ function user_load($uid, $reset = FALSE) { - return entity_load('user', $uid, $reset); + if ($reset) { + \Drupal::entityManager()->getStorageController('user')->resetCache(array($uid)); + } + return User::load($uid); } /** @@ -1342,9 +1355,12 @@ function user_roles($membersonly = FALSE, $permission = NULL) { * @return * A fully-loaded role object if a role with the given ID exists, or NULL * otherwise. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0. + * Use \Drupal\user\Entity\Role::load(). */ function user_role_load($rid) { - return entity_load('user_role', $rid); + return Role::load($rid); } /**