You are here

function install_profile_info in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/includes/install.inc \install_profile_info()

Retrieves information about an installation profile from its .info.yml file.

The information stored in a profile .info.yml file is similar to that stored in a normal Drupal module .info.yml file. For example:

  • name: The real name of the installation profile for display purposes.
  • description: A brief description of the profile.
  • dependencies: An array of shortnames of other modules that this install profile requires.

Additional, less commonly-used information that can appear in a profile.info.yml file but not in a normal Drupal module .info.yml file includes:

  • distribution: Existence of this key denotes that the installation profile is intended to be the only eligible choice in a distribution and will be auto-selected during installation, whereas the installation profile selection screen will be skipped. If more than one distribution profile is found then the first one discovered will be selected. The following subproperties may be set:

    • name: The name of the distribution that is being installed, to be shown throughout the installation process. If omitted, drupal_install_profile_distribution_name() defaults to 'Drupal'.
    • install: Optional parameters to override the installer:
      • theme: The machine name of a theme to use in the installer instead of Drupal's default installer theme.

Note that this function does an expensive file system scan to get info file information for dependencies. If you only need information from the info file itself, use system_get_info().

Example of .info.yml file:


   name = Minimal
   description = Start fresh, with only a few modules enabled.
   dependencies[] = block
   dependencies[] = dblog

Parameters

$profile: Name of profile.

$langcode: Language code (if any).

Return value

The info array.

5 calls to install_profile_info()
drupal_check_profile in core/includes/install.inc
Checks an installation profile's requirements.
InstallerLanguageTest::testInstallerTranslationCache in core/modules/system/src/Tests/Installer/InstallerLanguageTest.php
Tests profile info caching in non-English languages.
install_load_profile in core/includes/install.core.inc
Loads information about the chosen profile during installation.
SelectProfileForm::buildForm in core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php
Form constructor.
_install_select_profile in core/includes/install.core.inc
Determines the installation profile to use in the installer.

File

core/includes/install.inc, line 1052
API functions for installing modules and themes.

Code

function install_profile_info($profile, $langcode = 'en') {
  $cache =& drupal_static(__FUNCTION__, array());
  if (!isset($cache[$profile][$langcode])) {

    // Set defaults for module info.
    $defaults = array(
      'dependencies' => array(),
      'themes' => array(
        'stark',
      ),
      'description' => '',
      'version' => NULL,
      'hidden' => FALSE,
      'php' => DRUPAL_MINIMUM_PHP,
    );
    $profile_file = drupal_get_path('profile', $profile) . "/{$profile}.info.yml";
    $info = \Drupal::service('info_parser')
      ->parse($profile_file);
    $info += $defaults;

    // drupal_required_modules() includes the current profile as a dependency.
    // Remove that dependency, since a module cannot depend on itself.
    $required = array_diff(drupal_required_modules(), array(
      $profile,
    ));
    $locale = !empty($langcode) && $langcode != 'en' ? array(
      'locale',
    ) : array();
    $info['dependencies'] = array_unique(array_merge($required, $info['dependencies'], $locale));
    $cache[$profile][$langcode] = $info;
  }
  return $cache[$profile][$langcode];
}