annotate core/modules/shortcut/shortcut.module @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /**
Chris@0 4 * @file
Chris@0 5 * Allows users to manage customizable lists of shortcut links.
Chris@0 6 */
Chris@0 7
Chris@17 8 use Drupal\Component\Render\FormattableMarkup;
Chris@0 9 use Drupal\Core\Access\AccessResult;
Chris@0 10 use Drupal\Core\Cache\Cache;
Chris@0 11 use Drupal\Core\Routing\RouteMatchInterface;
Chris@0 12 use Drupal\Core\Url;
Chris@0 13 use Drupal\shortcut\Entity\ShortcutSet;
Chris@0 14 use Drupal\shortcut\ShortcutSetInterface;
Chris@0 15
Chris@0 16 /**
Chris@0 17 * Implements hook_help().
Chris@0 18 */
Chris@0 19 function shortcut_help($route_name, RouteMatchInterface $route_match) {
Chris@0 20 switch ($route_name) {
Chris@0 21 case 'help.page.shortcut':
Chris@0 22 $output = '<h3>' . t('About') . '</h3>';
Chris@0 23 $output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the <a href=":shortcut">online documentation for the Shortcut module</a>.', [':shortcut' => 'https://www.drupal.org/documentation/modules/shortcut']) . '</p>';
Chris@0 24 $output .= '<h3>' . t('Uses') . '</h3>';
Chris@0 25 $output .= '<dl><dt>' . t('Administering shortcuts') . '</dt>';
Chris@18 26 $output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href=":shortcuts">Shortcuts administration page</a>.', [':shortcuts' => Url::fromRoute('entity.shortcut_set.collection')->toString()]) . '</dd>';
Chris@0 27 $output .= '<dt>' . t('Choosing shortcut sets') . '</dt>';
Chris@0 28 $output .= '<dd>' . t('Users with permission to switch shortcut sets can choose a shortcut set to use from the Shortcuts tab of their user account page.') . '</dd>';
Chris@0 29 $output .= '<dt>' . t('Adding and removing shortcuts') . '</dt>';
Chris@0 30 $output .= '<dd>' . t('The Shortcut module creates an add/remove link for each page on your site; the link lets you add or remove the current page from the currently-enabled set of shortcuts (if your theme displays it and you have permission to edit your shortcut set). The core Seven administration theme displays this link next to the page title, as a grey or yellow star. If you click on the grey star, you will add that page to your preferred set of shortcuts. If the page is already part of your shortcut set, the link will be a yellow star, and will allow you to remove the current page from your shortcut set.') . '</dd>';
Chris@0 31 $output .= '<dt>' . t('Displaying shortcuts') . '</dt>';
Chris@18 32 $output .= '<dd>' . t('You can display your shortcuts by enabling the <em>Shortcuts</em> block on the <a href=":blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href=":toolbar-help">Toolbar module</a> provides a corresponding menu item.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? Url::fromRoute('block.admin_display')->toString() : '#', ':toolbar-help' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? Url::fromRoute('help.page', ['name' => 'toolbar'])->toString() : '#']) . '</dd>';
Chris@0 33 $output .= '</dl>';
Chris@0 34 return $output;
Chris@0 35
Chris@0 36 case 'entity.shortcut_set.collection':
Chris@0 37 case 'shortcut.set_add':
Chris@0 38 case 'entity.shortcut_set.edit_form':
Chris@0 39 $user = \Drupal::currentUser();
Chris@0 40 if ($user->hasPermission('access shortcuts') && $user->hasPermission('switch shortcut sets')) {
Chris@18 41 $output = '<p>' . t('Define which shortcut set you are using on the <a href=":shortcut-link">Shortcuts tab</a> of your account page.', [':shortcut-link' => Url::fromRoute('shortcut.set_switch', ['user' => $user->id()])->toString()]) . '</p>';
Chris@0 42 return $output;
Chris@0 43 }
Chris@0 44 }
Chris@0 45 }
Chris@0 46
Chris@0 47 /**
Chris@0 48 * Access callback for editing a shortcut set.
Chris@0 49 *
Chris@0 50 * @param Drupal\shortcut\ShortcutSetInterface $shortcut_set
Chris@0 51 * (optional) The shortcut set to be edited. If not set, the current user's
Chris@0 52 * shortcut set will be used.
Chris@0 53 *
Chris@0 54 * @return \Drupal\Core\Access\AccessResultInterface
Chris@0 55 * The access result.
Chris@0 56 */
Chris@0 57 function shortcut_set_edit_access(ShortcutSetInterface $shortcut_set = NULL) {
Chris@0 58 $account = \Drupal::currentUser();
Chris@0 59
Chris@0 60 // Shortcut administrators can edit any set.
Chris@0 61 if ($account->hasPermission('administer shortcuts')) {
Chris@0 62 return AccessResult::allowed()->cachePerPermissions();
Chris@0 63 }
Chris@0 64
Chris@0 65 // Sufficiently-privileged users can edit their currently displayed shortcut
Chris@0 66 // set, but not other sets. They must also be able to access shortcuts.
Chris@0 67 $may_edit_current_shortcut_set = $account->hasPermission('customize shortcut links') && (!isset($shortcut_set) || $shortcut_set == shortcut_current_displayed_set()) && $account->hasPermission('access shortcuts');
Chris@0 68 $result = AccessResult::allowedIf($may_edit_current_shortcut_set)->cachePerPermissions();
Chris@0 69 if (!$result->isAllowed()) {
Chris@0 70 $result->setReason("The shortcut set must be the currently displayed set for the user and the user must have 'access shortcuts' AND 'customize shortcut links' permissions.");
Chris@0 71 }
Chris@0 72 return $result;
Chris@0 73 }
Chris@0 74
Chris@0 75 /**
Chris@0 76 * Access callback for switching the shortcut set assigned to a user account.
Chris@0 77 *
Chris@0 78 * @param object $account
Chris@0 79 * (optional) The user account whose shortcuts will be switched. If not set,
Chris@0 80 * permissions will be checked for switching the logged-in user's own
Chris@0 81 * shortcut set.
Chris@0 82 *
Chris@0 83 * @return \Drupal\Core\Access\AccessResultInterface
Chris@0 84 * The access result.
Chris@0 85 */
Chris@0 86 function shortcut_set_switch_access($account = NULL) {
Chris@0 87 $user = \Drupal::currentUser();
Chris@0 88
Chris@0 89 if ($user->hasPermission('administer shortcuts')) {
Chris@0 90 // Administrators can switch anyone's shortcut set.
Chris@0 91 return AccessResult::allowed()->cachePerPermissions();
Chris@0 92 }
Chris@0 93
Chris@0 94 if (!$user->hasPermission('access shortcuts')) {
Chris@0 95 // The user has no permission to use shortcuts.
Chris@0 96 return AccessResult::neutral()->cachePerPermissions();
Chris@0 97 }
Chris@0 98
Chris@0 99 if (!$user->hasPermission('switch shortcut sets')) {
Chris@0 100 // The user has no permission to switch anyone's shortcut set.
Chris@0 101 return AccessResult::neutral()->cachePerPermissions();
Chris@0 102 }
Chris@0 103
Chris@0 104 // Users with the 'switch shortcut sets' permission can switch their own
Chris@0 105 // shortcuts sets.
Chris@0 106 if (!isset($account)) {
Chris@0 107 return AccessResult::allowed()->cachePerPermissions();
Chris@0 108 }
Chris@0 109 elseif ($user->id() == $account->id()) {
Chris@0 110 return AccessResult::allowed()->cachePerPermissions()->cachePerUser();
Chris@0 111 }
Chris@0 112
Chris@0 113 // No opinion.
Chris@0 114 return AccessResult::neutral()->cachePerPermissions();
Chris@0 115 }
Chris@0 116
Chris@0 117 /**
Chris@0 118 * Assigns a user to a particular shortcut set.
Chris@0 119 *
Chris@0 120 * @param $shortcut_set Drupal\shortcut\Entity\Shortcut
Chris@0 121 * An object representing the shortcut set.
Chris@0 122 * @param $account
Chris@0 123 * A user account that will be assigned to use the set.
Chris@0 124 *
Chris@0 125 * @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
Chris@0 126 * Use \Drupal::entityManager()->getStorage('shortcut_set')->assignUser().
Chris@0 127 */
Chris@0 128 function shortcut_set_assign_user($shortcut_set, $account) {
Chris@0 129 \Drupal::entityManager()
Chris@0 130 ->getStorage('shortcut_set')
Chris@0 131 ->assignUser($shortcut_set, $account);
Chris@0 132 }
Chris@0 133
Chris@0 134 /**
Chris@0 135 * Unassigns a user from any shortcut set they may have been assigned to.
Chris@0 136 *
Chris@0 137 * The user will go back to using whatever default set applies.
Chris@0 138 *
Chris@0 139 * @param $account
Chris@0 140 * A user account that will be removed from the shortcut set assignment.
Chris@0 141 *
Chris@0 142 * @return
Chris@0 143 * TRUE if the user was previously assigned to a shortcut set and has been
Chris@0 144 * successfully removed from it. FALSE if the user was already not assigned
Chris@0 145 * to any set.
Chris@0 146 *
Chris@0 147 * @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
Chris@0 148 * Use \Drupal::entityManager()->getStorage('shortcut_set')->unassignUser().
Chris@0 149 */
Chris@0 150 function shortcut_set_unassign_user($account) {
Chris@0 151 return (bool) \Drupal::entityManager()
Chris@0 152 ->getStorage('shortcut_set')
Chris@0 153 ->unassignUser($account);
Chris@0 154 }
Chris@0 155
Chris@0 156 /**
Chris@0 157 * Returns the current displayed shortcut set for the provided user account.
Chris@0 158 *
Chris@0 159 * @param $account
Chris@0 160 * (optional) The user account whose shortcuts will be returned. Defaults to
Chris@0 161 * the currently logged-in user.
Chris@0 162 *
Chris@0 163 * @return
Chris@0 164 * An object representing the shortcut set that should be displayed to the
Chris@0 165 * current user. If the user does not have an explicit shortcut set defined,
Chris@0 166 * the default set is returned.
Chris@0 167 */
Chris@0 168 function shortcut_current_displayed_set($account = NULL) {
Chris@0 169 $shortcut_sets = &drupal_static(__FUNCTION__, []);
Chris@0 170 $user = \Drupal::currentUser();
Chris@0 171 if (!isset($account)) {
Chris@0 172 $account = $user;
Chris@0 173 }
Chris@0 174 // Try to return a shortcut set from the static cache.
Chris@0 175 if (isset($shortcut_sets[$account->id()])) {
Chris@0 176 return $shortcut_sets[$account->id()];
Chris@0 177 }
Chris@0 178 // If none was found, try to find a shortcut set that is explicitly assigned
Chris@0 179 // to this user.
Chris@0 180 $shortcut_set_name = \Drupal::entityManager()
Chris@0 181 ->getStorage('shortcut_set')
Chris@0 182 ->getAssignedToUser($account);
Chris@0 183 if ($shortcut_set_name) {
Chris@0 184 $shortcut_set = ShortcutSet::load($shortcut_set_name);
Chris@0 185 }
Chris@0 186 // Otherwise, use the default set.
Chris@0 187 else {
Chris@0 188 $shortcut_set = shortcut_default_set($account);
Chris@0 189 }
Chris@0 190
Chris@0 191 $shortcut_sets[$account->id()] = $shortcut_set;
Chris@0 192 return $shortcut_set;
Chris@0 193 }
Chris@0 194
Chris@0 195 /**
Chris@0 196 * Returns the default shortcut set for a given user account.
Chris@0 197 *
Chris@0 198 * @param object $account
Chris@0 199 * (optional) The user account whose default shortcut set will be returned.
Chris@0 200 * If not provided, the function will return the currently logged-in user's
Chris@0 201 * default shortcut set.
Chris@0 202 *
Chris@0 203 * @return
Chris@0 204 * An object representing the default shortcut set.
Chris@0 205 */
Chris@0 206 function shortcut_default_set($account = NULL) {
Chris@0 207 $user = \Drupal::currentUser();
Chris@0 208 if (!isset($account)) {
Chris@0 209 $account = $user;
Chris@0 210 }
Chris@0 211
Chris@0 212 // Allow modules to return a default shortcut set name. Since we can only
Chris@0 213 // have one, we allow the last module which returns a valid result to take
Chris@0 214 // precedence. If no module returns a valid set, fall back on the site-wide
Chris@0 215 // default, which is the lowest-numbered shortcut set.
Chris@0 216 $suggestions = array_reverse(\Drupal::moduleHandler()->invokeAll('shortcut_default_set', [$account]));
Chris@0 217 $suggestions[] = 'default';
Chris@0 218 foreach ($suggestions as $name) {
Chris@0 219 if ($shortcut_set = ShortcutSet::load($name)) {
Chris@0 220 break;
Chris@0 221 }
Chris@0 222 }
Chris@0 223
Chris@0 224 return $shortcut_set;
Chris@0 225 }
Chris@0 226
Chris@0 227 /**
Chris@0 228 * Check to see if a shortcut set with the given title already exists.
Chris@0 229 *
Chris@0 230 * @param $title
Chris@0 231 * Human-readable name of the shortcut set to check.
Chris@0 232 *
Chris@0 233 * @return
Chris@0 234 * TRUE if a shortcut set with that title exists; FALSE otherwise.
Chris@0 235 *
Chris@0 236 * @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
Chris@0 237 */
Chris@0 238 function shortcut_set_title_exists($title) {
Chris@0 239 $sets = ShortcutSet::loadMultiple();
Chris@0 240 foreach ($sets as $set) {
Chris@0 241 if ($set->label() == $title) {
Chris@0 242 return TRUE;
Chris@0 243 }
Chris@0 244 }
Chris@0 245 return FALSE;
Chris@0 246 }
Chris@0 247
Chris@0 248 /**
Chris@0 249 * Returns an array of shortcut links, suitable for rendering.
Chris@0 250 *
Chris@0 251 * @param \Drupal\shortcut\ShortcutSetInterface $shortcut_set
Chris@0 252 * (optional) An object representing the set whose links will be displayed.
Chris@0 253 * If not provided, the user's current set will be displayed.
Chris@0 254 *
Chris@0 255 * @return \Drupal\shortcut\ShortcutInterface[]
Chris@0 256 * An array of shortcut links, in the format returned by the menu system.
Chris@0 257 */
Chris@0 258 function shortcut_renderable_links($shortcut_set = NULL) {
Chris@0 259 $shortcut_links = [];
Chris@0 260
Chris@0 261 if (!isset($shortcut_set)) {
Chris@0 262 $shortcut_set = shortcut_current_displayed_set();
Chris@0 263 }
Chris@0 264
Chris@0 265 $cache_tags = [];
Chris@0 266 foreach ($shortcut_set->getShortcuts() as $shortcut) {
Chris@18 267 $shortcut = \Drupal::service('entity.repository')->getTranslationFromContext($shortcut);
Chris@0 268 $url = $shortcut->getUrl();
Chris@0 269 if ($url->access()) {
Chris@0 270 $links[$shortcut->id()] = [
Chris@0 271 'type' => 'link',
Chris@0 272 'title' => $shortcut->label(),
Chris@0 273 'url' => $shortcut->getUrl(),
Chris@0 274 ];
Chris@0 275 $cache_tags = Cache::mergeTags($cache_tags, $shortcut->getCacheTags());
Chris@0 276 }
Chris@0 277 }
Chris@0 278
Chris@0 279 if (!empty($links)) {
Chris@0 280 $shortcut_links = [
Chris@0 281 '#theme' => 'links__toolbar_shortcuts',
Chris@0 282 '#links' => $links,
Chris@0 283 '#attributes' => [
Chris@0 284 'class' => ['toolbar-menu'],
Chris@0 285 ],
Chris@0 286 '#cache' => [
Chris@0 287 'tags' => $cache_tags,
Chris@0 288 ],
Chris@0 289 ];
Chris@0 290 }
Chris@0 291
Chris@0 292 return $shortcut_links;
Chris@0 293 }
Chris@0 294
Chris@0 295 /**
Chris@0 296 * Implements hook_preprocess_HOOK() for block templates.
Chris@0 297 */
Chris@0 298 function shortcut_preprocess_block(&$variables) {
Chris@0 299 if ($variables['configuration']['provider'] == 'shortcut') {
Chris@0 300 $variables['attributes']['role'] = 'navigation';
Chris@0 301 }
Chris@0 302 }
Chris@0 303
Chris@0 304 /**
Chris@0 305 * Implements hook_preprocess_HOOK() for page title templates.
Chris@0 306 */
Chris@0 307 function shortcut_preprocess_page_title(&$variables) {
Chris@0 308 // Only display the shortcut link if the user has the ability to edit
Chris@0 309 // shortcuts and if the page's actual content is being shown (for example,
Chris@0 310 // we do not want to display it on "access denied" or "page not found"
Chris@0 311 // pages).
Chris@0 312 if (shortcut_set_edit_access()->isAllowed() && !\Drupal::request()->attributes->has('exception')) {
Chris@0 313 $link = Url::fromRouteMatch(\Drupal::routeMatch())->getInternalPath();
Chris@0 314 $route_match = \Drupal::routeMatch();
Chris@0 315
Chris@0 316 // Replicate template_preprocess_html()'s processing to get the title in
Chris@0 317 // string form, so we can set the default name for the shortcut.
Chris@0 318 // Strip HTML tags from the title.
Chris@0 319 $name = trim(strip_tags(render($variables['title'])));
Chris@0 320 $query = [
Chris@0 321 'link' => $link,
Chris@0 322 'name' => $name,
Chris@0 323 ];
Chris@0 324
Chris@0 325 $shortcut_set = shortcut_current_displayed_set();
Chris@0 326
Chris@0 327 // Check if $link is already a shortcut and set $link_mode accordingly.
Chris@0 328 $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $shortcut_set->id()]);
Chris@0 329 /** @var \Drupal\shortcut\ShortcutInterface $shortcut */
Chris@0 330 foreach ($shortcuts as $shortcut) {
Chris@0 331 if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName() && $shortcut_url->getRouteParameters() == $route_match->getRawParameters()->all()) {
Chris@0 332 $shortcut_id = $shortcut->id();
Chris@0 333 break;
Chris@0 334 }
Chris@0 335 }
Chris@0 336 $link_mode = isset($shortcut_id) ? "remove" : "add";
Chris@0 337
Chris@0 338 if ($link_mode == "add") {
Chris@0 339 $link_text = shortcut_set_switch_access()->isAllowed() ? t('Add to %shortcut_set shortcuts', ['%shortcut_set' => $shortcut_set->label()]) : t('Add to shortcuts');
Chris@0 340 $route_name = 'shortcut.link_add_inline';
Chris@0 341 $route_parameters = ['shortcut_set' => $shortcut_set->id()];
Chris@0 342 }
Chris@0 343 else {
Chris@0 344 $query['id'] = $shortcut_id;
Chris@0 345 $link_text = shortcut_set_switch_access()->isAllowed() ? t('Remove from %shortcut_set shortcuts', ['%shortcut_set' => $shortcut_set->label()]) : t('Remove from shortcuts');
Chris@0 346 $route_name = 'entity.shortcut.link_delete_inline';
Chris@0 347 $route_parameters = ['shortcut' => $shortcut_id];
Chris@0 348 }
Chris@0 349
Chris@0 350 if (theme_get_setting('third_party_settings.shortcut.module_link')) {
Chris@0 351 $query += \Drupal::destination()->getAsArray();
Chris@0 352 $variables['title_suffix']['add_or_remove_shortcut'] = [
Chris@0 353 '#attached' => [
Chris@0 354 'library' => [
Chris@0 355 'shortcut/drupal.shortcut',
Chris@0 356 ],
Chris@0 357 ],
Chris@0 358 '#type' => 'link',
Chris@17 359 '#title' => new FormattableMarkup('<span class="shortcut-action__icon"></span><span class="shortcut-action__message">@text</span>', ['@text' => $link_text]),
Chris@0 360 '#url' => Url::fromRoute($route_name, $route_parameters),
Chris@0 361 '#options' => ['query' => $query],
Chris@0 362 '#attributes' => [
Chris@0 363 'class' => [
Chris@0 364 'shortcut-action',
Chris@0 365 'shortcut-action--' . $link_mode,
Chris@0 366 ],
Chris@0 367 ],
Chris@0 368 ];
Chris@0 369 }
Chris@0 370 }
Chris@0 371 }
Chris@0 372
Chris@0 373 /**
Chris@0 374 * Implements hook_toolbar().
Chris@0 375 */
Chris@0 376 function shortcut_toolbar() {
Chris@0 377 $user = \Drupal::currentUser();
Chris@0 378
Chris@0 379 $items = [];
Chris@0 380 $items['shortcuts'] = [
Chris@0 381 '#cache' => [
Chris@0 382 'contexts' => [
Chris@0 383 // Cacheable per user, because each user can have their own shortcut
Chris@0 384 // set, even if they cannot create or select a shortcut set, because
Chris@0 385 // an administrator may have assigned a non-default shortcut set.
Chris@0 386 'user',
Chris@0 387 ],
Chris@0 388 ],
Chris@0 389 ];
Chris@0 390
Chris@0 391 if ($user->hasPermission('access shortcuts')) {
Chris@0 392 $links = shortcut_renderable_links();
Chris@0 393 $shortcut_set = shortcut_current_displayed_set();
Chris@0 394 \Drupal::service('renderer')->addCacheableDependency($items['shortcuts'], $shortcut_set);
Chris@0 395 $configure_link = NULL;
Chris@0 396 if (shortcut_set_edit_access($shortcut_set)->isAllowed()) {
Chris@0 397 $configure_link = [
Chris@0 398 '#type' => 'link',
Chris@0 399 '#title' => t('Edit shortcuts'),
Chris@0 400 '#url' => Url::fromRoute('entity.shortcut_set.customize_form', ['shortcut_set' => $shortcut_set->id()]),
Chris@0 401 '#options' => ['attributes' => ['class' => ['edit-shortcuts']]],
Chris@0 402 ];
Chris@0 403 }
Chris@0 404 if (!empty($links) || !empty($configure_link)) {
Chris@0 405 $items['shortcuts'] += [
Chris@0 406 '#type' => 'toolbar_item',
Chris@0 407 'tab' => [
Chris@0 408 '#type' => 'link',
Chris@0 409 '#title' => t('Shortcuts'),
Chris@18 410 '#url' => $shortcut_set->toUrl('collection'),
Chris@0 411 '#attributes' => [
Chris@0 412 'title' => t('Shortcuts'),
Chris@0 413 'class' => ['toolbar-icon', 'toolbar-icon-shortcut'],
Chris@0 414 ],
Chris@0 415 ],
Chris@0 416 'tray' => [
Chris@0 417 '#heading' => t('User-defined shortcuts'),
Chris@0 418 'shortcuts' => $links,
Chris@0 419 'configure' => $configure_link,
Chris@0 420 ],
Chris@0 421 '#weight' => -10,
Chris@0 422 '#attached' => [
Chris@0 423 'library' => [
Chris@0 424 'shortcut/drupal.shortcut',
Chris@0 425 ],
Chris@0 426 ],
Chris@0 427 ];
Chris@0 428 }
Chris@0 429 }
Chris@0 430
Chris@0 431 return $items;
Chris@0 432 }
Chris@0 433
Chris@0 434 /**
Chris@0 435 * Implements hook_themes_installed().
Chris@0 436 */
Chris@0 437 function shortcut_themes_installed($theme_list) {
Chris@0 438 if (in_array('seven', $theme_list)) {
Chris@0 439 // Theme settings are not configuration entities and cannot depend on modules
Chris@0 440 // so to set a module-specific setting, we need to set it with logic.
Chris@0 441 if (\Drupal::moduleHandler()->moduleExists('shortcut')) {
Chris@0 442 \Drupal::configFactory()->getEditable('seven.settings')->set('third_party_settings.shortcut.module_link', TRUE)->save(TRUE);
Chris@0 443 }
Chris@0 444 }
Chris@0 445 }