Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UpdateRegistry.php

function UpdateRegistry::onConfigSave

Processes the list of installed extensions when core.extension changes.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The Event to process.

File

core/lib/Drupal/Core/Update/UpdateRegistry.php, line 301

Class

UpdateRegistry
Provides all and missing update implementations.

Namespace

Drupal\Core\Update

Code

public function onConfigSave(ConfigCrudEvent $event) {
    $config = $event->getConfig();
    if ($config->getName() === 'core.extension') {
        // Build the old extension configuration list from configuration rather
        // than using $this->enabledExtensions. This ensures that if the
        // UpdateRegistry is constructed after _drupal_maintenance_theme() has
        // added a theme to the theme handler it will not be considered as already
        // installed.
        $old_extension_list = array_keys($config->getOriginal('module') ?? []);
        $new_extension_list = array_keys($config->get('module'));
        if ($this->includeThemes()) {
            $new_extension_list = array_merge($new_extension_list, array_keys($config->get('theme')));
            $old_extension_list = array_merge($old_extension_list, array_keys($config->getOriginal('theme') ?? []));
        }
        // The list of extensions installed or uninstalled. In regular operation
        // only one of the lists will have a single value. This is because Drupal
        // can only install one extension at a time.
        $uninstalled_extensions = array_diff($old_extension_list, $new_extension_list);
        $installed_extensions = array_diff($new_extension_list, $old_extension_list);
        // Set the list of enabled extensions correctly so update function
        // discovery works as expected.
        $this->enabledExtensions = $new_extension_list;
        foreach ($uninstalled_extensions as $uninstalled_extension) {
            $this->filterOutInvokedUpdatesByExtension($uninstalled_extension);
        }
        foreach ($installed_extensions as $installed_extension) {
            // Ensure that all post_update functions are registered already. This
            // should include existing post-updates, as well as any specified as
            // having been previously removed, to ensure that newly installed and
            // updated sites have the same entries in the registry.
            $this->registerInvokedUpdates(array_merge($this->getUpdateFunctions($installed_extension), array_keys($this->getRemovedPostUpdates($installed_extension))));
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal