updateModules example

/** * Updates the kernel module list. * * @param string $module_filenames * The list of installed modules. */
  protected function updateKernel($module_filenames) {
    // This reboots the kernel to register the module's bundle and its services     // in the service container. The $module_filenames argument is taken over as     // %container.modules% parameter, which is passed to a fresh ModuleHandler     // instance upon first retrieval.     $this->kernel->updateModules($module_filenames$module_filenames);
    // After rebuilding the container we need to update the injected     // dependencies.     $container = $this->kernel->getContainer();
    $this->moduleHandler = $container->get('module_handler');
    $this->connection = $container->get('database');
    $this->updateRegistry = $container->get('update.update_hook_registry');
  }

  /** * {@inheritdoc} */
  
if ($flowEvents) {
            $this->flowEventPersister->updateEvents($flowEvents$id$context$defaultLocale);
        }

        // we need an app secret to securely communicate with apps         // therefore we only install webhooks, modules, tax providers and payment methods if we have a secret         if ($app->getAppSecret()) {
            $this->paymentMethodPersister->updatePaymentMethods($manifest$id$defaultLocale$context);
            $this->taxProviderPersister->updateTaxProviders($manifest$id$defaultLocale$context);

            $this->updateModules($manifest$id$defaultLocale$context);
        }

        $this->ruleConditionPersister->updateConditions($manifest$id$defaultLocale$context);
        $this->actionButtonPersister->updateActions($manifest$id$defaultLocale$context);
        $this->templatePersister->updateTemplates($manifest$id$context);
        $this->scriptPersister->updateScripts($id$context);
        $this->customFieldPersister->updateCustomFields($manifest$id$context);
        $this->assetService->copyAssetsFromApp($app->getName()$app->getPath());

        $cmsExtensions = $this->appLoader->getCmsExtensions($app);
        if ($cmsExtensions) {
            

  protected function getTestKernel(Request $request, array $modules_enabled = NULL) {
    // Manually create kernel to avoid replacing settings.     $class_loader = require $this->root . '/autoload.php';
    $kernel = DrupalKernel::createFromRequest($request$class_loader, 'testing');
    $this->setSetting('container_yamls', []);
    $this->setSetting('hash_salt', $this->databasePrefix);
    if (isset($modules_enabled)) {
      $kernel->updateModules($modules_enabled);
    }
    $kernel->boot();

    return $kernel;
  }

  /** * Tests DIC compilation. */
  public function testCompileDIC() {
    // @todo: write a memory based storage backend for testing.

        return 1614765170;
    }

    public function update(Connection $connection): void
    {
        /** @var list<array{id: string, modules: string|null}> $apps */
        $apps = $connection->executeQuery('SELECT `id`, `modules` FROM `app`')->fetchAllAssociative();

        $preparedModules = $this->prepareModules($apps);

        $this->updateModules($preparedModules$connection);
    }

    public function updateDestructive(Connection $connection): void
    {
        // implement update destructive     }

    /** * @param list<array{id: string, modules: string|null}> $apps * * @return list<array{id: string, modules: string|null}> */
        array_unshift($modules$second);
      }
    }

    // Bootstrap the kernel. Do not use createFromRequest() to retain Settings.     $kernel = new DrupalKernel('testing', $this->classLoader, FALSE);
    $kernel->setSitePath($this->siteDirectory);
    // Boot a new one-time container from scratch. Set the module list upfront     // to avoid a subsequent rebuild or setting the kernel into the     // pre-installer mode.     $extensions = $modules ? $this->getExtensionsForModules($modules) : [];
    $kernel->updateModules($extensions$extensions);

    // DrupalKernel::boot() is not sufficient as it does not invoke preHandle(),     // which is required to initialize legacy global variables.     $request = Request::create('/');
    $kernel->boot();
    $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>'));
    $request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<none>');
    $kernel->preHandle($request);

    $this->container = $kernel->getContainer();

    
$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) {
        // Note that resetAll() does not reset the kernel module list so we         // have to do that manually.         $this->kernel->updateModules($module_handler_list$module_handler_list);
      }

      // Close any open database connections. This allows DB drivers that store       // static information to refresh it in the update runner.       // @todo https://drupal.org/i/3222121 consider doing this in       // \Drupal\Core\DrupalKernel::initializeContainer() for container       // rebuilds.       foreach (Database::getAllConnectionInfo() as $key => $info) {
        Database::closeConnection(NULL, $key);
      }

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