Skip to content

Drupal\helper\InstallProfile

Helpers related to working with install profiles.

Methods

Name Description
__construct InstallProfileSwitcher constructor.
switch Switches the site's install profile.
validateProfile Validates a profile and checks its various requirements.

InstallProfile::__construct

Description

public __construct (\Drupal\Core\Extension\ExtensionList $profileList, \Drupal\Core\Config\ConfigFactoryInterface $configFactory, \Drupal\Core\Extension\ModuleHandlerInterface $module_handler, \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory, \Drupal\Core\Update\UpdateHookRegistry $update_hook_registry)

InstallProfileSwitcher constructor.

Parameters

  • (\Drupal\Core\Extension\ExtensionList) $profileList : The profile extension list service.
  • (\Drupal\Core\Config\ConfigFactoryInterface) $configFactory : The config factory.
  • (\Drupal\Core\Extension\ModuleHandlerInterface) $module_handler : The module handler.
  • (\Drupal\Core\KeyValueStore\KeyValueFactoryInterface) $key_value_factory : The key/value storage factory.
  • (\Drupal\Core\Update\UpdateHookRegistry) $update_hook_registry : The update hook registry.

Return Values

void


InstallProfile::switch

Description

public switch (string $profile, int $schema_version)

Switches the site's install profile.

Note the following:
- This does not run the new profile's install hooks.
- Does not enable any of the profile's dependencies.
- This does not check that currently enabled modules are located in the
current profile's code and will no longer be available once switching
to the new profile.
- Does not run any uninstallation of the current profile, like removing
any tables defined in hook_schema().

Parameters

  • (string) $profile : The machine name of the profile to switch to.
  • (int) $schema_version : The schema version to set for the install profile.

Return Values

void


InstallProfile::validateProfile

Description

public validateProfile (string $profile)

Validates a profile and checks its various requirements.

This method performs the following validations:
- Does the profile exist?
- Does the profile have all of its module dependencies currently enabled?
- Does the profile or any of its dependencies fail any hook_requirements()
checks with errors?
- Does the current profile have any enabled modules or themes inside of it
that will go "missing" when switching to the new profile?

Parameters

  • (string) $profile : The profile name.

Return Values

void

Throws Exceptions

\InvalidArgumentException

If the profile does not exist.

\Drupal\Core\Installer\Exception\InstallerException

If the profile failed any validations.