navigation.post_update.php

Same filename in other branches
  1. 10 core/modules/navigation/navigation.post_update.php

Post update functions for the Navigation module.

File

core/modules/navigation/navigation.post_update.php

View source
<?php


/**
 * @file
 * Post update functions for the Navigation module.
 */
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\user\RoleInterface;

/**
 * Grants navigation specific permission to roles with access to any layout.
 */
function navigation_post_update_update_permissions(array &$sandbox) {
    \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'user_role', function (RoleInterface $role) {
        $needs_save = FALSE;
        if ($role->hasPermission('configure any layout')) {
            $role->grantPermission('configure navigation layout');
            $needs_save = TRUE;
        }
        if ($role->hasPermission('administer navigation_block')) {
            $role->revokePermission('administer navigation_block');
            $role->grantPermission('configure navigation layout');
            $needs_save = TRUE;
        }
        return $needs_save;
    });
}

/**
 * Defines the values for the default logo dimensions.
 */
function navigation_post_update_set_logo_dimensions_default(array &$sandbox) {
    // Empty post_update hook.
}

Functions

Title Deprecated Summary
navigation_post_update_set_logo_dimensions_default Defines the values for the default logo dimensions.
navigation_post_update_update_permissions Grants navigation specific permission to roles with access to any layout.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.