function navigation_update_11002

Update for navigation logo to store the file path instead of ID.

File

core/modules/navigation/navigation.install, line 49

Code

function navigation_update_11002(array &$sandbox) : void {
    $settings = \Drupal::configFactory()->getEditable('navigation.settings');
    $logo_path = '';
    if (!empty($settings->get('logo.managed'))) {
        $logo_fid = $settings->get('logo.managed');
        $file = \Drupal::entityTypeManager()->getStorage('file')
            ->load($logo_fid);
        if (isset($file)) {
            $logo_path = $file->getFileUri();
            // Delete file usage reference because they are not being used anymore.
            \Drupal::service('file.usage')->delete($file, 'navigation');
        }
    }
    $settings->set('logo.path', $logo_path);
    $settings->clear('logo.managed');
    $settings->save();
}

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