function drupal_get_profile in Drupal 8
Same name and namespace in other branches
- 7 includes/common.inc \drupal_get_profile()
Gets the name of the currently active installation profile.
When this function is called during Drupal's initial installation process, the name of the profile that's about to be installed is stored in the global installation state. At all other times, the "install_profile" setting will be available in container as a parameter.
Return value
string|null The name of the installation profile or NULL if no installation profile is currently active. This is the case for example during the first steps of the installer or during unit tests.
Deprecated
in drupal:8.3.0 and is removed from drupal:9.0.0. Use the install_profile container parameter or \Drupal::installProfile() instead. If you are accessing the value before it is written to configuration during the installer use the $install_state global. If you need to access the value before container is available you can use BootstrapConfigStorageFactory to load the value directly from configuration.
See also
https://www.drupal.org/node/2538996
1 call to drupal_get_profile()
- DrupalGetProfileLegacyTest::testDrupalGetProfileLegacyInstallState in core/
tests/ Drupal/ Tests/ Core/ Bootstrap/ DrupalGetProfileLegacyTest.php - Tests drupal_get_profile() deprecation.
File
- core/
includes/ bootstrap.inc, line 799 - Functions that need to be loaded on every Drupal request.
Code
function drupal_get_profile() {
global $install_state;
@trigger_error('drupal_get_profile() is deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use the install_profile container parameter or \\Drupal::installProfile() instead. If you are accessing the value before it is written to configuration during the installer use the $install_state global. If you need to access the value before container is available you can use BootstrapConfigStorageFactory to load the value directly from configuration. See https://www.drupal.org/node/2538996', E_USER_DEPRECATED);
if (InstallerKernel::installationAttempted()) {
// If the profile has been selected return it.
if (isset($install_state['parameters']['profile'])) {
$profile = $install_state['parameters']['profile'];
}
else {
$profile = NULL;
}
}
else {
if (\Drupal::hasContainer()) {
$profile = \Drupal::installProfile();
}
else {
$profile = BootstrapConfigStorageFactory::getDatabaseStorage()
->read('core.extension')['profile'];
}
}
return $profile;
}