W3cubDocs

/Drupal 8

function drupal_get_profile

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 settings.php.

Return value

string|null $profile 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.

File

core/includes/bootstrap.inc, line 726
Functions that need to be loaded on every Drupal request.

Code

function drupal_get_profile() {
  global $install_state;

  if (drupal_installation_attempted()) {
    // If the profile has been selected return it.
    if (isset($install_state['parameters']['profile'])) {
      $profile = $install_state['parameters']['profile'];
    }
    else {
      $profile = NULL;
    }
  }
  else {
    // Fall back to NULL, if there is no 'install_profile' setting.
    $profile = Settings::get('install_profile');
  }

  return $profile;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!bootstrap.inc/function/drupal_get_profile/8.1.x