class PackageManagerUpdateProcessor
Extends the Update Status update processor allow fetching any project.
The Update Status module's update processor service is intended to only fetch information for projects in the active codebase. Although it would be possible to use the Update Status module's update processor service to fetch information for projects not in the active code base this would add the project information to Update Status module's cache which would result in these projects being returned from the Update Status module's global functions such as update_get_available().
@internal This is an internal part of Package Manager and may be changed or removed at any time without warning. External code should not interact with this class.
Hierarchy
- class \Drupal\update\UpdateProcessor extends \Drupal\update\UpdateProcessorInterface
- class \Drupal\package_manager\PackageManagerUpdateProcessor implements \Drupal\update\UpdateProcessor
Expanded class hierarchy of PackageManagerUpdateProcessor
File
-
core/
modules/ package_manager/ src/ PackageManagerUpdateProcessor.php, line 33
Namespace
Drupal\package_managerView source
final class PackageManagerUpdateProcessor extends UpdateProcessor {
public function __construct(ConfigFactoryInterface $config_factory, QueueFactory $queue_factory, UpdateFetcherInterface $update_fetcher, StateInterface $state_store, PrivateKey $private_key, KeyValueFactoryInterface $key_value_factory, KeyValueExpirableFactoryInterface $key_value_expirable_factory, TimeInterface $time) {
parent::__construct(...func_get_args());
$this->fetchQueue = $queue_factory->get('package_manager.update_fetch_tasks');
$this->tempStore = $key_value_expirable_factory->get('package_manager.update');
$this->fetchTaskStore = $key_value_factory->get('package_manager.update_fetch_task');
$this->availableReleasesTempStore = $key_value_expirable_factory->get('package_manager.update_available_releases');
}
/**
* Gets the project data by name.
*
* @param string $name
* The project name.
*
* @return mixed[]
* The project data if any is available, otherwise NULL.
*/
public function getProjectData(string $name) : ?array {
if ($this->availableReleasesTempStore
->has($name)) {
return $this->availableReleasesTempStore
->get($name);
}
$project_fetch_data = [
'name' => $name,
'project_type' => 'unknown',
'includes' => [],
];
$this->createFetchTask($project_fetch_data);
if ($this->processFetchTask($project_fetch_data)) {
// If the fetch task was successful return the project information.
return $this->availableReleasesTempStore
->get($name);
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function processFetchTask($project) {
// The parent method will set 'update.last_check' which will be used to
// inform the user when the last time update information was checked. In
// order to leave this value unaffected we will reset this to its previous
// value.
$last_check = $this->stateStore
->get('update.last_check');
$success = parent::processFetchTask($project);
$this->stateStore
->set('update.last_check', $last_check);
return $success;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
PackageManagerUpdateProcessor::getProjectData | public | function | Gets the project data by name. | |
PackageManagerUpdateProcessor::processFetchTask | public | function | Processes a task to fetch available update data for a single project. | Overrides UpdateProcessor::processFetchTask |
PackageManagerUpdateProcessor::__construct | public | function | Constructs an UpdateProcessor. | Overrides UpdateProcessor::__construct |
UpdateProcessor::$availableReleasesTempStore | protected | property | Update available releases store. | |
UpdateProcessor::$failed | protected | property | Array of release history URLs that we have failed to fetch. | |
UpdateProcessor::$fetchQueue | protected | property | The update fetch queue. | |
UpdateProcessor::$fetchTasks | protected | property | The queue for fetching release history data. | |
UpdateProcessor::$fetchTaskStore | protected | property | Update Fetch Task Store. | |
UpdateProcessor::$privateKey | protected | property | The private key. | |
UpdateProcessor::$stateStore | protected | property | The state service. | |
UpdateProcessor::$tempStore | protected | property | Update key/value store. | |
UpdateProcessor::$updateFetcher | protected | property | The UpdateFetcher service. | |
UpdateProcessor::$updateSettings | protected | property | The update settings. | |
UpdateProcessor::claimQueueItem | public | function | Claims an item in the update fetch queue for processing. | Overrides UpdateProcessorInterface::claimQueueItem |
UpdateProcessor::createFetchTask | public | function | Adds a task to the queue for fetching release history data for a project. | Overrides UpdateProcessorInterface::createFetchTask |
UpdateProcessor::deleteQueueItem | public | function | Deletes a finished item from the update fetch queue. | Overrides UpdateProcessorInterface::deleteQueueItem |
UpdateProcessor::fetchData | public | function | Attempts to drain the queue of tasks for release history data to fetch. | Overrides UpdateProcessorInterface::fetchData |
UpdateProcessor::numberOfQueueItems | public | function | Retrieves the number of items in the update fetch queue. | Overrides UpdateProcessorInterface::numberOfQueueItems |
UpdateProcessor::parseXml | protected | function | Parses the XML of the Drupal release history info files. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.