diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 112f323..8180808 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -13,6 +13,8 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; +use Drupal\Core\Entity\Exception\AmbiguousEntityClassException; +use Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException; use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException; use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; @@ -435,9 +437,9 @@ public static function loadMultiple(array $ids = NULL) { * @return string * The entity type ID. * - * @throws \Drupal\Core\Entity\AmbiguousEntityClassException + * @throws \Drupal\Core\Entity\Exception\AmbiguousEntityClassException * Thrown when multiple subclasses correspond to the called class. - * @throws \Drupal\Core\Entity\NoCorrespondingEntityClassException + * @throws \Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException * Thrown when no entity class corresponds to the called class. */ protected static function getEntityTypeFromStaticClass() { diff --git a/core/lib/Drupal/Core/Entity/AmbiguousEntityClassException.php b/core/lib/Drupal/Core/Entity/Exception/AmbiguousEntityClassException.php similarity index 87% rename from core/lib/Drupal/Core/Entity/AmbiguousEntityClassException.php rename to core/lib/Drupal/Core/Entity/Exception/AmbiguousEntityClassException.php index 3b798bf..3992bba 100644 --- a/core/lib/Drupal/Core/Entity/AmbiguousEntityClassException.php +++ b/core/lib/Drupal/Core/Entity/Exception/AmbiguousEntityClassException.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\Core\Entity\AmbiguousEntityClassException. + * Contains \Drupal\Core\Entity\Exception\AmbiguousEntityClassException. */ -namespace Drupal\Core\Entity; +namespace Drupal\Core\Entity\Exception; /** * Exception thrown if multiple subclasses exist for an entity. diff --git a/core/lib/Drupal/Core/Entity/NoCorrespondingEntityClassException.php b/core/lib/Drupal/Core/Entity/Exception/NoCorrespondingEntityClassException.php similarity index 84% rename from core/lib/Drupal/Core/Entity/NoCorrespondingEntityClassException.php rename to core/lib/Drupal/Core/Entity/Exception/NoCorrespondingEntityClassException.php index 45e4854..fae821f 100644 --- a/core/lib/Drupal/Core/Entity/NoCorrespondingEntityClassException.php +++ b/core/lib/Drupal/Core/Entity/Exception/NoCorrespondingEntityClassException.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\Core\Entity\NoCorrespondingEntityClassException. + * Contains \Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException. */ -namespace Drupal\Core\Entity; +namespace Drupal\Core\Entity\Exception; /** * Exception thrown if an entity type is not represented by a class. diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 125a1a7..92cfab7 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -110,9 +110,8 @@ function aggregator_permission() { function aggregator_cron() { $queue = \Drupal::queue('aggregator_feeds'); - $result = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh(); - foreach ($result as $fid) { - $feed = aggregator_feed_load($fid); + $ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh(); + foreach (Feed::loadMultiple($ids) as $feed) { if ($queue->createItem($feed)) { // Add timestamp to avoid queueing item more than once. $feed->setQueuedTime(REQUEST_TIME); @@ -121,12 +120,12 @@ function aggregator_cron() { } // Delete queued timestamp after 6 hours assuming the update has failed. - $result = \Drupal::entityQuery('aggregator_feed') + $ids = \Drupal::entityQuery('aggregator_feed') ->condition('queued', REQUEST_TIME - (3600 * 6), '<') ->execute(); - if ($result) { - $feeds = entity_load_multiple('aggregator_feed', $result); + if ($ids) { + $feeds = Feed::loadMultiple($ids); foreach ($feeds as $feed) { $feed->setQueuedTime(0); $feed->save(); @@ -151,22 +150,6 @@ function aggregator_queue_info() { } /** - * Loads an aggregator feed. - * - * @param int $fid - * The feed id. - * - * @return \Drupal\aggregator\FeedInterface - * An object describing the feed. - * - * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal\aggregator\Entity\Feed::load(). - */ -function aggregator_feed_load($fid) { - return Feed::load($fid); -} - -/** * Renders the HTML content safely, as allowed. * * @param $value diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php index 6a85657..f8df38a 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\aggregator\Tests; +use Drupal\aggregator\Entity\Feed; use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use Drupal\aggregator\FeedInterface; @@ -58,7 +59,7 @@ function createFeed($feed_url = NULL, array $edit = array()) { $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField(); $this->assertTrue(!empty($fid), 'The feed found in database.'); - return aggregator_feed_load($fid); + return Feed::load($fid); } /** diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/UpdateFeedItemTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/UpdateFeedItemTest.php index 8256d66..d53bdd1 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/UpdateFeedItemTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/UpdateFeedItemTest.php @@ -6,6 +6,7 @@ */ namespace Drupal\aggregator\Tests; +use Drupal\aggregator\Entity\Feed; /** * Tests functionality of updating a feed item in the Aggregator module. @@ -48,7 +49,7 @@ function testUpdateFeedItem() { $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed !name has been added.', array('!name' => $edit['title[0][value]']))); $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField(); - $feed = aggregator_feed_load($fid); + $feed = Feed::load($fid); $feed->refreshItems(); $before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(); diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 9db8b3e..6e3625e 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -6,8 +6,6 @@ */ use Drupal\block\BlockInterface; -use Drupal\block\Entity\Block; -use Drupal\Component\Plugin\Exception\PluginException; use Drupal\language\Entity\Language; use Drupal\system\Entity\Menu; use Symfony\Cmf\Component\Routing\RouteObjectInterface; @@ -301,24 +299,6 @@ function block_list($region) { } /** - * Loads a block instance. - * - * This should only be used when entity_load() cannot be used directly. - * - * @param string $entity_id - * The block ID. - * - * @return \Drupal\block\Entity\Block - * The loaded block object. - * - * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal\block\Entity\Block::load(). - */ -function block_load($entity_id) { - return Block::load($entity_id); -} - -/** * Implements hook_rebuild(). */ function block_rebuild() { diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index a03bef8..42dee44 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -5,9 +5,6 @@ * Allows the creation of custom blocks through the user interface. */ -use Drupal\custom_block\Entity\CustomBlockType; -use Drupal\custom_block\Entity\CustomBlock; - /** * Implements hook_help(). */ @@ -51,38 +48,6 @@ function custom_block_theme($existing, $type, $theme, $path) { } /** - * Loads a custom block type. - * - * @param int $id - * The ID of the custom block type to load. - * - * @return \Drupal\custom_block\Entity\CustomBlockType|null - * A CustomBlockType object or NULL if the requested $id does not exist. - * - * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal\custom_block\Entity\CustomBlockType::load(). - */ -function custom_block_type_load($id) { - return CustomBlockType::load($id); -} - -/** - * Loads a custom block. - * - * @param int $id - * The id of the custom block. - * - * @return \Drupal\custom_block\Entity\CustomBlock|null - * A CustomBlock object or NULL if the requested $id does not exist. - * - * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal\custom_block\Entity\CustomBlock::load(). - */ -function custom_block_load($id) { - return CustomBlock::load($id); -} - -/** * Implements hook_entity_type_alter(). */ function custom_block_entity_type_alter(array &$entity_types) { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index a2f3008..4471d3e 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -35,7 +35,7 @@ public function form(array $form, array &$form_state) { '#type' => 'machine_name', '#default_value' => $block_type->id(), '#machine_name' => array( - 'exists' => 'custom_block_type_load', + 'exists' => '\Drupal\custom_block\Entity\CustomBlockType::load', ), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => !$block_type->isNew(), diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php index 167014e..0ae892a 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php @@ -8,6 +8,7 @@ namespace Drupal\custom_block\Tests; use Drupal\Core\Database\Database; +use Drupal\custom_block\Entity\CustomBlock; /** * Tests creating and saving a block. @@ -180,7 +181,7 @@ public function testBlockDelete() { $url = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default'); $this->drupalPostForm($url, $instance, t('Save block')); - $block = custom_block_load(1); + $block = CustomBlock::load(1); // Test getInstances method. $this->assertEqual(1, count($block->getInstances())); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php index ff0192e..bae766a 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php @@ -8,6 +8,7 @@ namespace Drupal\custom_block\Tests; use Drupal\Core\Language\Language; +use Drupal\custom_block\Entity\CustomBlock; /** * Tests block save related functionality. @@ -63,7 +64,7 @@ public function testImport() { $this->assertEqual($block->id(), $test_id, 'Block imported using provide id'); // Test the import saved. - $block_by_id = custom_block_load($test_id); + $block_by_id = CustomBlock::load($test_id); $this->assertTrue($block_by_id, 'Custom block load by block ID.'); $this->assertIdentical($block_by_id->body->value, $block_array['body']['value']); } @@ -93,7 +94,7 @@ public function testDeterminingChanges() { $this->assertEqual($block->getChangedTime(), 979534800, 'Saving a custom block uses "changed" timestamp set in presave hook.'); // Test the static block load cache to be cleared. - $block = custom_block_load($block->id()); + $block = CustomBlock::load($block->id()); $this->assertEqual($block->label(), 'updated_presave', 'Static cache has been cleared.'); } diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 4b4c859..6c39cf5 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -98,7 +98,7 @@ public function form(array $form, array &$form_state) { '#description' => $this->t('A unique name for this block instance. Must be alpha-numeric and underscore separated.'), '#default_value' => !$entity->isNew() ? $entity->id() : $this->getUniqueMachineName($entity), '#machine_name' => array( - 'exists' => 'block_load', + 'exists' => '\Drupal\block\Entity\Block::load', 'replace_pattern' => '[^a-z0-9_.]+', 'source' => array('settings', 'label'), ), diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module index dc41879..34dc400 100644 --- a/core/modules/breakpoint/breakpoint.module +++ b/core/modules/breakpoint/breakpoint.module @@ -39,25 +39,6 @@ function breakpoint_help($path, $arg) { } /** - * Load one breakpoint by its identifier. - * - * @param int $id - * The id of the breakpoint to load. - * - * @return \Drupal\breakpoint\Entity\Breakpoint|null - * The entity object, or NULL if there is no entity with the given id. - * - * @todo Remove this in a follow-up issue. - * @see http://drupal.org/node/1798214 - * - * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal\breakpoint\Entity\Breakpoint::load(). - */ -function breakpoint_load($id) { - return Breakpoint::load($id); -} - -/** * Load all breakpoint groups as select options. * * @return array diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php index 4358869..66ed416 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php @@ -35,10 +35,10 @@ public function testBreakpointCRUD() { $this->verifyBreakpoint($breakpoint); - // Test breakpoint_load_all - $all_breakpoints = entity_load_multiple('breakpoint'); + // Test BreakPoint::loadMultiple(). + $all_breakpoints = Breakpoint::loadMultiple(); $config_name = $breakpoint->id(); - $this->assertTrue(isset($all_breakpoints[$config_name]), 'breakpoint_load_all: New breakpoint is present when loading all breakpoints.'); + $this->assertTrue(isset($all_breakpoints[$config_name]), 'New breakpoint is present when loading all breakpoints.'); $this->verifyBreakpoint($breakpoint, $all_breakpoints[$config_name]); // Update the breakpoint. @@ -49,6 +49,6 @@ public function testBreakpointCRUD() { // Delete the breakpoint. $breakpoint->delete(); - $this->assertFalse(breakpoint_load($config_name), 'breakpoint_load: Loading a deleted breakpoint returns false.', 'Breakpoints API'); + $this->assertNull(Breakpoint::load($config_name), 'Loading a deleted breakpoint returns null.', 'Breakpoints API'); } } diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php index 89d0cc1..aac96c9 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php @@ -38,14 +38,14 @@ public function verifyBreakpoint(Breakpoint $breakpoint, Breakpoint $compare_bre 'multipliers', ); - // Verify breakpoint_load(). - $compare_breakpoint = is_null($compare_breakpoint) ? breakpoint_load($breakpoint->id()) : $compare_breakpoint; + // Verify Breakpoint::load(). + $compare_breakpoint = is_null($compare_breakpoint) ? Breakpoint::load($breakpoint->id()) : $compare_breakpoint; foreach ($properties as $property) { $t_args = array( '%breakpoint' => $breakpoint->label(), '%property' => $property, ); - $this->assertEqual($compare_breakpoint->{$property}, $breakpoint->{$property}, format_string('breakpoint_load: Proper %property for breakpoint %breakpoint.', $t_args), 'Breakpoint API'); + $this->assertEqual($compare_breakpoint->{$property}, $breakpoint->{$property}, format_string('Proper %property for breakpoint %breakpoint.', $t_args), 'Breakpoint API'); } } } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 20ac105..3815ffd 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -5,8 +5,6 @@ * Enables the use of personal and site-wide contact forms. */ -use Drupal\contact\Entity\Category; - /** * Implements hook_help(). */ @@ -128,22 +126,6 @@ function contact_entity_extra_field_info() { } /** - * Loads a contact category. - * - * @param $id - * The ID of the contact category to load. - * - * @return \Drupal\contact\Entity\Category|null - * A Category object or NULL if the requested $id does not exist. - * - * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal\contact\Entity\Category::load(). - */ -function contact_category_load($id) { - return Category::load($id); -} - -/** * Implements hook_mail(). */ function contact_mail($key, &$message, $params) { diff --git a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php index 26d4d4c..23fc7e3 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php @@ -37,7 +37,7 @@ public function form(array $form, array &$form_state) { '#default_value' => $category->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => array( - 'exists' => 'contact_category_load', + 'exists' => '\Drupal\contact\Entity\Category::load', ), '#disabled' => !$category->isNew(), ); diff --git a/core/modules/image/image.module b/core/modules/image/image.module index c800076..fea2673 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -7,12 +7,9 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Component\Plugin\Exception\PluginNotFoundException; -use Drupal\field\Entity\FieldConfig; -use Drupal\field\Entity\FieldInstanceConfig; 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. @@ -248,19 +245,6 @@ function image_path_flush($path) { } /** - * Loads an ImageStyle object. - * - * @param string $name - * The ID of the ImageStyle object to load. - * - * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal\image\Entity\ImageStyle::load(). - */ -function image_style_load($name) { - return ImageStyle::load($name); -} - -/** * Gets an array of image styles suitable for using as select list options. * * @param $include_empty diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/MenuFormController.php b/core/modules/menu_ui/lib/Drupal/menu_ui/MenuFormController.php index 82c40d0..62deb6a 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/MenuFormController.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/MenuFormController.php @@ -240,7 +240,7 @@ public function save(array $form, array &$form_state) { * * This form constructor can be integrated as a section into another form. It * relies on the following keys in $form_state: - * - menu: A loaded menu definition, as returned by menu_ui_load(). + * - menu: A menu entity. * - menu_overview_form_parents: An array containing the parent keys to this * form. * Forms integrating this section should call menu_overview_form_submit() from diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuLanguageTest.php b/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuLanguageTest.php index 73374aa..971e821 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuLanguageTest.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuLanguageTest.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Language\Language; +use Drupal\system\Entity\Menu; /** * Defines a test class for testing menu language functionality. @@ -174,7 +175,7 @@ function testMenuLanguageRemovedEnglish() { $this->drupalPostForm('admin/structure/menu/add', $edit, t('Save')); // Check that the language settings were saved. - $menu = menu_ui_load($menu_name); + $menu = Menu::load($menu_name); $this->assertEqual($menu->langcode, 'en'); // Remove English language. To do that another language has to be set as @@ -186,7 +187,7 @@ function testMenuLanguageRemovedEnglish() { // Save the menu again and check if the language is still the same. $this->drupalPostForm("admin/structure/menu/manage/$menu_name", array(), t('Save')); - $menu = menu_ui_load($menu_name); + $menu = Menu::load($menu_name); $this->assertEqual($menu->langcode, 'en'); } diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuTest.php b/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuTest.php index fba3691..9fe966d 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuTest.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/Tests/MenuTest.php @@ -8,6 +8,7 @@ namespace Drupal\menu_ui\Tests; use Drupal\Component\Serialization\Json; +use Drupal\system\Entity\Menu; /** * Defines a test class for testing menu and menu link functionality. @@ -199,7 +200,7 @@ function addCustomMenu() { // Enable the block. $this->drupalPlaceBlock('system_menu_block:' . $menu_name); - return menu_ui_load($menu_name); + return Menu::load($menu_name); } /** @@ -216,7 +217,7 @@ function deleteCustomMenu() { $this->drupalPostForm("admin/structure/menu/manage/$menu_name/delete", array(), t('Delete')); $this->assertResponse(200); $this->assertRaw(t('The custom menu %title has been deleted.', array('%title' => $label)), 'Custom menu was deleted'); - $this->assertFalse(menu_ui_load($menu_name), 'Custom menu was deleted'); + $this->assertNull(Menu::load($menu_name), 'Custom menu was deleted'); // Test if all menu links associated to the menu were removed from database. $result = entity_load_multiple_by_properties('menu_link', array('menu_name' => $menu_name)); $this->assertFalse($result, 'All menu links associated to the custom menu were deleted.'); diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index b514c1b..572937d 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -113,21 +113,6 @@ function menu_ui_theme() { } /** - * Load the data for a single custom menu. - * - * @param $menu_name - * 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, will be removed before Drupal 9.0. - * Use \Drupal\system\Entity\Menu::load(). - */ -function menu_ui_load($menu_name) { - return Menu::load($menu_name); -} - -/** * Implements hook_menu_insert() */ function menu_ui_menu_insert(Menu $menu) { diff --git a/core/modules/responsive_image/lib/Drupal/responsive_image/ResponsiveImageMappingFormController.php b/core/modules/responsive_image/lib/Drupal/responsive_image/ResponsiveImageMappingFormController.php index 721817b..e195498 100644 --- a/core/modules/responsive_image/lib/Drupal/responsive_image/ResponsiveImageMappingFormController.php +++ b/core/modules/responsive_image/lib/Drupal/responsive_image/ResponsiveImageMappingFormController.php @@ -50,7 +50,7 @@ public function form(array $form, array &$form_state) { '#type' => 'machine_name', '#default_value' => $responsive_image_mapping->id(), '#machine_name' => array( - 'exists' => 'responsive_image_mapping_load', + 'exists' => '\Drupal\responsive_image\Entity\ResponsiveImageMapping::load', 'source' => array('label'), ), '#disabled' => (bool) $responsive_image_mapping->id() && $this->operation != 'duplicate', diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index 7f456ad..dd43707 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -6,7 +6,6 @@ */ use Drupal\breakpoint\Entity\Breakpoint; -use Drupal\responsive_image\Entity\ResponsiveImageMapping; use \Drupal\Core\Template\Attribute; /** @@ -70,26 +69,6 @@ function responsive_image_menu() { } /** - * Load one responsive image by its identifier. - * - * @param int $id - * The id of the responsive image mapping to load. - * - * @return \Drupal\responsive_image\ResponsiveImageMappingInterface - * The entity object, or NULL if there is no entity with the given id. - * - * @deprecated in Drupal 8.x, 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 ResponsiveImageMapping::load($id); -} - -/** * Implements hook_theme(). */ function responsive_image_theme() { diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index e6f3a86..f2f938d 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -4,6 +4,7 @@ * @file * Administrative page callbacks for the shortcut module. */ +use Drupal\shortcut\Entity\ShortcutSet; /** * Form callback: builds the form for switching shortcut sets. @@ -71,7 +72,7 @@ function shortcut_set_switch($form, &$form_state, $account = NULL) { $form['id'] = array( '#type' => 'machine_name', '#machine_name' => array( - 'exists' => 'shortcut_set_load', + 'exists' => '\Drupal\shortcut\Entity\ShortcutSet::load', 'source' => array('label'), 'replace_pattern' => '[^a-z0-9-]+', 'replace' => '-', @@ -164,7 +165,7 @@ function shortcut_set_switch_submit($form, &$form_state) { } else { // Switch to a different shortcut set. - $set = shortcut_set_load($form_state['values']['set']); + $set = ShortcutSet::load($form_state['values']['set']); $replacements = array( '%user' => $account->getUsername(), '%set_name' => $set->label(), diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 50f3add..158f0ea 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -122,25 +122,6 @@ function shortcut_set_switch_access($account = NULL) { } /** - * Loads the data for a shortcut set. - * - * @param string $id - * The machine-name of the shortcut set to load. - * - * @return \Drupal\shortcut\ShortcutSetInterface|null - * If the shortcut set exists, an object containing the following properties: - * - '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, will be removed before Drupal 9.0. - * Use \Drupal\shortcut\Entity\ShortcutSet::load(). - */ -function shortcut_set_load($id) { - return ShortcutSet::load($id); -} - -/** * Assigns a user to a particular shortcut set. * * @param $shortcut_set Drupal\shortcut\Entity\Shortcut @@ -201,7 +182,7 @@ function shortcut_current_displayed_set($account = NULL) { ->getStorage('shortcut_set') ->getAssignedToUser($account); if ($shortcut_set_name) { - $shortcut_set = shortcut_set_load($shortcut_set_name); + $shortcut_set = ShortcutSet::load($shortcut_set_name); } // Otherwise, use the default set. else { @@ -236,7 +217,7 @@ function shortcut_default_set($account = NULL) { $suggestions = array_reverse(\Drupal::moduleHandler()->invokeAll('shortcut_default_set', array($account))); $suggestions[] = 'default'; foreach ($suggestions as $name) { - if ($shortcut_set = shortcut_set_load($name)) { + if ($shortcut_set = ShortcutSet::load($name)) { break; } } diff --git a/core/modules/shortcut/src/Access/LinkAccessCheck.php b/core/modules/shortcut/src/Access/LinkAccessCheck.php index b85fb9f..220f5de 100644 --- a/core/modules/shortcut/src/Access/LinkAccessCheck.php +++ b/core/modules/shortcut/src/Access/LinkAccessCheck.php @@ -9,6 +9,7 @@ use Drupal\Core\Routing\Access\AccessInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\shortcut\Entity\ShortcutSet; use Symfony\Component\Routing\Route; use Symfony\Component\HttpFoundation\Request; @@ -23,7 +24,7 @@ class LinkAccessCheck implements AccessInterface { public function access(Route $route, Request $request, AccountInterface $account) { $menu_link = $request->attributes->get('menu_link'); $set_name = str_replace('shortcut-', '', $menu_link['menu_name']); - if ($shortcut_set = shortcut_set_load($set_name)) { + if ($shortcut_set = ShortcutSet::load($set_name)) { return shortcut_set_edit_access($shortcut_set) ? static::ALLOW : static::DENY; } return static::DENY; diff --git a/core/modules/shortcut/src/ShortcutSetFormController.php b/core/modules/shortcut/src/ShortcutSetFormController.php index 5360b5f..191c249 100644 --- a/core/modules/shortcut/src/ShortcutSetFormController.php +++ b/core/modules/shortcut/src/ShortcutSetFormController.php @@ -31,7 +31,7 @@ public function form(array $form, array &$form_state) { $form['id'] = array( '#type' => 'machine_name', '#machine_name' => array( - 'exists' => 'shortcut_set_load', + 'exists' => '\Drupal\shortcut\Entity\ShortcutSet::load', 'source' => array('label'), 'replace_pattern' => '[^a-z0-9-]+', 'replace' => '-', diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index a6d477f..8799760 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -8,10 +8,9 @@ namespace Drupal\Tests\Core\Entity; use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\Core\Entity\AmbiguousEntityClassException; use Drupal\Core\Entity\Entity; -use Drupal\Core\Entity\NoCorrespondingEntityClassException; use Drupal\Core\Language\Language; +use Drupal\entity_test\Entity\EntityTestMul; use Drupal\Tests\UnitTestCase; /** @@ -267,7 +266,6 @@ function setupTestLoad() { ->disableOriginalConstructor() ->setMethods($methods) ->getMock(); - $this->entity->id = 1; $this->entityType->setClass(get_class($this->entity)); $this->entityManager->expects($this->once()) @@ -306,6 +304,8 @@ public function testLoad() { * * Tests if an assertion is thrown if Entity::load() is called on a base class * which is subclassed multiple times. + * + * @expectedException \Drupal\Core\Entity\Exception\AmbiguousEntityClassException */ public function testLoadWithAmbiguousSubclasses() { // Use an entity type object which has the methods enabled which are being @@ -336,12 +336,7 @@ public function testLoadWithAmbiguousSubclasses() { ))); // Call Entity::load statically and check that it throws an exception. - try { - Entity::load(1); - $this->fail('An assertion is thrown when multiple subclasses are able to provide entities.'); - } - catch (AmbiguousEntityClassException $e) { - } + Entity::load(1); } /** @@ -349,6 +344,8 @@ public function testLoadWithAmbiguousSubclasses() { * * Tests if an assertion is thrown if Entity::load() is called and there are * no subclasses defined that can return entities. + * + * @expectedException \Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException */ public function testLoadWithNoCorrespondingSubclasses() { $this->entityManager->expects($this->once()) @@ -356,12 +353,7 @@ public function testLoadWithNoCorrespondingSubclasses() { ->will($this->returnValue(array())); // Call Entity::load statically and check that it throws an exception. - try { - Entity::load(1); - $this->fail('An assertion is thrown when no classes are able to provide entities.'); - } - catch (NoCorrespondingEntityClassException $e) { - } + Entity::load(1); } /**