Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By andypost on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Description:
As a part of #1802750: [Meta] Convert configurable data to ConfigEntity system
The {shortcut_set} table was removed in favor of a new shortcut_set
config entity.
Summary
- Shortcut set becomes a classed object,
Drupal\shortcut\Plugin\Core\Entity\ShortcutSet
. - Wherever the code refers to the
$set->set_name
, use$set->id()
. - Wherever the code intends to output a name for the shortcut set, use
$set->label()
.
API changes
const SHORTCUT_DEFAULT_SET_NAME
removed and'default'
string used instead.- Removed
shortcut_set_get_unique_name()
andshortcut_set_name()
, the machine names are internally verified for uniqueness - Removed
shortcut_sets()
,ShortcutSet::loadMultiple()
can be used instead. - Shortcut set add/edit forms now use the entity form controller
ShortcutSetFormController
. - Administration page uses the entity list controller
ShortcutSetListController
.
Examples
// D7 code
$shortcut_sets = shortcut_sets();
$options = array();
foreach ($shortcut_sets as $name => $set) {
$options[$name] = check_plain($set->title);
//...
// D8 code
use Drupal\Component\Utility\String;
use Drupal\shortcut\Entity\ShortcutSet;
$shortcut_sets = ShortcutSet::loadMultiple();
$options = array();
foreach ($shortcut_sets as $name => $set) {
// Sanitation is not needed because of Drupal 8's autoescape functionality.
$options[$name] = $set->label();
//...
Entity API
// D7 code
$shortcut_set = shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME);
// D8 code
$shortcut_set = ShortcutSet::load('default');
Impacts:
Module developers
Comments
the machine names are has
What do you mean here? besides that change notice seems good
Still using custom function
That shortcut_set_load() still here