summaryrefslogtreecommitdiffstats
path: root/core/modules/shortcut
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/shortcut')
-rw-r--r--core/modules/shortcut/shortcut.admin.inc5
-rw-r--r--core/modules/shortcut/shortcut.module21
-rw-r--r--core/modules/shortcut/src/ShortcutSetForm.php2
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutLinksTest.php9
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutSetsTest.php5
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutTestBase.php3
6 files changed, 17 insertions, 28 deletions
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 3ad21f0..09ead75 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -9,6 +9,7 @@ use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\UrlHelper;
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;
@@ -122,22 +123,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.
- */
-function shortcut_set_load($id) {
- return entity_load('shortcut_set', $id);
-}
-
-/**
* Assigns a user to a particular shortcut set.
*
* @param $shortcut_set Drupal\shortcut\Entity\Shortcut
@@ -198,7 +183,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 {
@@ -233,7 +218,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/ShortcutSetForm.php b/core/modules/shortcut/src/ShortcutSetForm.php
index 3dd6282..2b50ed2 100644
--- a/core/modules/shortcut/src/ShortcutSetForm.php
+++ b/core/modules/shortcut/src/ShortcutSetForm.php
@@ -31,7 +31,7 @@ class ShortcutSetForm extends EntityForm {
$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/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
index 6607b7f..a713cfc 100644
--- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
@@ -6,6 +6,7 @@
*/
namespace Drupal\shortcut\Tests;
+use Drupal\shortcut\Entity\ShortcutSet;
/**
* Defines shortcut links test cases.
@@ -60,7 +61,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
);
$this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save'));
$this->assertResponse(200);
- $saved_set = shortcut_set_load($set->id());
+ $saved_set = ShortcutSet::load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'path');
$this->assertTrue(in_array($this->container->get('path.alias_manager')->getPathByAlias($test['path']), $paths), 'Shortcut created: ' . $test['path']);
$this->assertLink($title, 0, 'Shortcut link found on the page.');
@@ -110,7 +111,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $new_link_name, 'path' => $shortcut->path->value), t('Save'));
- $saved_set = shortcut_set_load($set->id());
+ $saved_set = ShortcutSet::load($set->id());
$titles = $this->getShortcutInformation($saved_set, 'title');
$this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name);
$this->assertLink($new_link_name, 0, 'Renamed shortcut link appears on the page.');
@@ -128,7 +129,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $shortcut->getTitle(), 'path' => $new_link_path), t('Save'));
- $saved_set = shortcut_set_load($set->id());
+ $saved_set = ShortcutSet::load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'path');
$this->assertTrue(in_array($new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path);
$this->assertLinkByHref($new_link_path, 0, 'Shortcut with new path appears on the page.');
@@ -156,7 +157,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
$shortcuts = $set->getShortcuts();
$shortcut = reset($shortcuts);
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id() . '/delete', array(), 'Delete');
- $saved_set = shortcut_set_load($set->id());
+ $saved_set = ShortcutSet::load($set->id());
$ids = $this->getShortcutInformation($saved_set, 'id');
$this->assertFalse(in_array($shortcut->id(), $ids), 'Successfully deleted a shortcut.');
diff --git a/core/modules/shortcut/src/Tests/ShortcutSetsTest.php b/core/modules/shortcut/src/Tests/ShortcutSetsTest.php
index 2a31535..c17316d 100644
--- a/core/modules/shortcut/src/Tests/ShortcutSetsTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutSetsTest.php
@@ -6,6 +6,7 @@
*/
namespace Drupal\shortcut\Tests;
+use Drupal\shortcut\Entity\ShortcutSet;
/**
* Defines shortcut set test cases.
@@ -98,7 +99,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
$this->drupalGet('admin/config/user-interface/shortcut');
$this->clickLink(t('Edit shortcut set'));
$this->drupalPostForm(NULL, array('label' => $new_label), t('Save'));
- $set = shortcut_set_load($set->id());
+ $set = ShortcutSet::load($set->id());
$this->assertTrue($set->label() == $new_label, 'Shortcut set has been successfully renamed.');
}
@@ -110,7 +111,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
$existing_label = $this->set->label();
$this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id(), array('label' => $existing_label), t('Save'));
$this->assertRaw(t('The shortcut set %name already exists. Choose another name.', array('%name' => $existing_label)));
- $set = shortcut_set_load($set->id());
+ $set = ShortcutSet::load($set->id());
$this->assertNotEqual($set->label(), $existing_label, format_string('The shortcut set %title cannot be renamed to %new-title because a shortcut set with that title already exists.', array('%title' => $set->label(), '%new-title' => $existing_label)));
}
diff --git a/core/modules/shortcut/src/Tests/ShortcutTestBase.php b/core/modules/shortcut/src/Tests/ShortcutTestBase.php
index de9e110..461a40c 100644
--- a/core/modules/shortcut/src/Tests/ShortcutTestBase.php
+++ b/core/modules/shortcut/src/Tests/ShortcutTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\shortcut\Tests;
+use Drupal\shortcut\Entity\ShortcutSet;
use Drupal\shortcut\ShortcutSetInterface;
use Drupal\simpletest\WebTestBase;
@@ -79,7 +80,7 @@ abstract class ShortcutTestBase extends WebTestBase {
// Log in as admin and grab the default shortcut set.
$this->drupalLogin($this->admin_user);
- $this->set = shortcut_set_load('default');
+ $this->set = ShortcutSet::load('default');
shortcut_set_assign_user($this->set, $this->admin_user);
}