addModule example

      // uninstalled during the update.       /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
      $module_handler = $this->container->get('module_handler');
      $config_module_list = $this->config('core.extension')->get('module');
      $module_handler_list = $module_handler->getModuleList();
      $modules_installed = FALSE;
      // Modules that are in configuration but not the module handler have been       // installed.       /** @var \Drupal\Core\Extension\ModuleExtensionList $module_list */
      $module_list = $this->container->get('extension.list.module');
      foreach (array_keys(array_diff_key($config_module_list$module_handler_list)) as $module) {
        $module_handler->addModule($module$module_list->getPath($module));
        $modules_installed = TRUE;
      }
      $modules_uninstalled = FALSE;
      $module_handler_list = $module_handler->getModuleList();
      // Modules that are in the module handler but not configuration have been       // uninstalled.       foreach (array_keys(array_diff_key($module_handler_list$config_module_list)) as $module) {
        $modules_uninstalled = TRUE;
        unset($module_handler_list[$module]);
      }
      if ($modules_installed || $modules_uninstalled) {
        
$request->setSession($kernel->getContainer()->get('session'));
  }
}
catch (HttpExceptionInterface $e) {
  $response = new Response('', $e->getStatusCode());
  $response->prepare($request)->send();
  exit;
}

// We have to enable the user and system modules, even to check access and // display errors via the maintenance theme. \Drupal::moduleHandler()->addModule('system', 'core/modules/system');
\Drupal::moduleHandler()->addModule('user', 'core/modules/user');
\Drupal::moduleHandler()->load('system');
\Drupal::moduleHandler()->load('user');

// Initialize the maintenance theme for this administrative script. drupal_maintenance_theme();

$content = [];
$show_messages = TRUE;

$is_allowed = authorize_access_allowed($request);

    $module_handler = $this->container->get('module_handler');

    // Write directly to active storage to avoid early instantiation of     // the event dispatcher which can prevent modules from registering events.     $active_storage = $this->container->get('config.storage');
    $extension_config = $active_storage->read('core.extension');

    foreach ($modules as $module) {
      if ($module_handler->moduleExists($module)) {
        continue;
      }
      $module_handler->addModule($module$module_list[$module]->getPath());
      // Maintain the list of enabled modules in configuration.       $extension_config['module'][$module] = 0;
    }
    $active_storage->write('core.extension', $extension_config);

    // Update the kernel to make their services available.     $extensions = $module_handler->getModuleList();
    $this->container->get('kernel')->updateModules($extensions$extensions);

    // Ensure isLoaded() is TRUE in order to make     // \Drupal\Core\Theme\ThemeManagerInterface::render() work.


use Shopware\Components\Migrations\AbstractMigration;

class Migrations_Migration918 extends AbstractMigration
{
    /** * {@inheritdoc} */
    public function up($modus)
    {
        $this->addModule();

        $this->addCategoryConfig();

        $this->importDefaultFacets();

        $this->importFacetTranslations();

        $this->createSearchFacets();

        $this->addNewCategoryFilterParam();
    }

    
/** * Tests loading a module. * * @covers ::load */
  public function testLoadModule() {
    $module_handler = $this->getModuleHandler();
    $this->assertFalse(function_exists('module_handler_test_hook'));
    $this->assertTrue($module_handler->load('module_handler_test'));
    $this->assertTrue(function_exists('module_handler_test_hook'));

    $module_handler->addModule('module_handler_test_added', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_added');
    $this->assertFalse(function_exists('module_handler_test_added_hook'), 'Function does not exist before being loaded.');
    $this->assertTrue($module_handler->load('module_handler_test_added'));
    $this->assertTrue(function_exists('module_handler_test_added_helper'), 'Function exists after being loaded.');
    $this->assertTrue($module_handler->load('module_handler_test_added'));

    $this->assertFalse($module_handler->load('module_handler_test_dne'), 'Non-existent modules returns false.');
  }

  /** * Tests loading all modules. * * @covers ::loadAll */
Home | Imprint | This part of the site doesn't use cookies.