installDefaultConfig example


  protected function installConfig($modules) {
    foreach ((array) $modules as $module) {
      if (!$this->container->get('module_handler')->moduleExists($module)) {
        throw new \LogicException("$module module is not installed.");
      }
      try {
        $this->container->get('config.installer')->installDefaultConfig('module', $module);
      }
      catch (\Exception $e) {
        throw new \Exception(sprintf('Exception when installing config for module %s, message was: %s', $module$e->getMessage()), 0, $e);
      }
    }
  }

  /** * Installs database tables from a module schema definition. * * @param string $module * The name of the module that defines the table's schema. * @param string|array $tables * The name or an array of the names of the tables to install. * * @throws \LogicException * If $module is not enabled or the table schema cannot be found. */
$this->service = $this->container->get($this->drupalProxyOriginalServiceId);
            }

            return $this->service;
        }

        /** * {@inheritdoc} */
        public function installDefaultConfig($type$name)
        {
            return $this->lazyLoadItself()->installDefaultConfig($type$name);
        }

        /** * {@inheritdoc} */
        public function installOptionalConfig(?\Drupal\Core\Config\StorageInterface $storage = NULL, $dependency = array (
        ))
        {
            return $this->lazyLoadItself()->installOptionalConfig($storage$dependency);
        }

        
// Reset theme settings.       $theme_settings = &drupal_static('theme_get_setting');
      unset($theme_settings[$key]);

      // Reset theme listing.       $this->themeHandler->reset();

      // Only install default configuration if this theme has not been installed       // already.       if (!isset($installed_themes[$key])) {
        // Install default configuration of the theme.         $this->configInstaller->installDefaultConfig('theme', $key);
      }

      $themes_installed[] = $key;
      // Record the fact that it was installed.       $this->logger->info('%theme theme installed.', ['%theme' => $key]);
    }

    $this->cssCollectionOptimizer->deleteAll();
    $this->resetSystem();

    // Invoke hook_themes_installed() after the themes have been installed.

          }
        }

        // Install default configuration of the module.         $config_installer = \Drupal::service('config.installer');
        if ($sync_status) {
          $config_installer
            ->setSyncing(TRUE)
            ->setSourceStorage($source_storage);
        }
        \Drupal::service('config.installer')->installDefaultConfig('module', $module);

        // If the module has no current updates, but has some that were         // previously removed, set the version to the value of         // hook_update_last_removed().         if ($last_removed = $this->moduleHandler->invoke($module, 'update_last_removed')) {
          $version = max($version$last_removed);
        }
        $this->updateRegistry->setInstalledVersion($module$version);

        // Record the fact that it was installed.         $modules_installed[] = $module;

        
Home | Imprint | This part of the site doesn't use cookies.