function PackageManagerRequirementsHooks::runtime
Same name and namespace in other branches
- 11.x core/modules/package_manager/src/Hook/PackageManagerRequirementsHooks.php \Drupal\package_manager\Hook\PackageManagerRequirementsHooks::runtime()
Implements hook_runtime_requirements().
Attributes
#[Hook('runtime_requirements')]
File
-
core/
modules/ package_manager/ src/ Hook/ PackageManagerRequirementsHooks.php, line 32
Class
- PackageManagerRequirementsHooks
- Requirements checks for Package Manager.
Namespace
Drupal\package_manager\HookCode
public function runtime() : array {
$requirements = [];
$requirements = $this->checkSettings($requirements);
$requirements = $this->checkFailure($requirements);
// Report the Composer version in use, as well as its path.
$title = $this->t('Composer version');
try {
$requirements['package_manager_composer'] = [
'title' => $title,
'description' => $this->t('@version (<code>@path</code>)', [
'@version' => $this->composerInspector
->getVersion(),
'@path' => $this->executableFinder
->find('composer'),
]),
'severity' => RequirementSeverity::Info,
];
} catch (\Throwable $e) {
// All Composer Stager exceptions are translatable.
$message = $e instanceof ExceptionInterface ? $e->getTranslatableMessage() : $e->getMessage();
$requirements['package_manager_composer'] = [
'title' => $title,
'description' => $this->t('Composer was not found. The error message was: @message', [
'@message' => $message,
]),
'severity' => RequirementSeverity::Error,
];
}
$legacy_executables = $this->configFactory
->get('package_manager.settings')
->get('executables');
if (isset($legacy_executables['composer'])) {
$requirements['package_manager_configured_executable_composer'] = [
'title' => $this->t('Path to Composer is configured'),
'description' => $this->t("The path to Composer is set in configuration, which is no longer supported. To fix this, add <code>composer/composer</code> to your project's dependencies by running <code>composer require 'composer/composer:@version'</code>, <em>or</em> add the following line to <code>settings.php</code>: <code>\$settings['package_manager_composer_path'] = '@composer_path';</code>. See <a href=\":url\">this change record</a> for more information.", [
'@composer_path' => $legacy_executables['composer'],
'@version' => ComposerInspector::SUPPORTED_VERSION,
':url' => 'https://www.drupal.org/node/3540264',
]),
'severity' => RequirementSeverity::Warning,
];
}
if (isset($legacy_executables['rsync'])) {
$requirements['package_manager_configured_executable_rsync'] = [
'title' => $this->t('Path to <code>rsync</code> is configured'),
'description' => $this->t("The path to <code>rsync</code> is set in configuration, which is no longer supported. To fix this, add the following line to <code>settings.php</code>: <code>\$settings['package_manager_rsync_path'] = '@rsync_path';</code>. See <a href=\":url\">this change record</a> for more information.", [
'@rsync_path' => $legacy_executables['rsync'],
':url' => 'https://www.drupal.org/node/3540264',
]),
'severity' => RequirementSeverity::Warning,
];
}
return $requirements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.