2008-11-25 02:37:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
2012-06-06 15:33:53 +00:00
|
|
|
* Hooks provided by the Update Manager module.
|
2008-11-25 02:37:33 +00:00
|
|
|
*/
|
|
|
|
|
2019-12-04 11:57:25 +00:00
|
|
|
use Drupal\update\UpdateFetcherInterface;
|
|
|
|
|
2008-11-25 02:37:33 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup hooks
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-06-05 01:04:11 +00:00
|
|
|
/**
|
|
|
|
* Alter the list of projects before fetching data and comparing versions.
|
|
|
|
*
|
|
|
|
* Most modules will never need to implement this hook. It is for advanced
|
2012-06-06 15:33:53 +00:00
|
|
|
* interaction with the Update Manager module. The primary use-case for this
|
|
|
|
* hook is to add projects to the list; for example, to provide update status
|
2024-03-05 16:17:18 +00:00
|
|
|
* data on uninstalled modules and themes. A contributed module might want to
|
|
|
|
* hide projects from the list; for example, if there is a site-specific module
|
|
|
|
* that doesn't have any official releases, that module could remove itself from
|
|
|
|
* this list to avoid "No available releases found" warnings on the available
|
|
|
|
* updates report. In rare cases, a module might want to alter the data
|
|
|
|
* associated with a project already in the list.
|
2009-06-05 01:04:11 +00:00
|
|
|
*
|
|
|
|
* @param $projects
|
|
|
|
* Reference to an array of the projects installed on the system. This
|
2012-06-06 15:33:53 +00:00
|
|
|
* includes all the metadata documented in the comments below for each project
|
2024-03-05 16:17:18 +00:00
|
|
|
* (either module or theme) that is currently installed. The array is
|
|
|
|
* initially populated inside \Drupal\update\UpdateManager::getProjects() with
|
|
|
|
* the help of \Drupal\Core\Utility\ProjectInfo->processInfoList(), so look
|
|
|
|
* there for examples of how to populate the array with real values.
|
2009-06-05 01:04:11 +00:00
|
|
|
*
|
2019-12-11 09:53:53 +00:00
|
|
|
* @see \Drupal\update\UpdateManager::getProjects()
|
2016-08-29 07:44:55 +00:00
|
|
|
* @see \Drupal\Core\Utility\ProjectInfo::processInfoList()
|
2009-06-05 01:04:11 +00:00
|
|
|
*/
|
|
|
|
function hook_update_projects_alter(&$projects) {
|
|
|
|
// Hide a site-specific module from the list.
|
|
|
|
unset($projects['site_specific_module']);
|
|
|
|
|
2024-03-05 16:17:18 +00:00
|
|
|
// Add an uninstalled module to the list.
|
2009-06-05 01:04:11 +00:00
|
|
|
// The key for the array should be the machine-readable project "short name".
|
2024-03-05 16:17:18 +00:00
|
|
|
$projects['uninstalled_project_name'] = [
|
2009-06-05 01:04:11 +00:00
|
|
|
// Machine-readable project short name (same as the array key above).
|
2024-03-05 16:17:18 +00:00
|
|
|
'name' => 'uninstalled_project_name',
|
2013-03-06 22:51:39 +00:00
|
|
|
// Array of values from the main .info.yml file for this project.
|
2017-03-04 01:20:24 +00:00
|
|
|
'info' => [
|
2024-03-05 16:17:18 +00:00
|
|
|
'name' => 'Some uninstalled module',
|
|
|
|
'description' => 'A module not installed on the site that you want to see in the available updates report.',
|
2011-03-21 00:28:12 +00:00
|
|
|
'version' => '8.x-1.0',
|
|
|
|
'core' => '8.x',
|
2009-06-05 01:04:11 +00:00
|
|
|
// The maximum file change time (the "ctime" returned by the filectime()
|
2013-03-06 22:51:39 +00:00
|
|
|
// PHP method) for all of the .info.yml files included in this project.
|
2009-06-05 01:04:11 +00:00
|
|
|
'_info_file_ctime' => 1243888165,
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
2024-03-05 16:17:18 +00:00
|
|
|
// The date stamp when the project was released, if known. If the
|
|
|
|
// uninstalled project was an officially packaged release from drupal.org,
|
|
|
|
// this will be included in the .info.yml file as the 'datestamp' field.
|
|
|
|
// This only really matters for development snapshot releases that are
|
|
|
|
// regenerated, so it can be left undefined or set to 0 in most cases.
|
2009-06-05 01:04:11 +00:00
|
|
|
'datestamp' => 1243888185,
|
|
|
|
// Any modules (or themes) included in this project. Keyed by machine-
|
|
|
|
// readable "short name", value is the human-readable project name printed
|
|
|
|
// in the UI.
|
2017-03-04 01:20:24 +00:00
|
|
|
'includes' => [
|
2024-03-05 16:17:18 +00:00
|
|
|
'uninstalled_project' => 'uninstalled module',
|
|
|
|
'uninstalled_project_helper' => 'uninstalled module helper module',
|
|
|
|
'uninstalled_project_foo' => 'uninstalled module foo add-on module',
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
2024-03-05 16:17:18 +00:00
|
|
|
// Does this project contain a 'module', 'theme', 'uninstalled-module', or
|
|
|
|
// 'uninstalled-theme'?
|
|
|
|
'project_type' => 'uninstalled-module',
|
2017-03-04 01:20:24 +00:00
|
|
|
];
|
2009-06-05 01:04:11 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 02:37:33 +00:00
|
|
|
/**
|
|
|
|
* Alter the information about available updates for projects.
|
|
|
|
*
|
|
|
|
* @param $projects
|
|
|
|
* Reference to an array of information about available updates to each
|
|
|
|
* project installed on the system.
|
|
|
|
*
|
|
|
|
* @see update_calculate_project_data()
|
|
|
|
*/
|
|
|
|
function hook_update_status_alter(&$projects) {
|
2013-09-16 03:58:06 +00:00
|
|
|
$settings = \Drupal::config('update_advanced.settings')->get('projects');
|
2008-11-25 02:37:33 +00:00
|
|
|
foreach ($projects as $project => $project_info) {
|
|
|
|
if (isset($settings[$project]) && isset($settings[$project]['check']) &&
|
|
|
|
($settings[$project]['check'] == 'never' ||
|
2009-05-24 17:39:35 +00:00
|
|
|
(isset($project_info['recommended']) &&
|
|
|
|
$settings[$project]['check'] === $project_info['recommended']))) {
|
2019-12-04 11:57:25 +00:00
|
|
|
$projects[$project]['status'] = UpdateFetcherInterface::NOT_CHECKED;
|
2008-11-25 02:37:33 +00:00
|
|
|
$projects[$project]['reason'] = t('Ignored from settings');
|
|
|
|
if (!empty($settings[$project]['notes'])) {
|
2017-03-04 01:20:24 +00:00
|
|
|
$projects[$project]['extra'][] = [
|
|
|
|
'class' => ['admin-note'],
|
2008-11-25 02:37:33 +00:00
|
|
|
'label' => t('Administrator note'),
|
|
|
|
'data' => $settings[$project]['notes'],
|
2017-03-04 01:20:24 +00:00
|
|
|
];
|
2008-11-25 02:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-30 16:27:02 +00:00
|
|
|
/**
|
|
|
|
* Verify an archive after it has been downloaded and extracted.
|
|
|
|
*
|
|
|
|
* @param string $project
|
|
|
|
* The short name of the project that has been downloaded.
|
|
|
|
* @param string $archive_file
|
2024-01-26 14:52:06 +00:00
|
|
|
* The filename of the un-extracted archive.
|
2010-04-30 16:27:02 +00:00
|
|
|
* @param string $directory
|
|
|
|
* The directory that the archive was extracted into.
|
|
|
|
*
|
Issue #2941148 by quietone, bruno.bicudo, ravi.shankar, Sweetchuck, beatrizrodrigues, lucienchalom, VitaliyB98, WagnerMelo, sophiavs, ankitjain28may, daffie, longwave, Sutharsan, borisson_, cosmicdreams, heykarthikwithu, catch: Fix Drupal.Commenting.FunctionComment.MissingReturnType
2022-09-27 09:58:26 +00:00
|
|
|
* @return array
|
2010-12-06 06:50:08 +00:00
|
|
|
* If there are any problems, return an array of error messages. If there are
|
|
|
|
* no problems, return an empty array.
|
2010-04-30 16:27:02 +00:00
|
|
|
*
|
|
|
|
* @see update_manager_archive_verify()
|
2012-06-06 15:33:53 +00:00
|
|
|
* @ingroup update_manager_file
|
2010-04-30 16:27:02 +00:00
|
|
|
*/
|
|
|
|
function hook_verify_update_archive($project, $archive_file, $directory) {
|
2017-03-04 01:20:24 +00:00
|
|
|
$errors = [];
|
2010-04-30 16:27:02 +00:00
|
|
|
if (!file_exists($directory)) {
|
2017-03-04 01:20:24 +00:00
|
|
|
$errors[] = t('The %directory does not exist.', ['%directory' => $directory]);
|
2010-04-30 16:27:02 +00:00
|
|
|
}
|
|
|
|
// Add other checks on the archive integrity here.
|
2010-12-06 06:50:08 +00:00
|
|
|
return $errors;
|
2010-04-30 16:27:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 02:37:33 +00:00
|
|
|
/**
|
|
|
|
* @} End of "addtogroup hooks".
|
|
|
|
*/
|