class UpdateManager implements UpdateManagerInterface (View source)

Default implementation of UpdateManagerInterface.

Traits

Provides dependency injection friendly methods for serialization.

Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.

Properties

protected array $_serviceIds

An array of service IDs keyed by property name used for serialization.

from  DependencySerializationTrait
protected array $_entityStorages

An array of entity type IDs keyed by the property name of their storages.

from  DependencySerializationTrait
protected TranslationInterface $stringTranslation

The string translation service.

from  StringTranslationTrait
protected Config $updateSettings

The update settings.

protected ModuleHandlerInterface $moduleHandler

Module Handler Service.

protected UpdateProcessorInterface $updateProcessor

Update Processor Service.

protected array $projects

An array of installed and enabled projects.

protected KeyValueStoreExpirableInterface $keyValueStore

The key/value store.

protected KeyValueStoreExpirableInterface $availableReleasesTempStore

Update available releases key/value store.

protected ThemeHandlerInterface $themeHandler

The theme handler.

protected ModuleExtensionList $moduleExtensionList

The module extension list.

Methods

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

getStringTranslation()

Gets the string translation service.

$this
setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

__construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, UpdateProcessorInterface $update_processor, TranslationInterface $translation, KeyValueFactoryInterface $key_value_expirable_factory, ThemeHandlerInterface $theme_handler, ModuleExtensionList $extension_list_module)

Constructs an UpdateManager.

refreshUpdateData()

Clears out all the available update data and initiates re-fetching.

array
getProjects()

Fetches an array of installed and enabled projects.

array
projectStorage(string $key)

Retrieves update storage data or empties it.

fetchDataBatch(array $context)

Processes a step in batch for fetching available update data.

Details

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

protected TranslatableMarkup t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.

In order for strings to be localized, make them available in one of the ways supported by the

Parameters

string $string

A string containing the English text to translate.

array $args

(optional) An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for details.

array $options

(optional) An associative array of additional options, with the following elements:

  • 'langcode' (defaults to the current language): A language code, to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to. See the @link i18n Internationalization topic @endlink for more information about string contexts.

Return Value

TranslatableMarkup

An object that, when cast to a string, returns the translated string.

See also

FormattableMarkup::placeholderFormat
TranslatableMarkup::__construct

protected formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

Parameters

$count
$singular
$plural
array $args
array $options

See also

TranslationInterface::formatPlural

protected getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

Parameters

$langcode

See also

PluralFormulaInterface::getNumberOfPlurals

protected TranslationInterface getStringTranslation()

Gets the string translation service.

Return Value

TranslationInterface

The string translation service.

$this setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

Parameters

TranslationInterface $translation

The string translation service.

Return Value

$this

__construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, UpdateProcessorInterface $update_processor, TranslationInterface $translation, KeyValueFactoryInterface $key_value_expirable_factory, ThemeHandlerInterface $theme_handler, ModuleExtensionList $extension_list_module)

Constructs an UpdateManager.

Parameters

ConfigFactoryInterface $config_factory

The config factory.

ModuleHandlerInterface $module_handler

The Module Handler service

UpdateProcessorInterface $update_processor

The Update Processor service.

TranslationInterface $translation

The translation service.

KeyValueFactoryInterface $key_value_expirable_factory

The expirable key/value factory.

ThemeHandlerInterface $theme_handler

The theme handler.

ModuleExtensionList $extension_list_module

The module extension list.

refreshUpdateData()

Clears out all the available update data and initiates re-fetching.

array getProjects()

Fetches an array of installed and enabled projects.

This is only responsible for generating an array of projects (taking into account projects that include more than one module or theme). Other information like the specific version and install type (official release, dev snapshot, etc) is handled later in update_process_project_info() since that logic is only required when preparing the status report, not for fetching the available release data.

This array is fairly expensive to construct, since it involves a lot of disk I/O, so we store the results. However, since this is not the data about available updates fetched from the network, it is acceptable to invalidate it somewhat quickly. If we keep this data for very long, site administrators are more likely to see incorrect results if they upgrade to a newer version of a module or theme but do not visit certain pages that automatically clear this data.

Return Value

array

An associative array of currently enabled projects keyed by the machine-readable project short name. Each project contains:

  • name: The machine-readable project short name.
  • info: An array with values from the main .info.yml file for this project.
    • name: The human-readable name of the project.
    • package: The package that the project is grouped under.
    • version: The version of the project.
    • project: The Drupal.org project name.
    • datestamp: The date stamp of the project's main .info.yml file.
    • _info_file_ctime: The maximum file change time for all of the .info.yml files included in this project.
  • datestamp: The date stamp when the project was released, if known.
  • includes: An associative array containing all projects included with this project, keyed by the machine-readable short name with the human-readable name as value.
  • project_type: The type of project. Allowed values are 'module' and 'theme'.
  • project_status: This indicates if the project is enabled and will always be TRUE, as the function only returns enabled projects.

array projectStorage(string $key)

Retrieves update storage data or empties it.

Two very expensive arrays computed by this module are the list of all installed modules and themes (and .info.yml data, project associations, etc), and the current status of the site relative to the currently available releases. These two arrays are stored and used whenever possible. The data is cleared whenever the administrator visits the status report, available updates report, or the module or theme administration pages, since we should always recompute the most current values on any of those pages.

Note: while both of these arrays are expensive to compute (in terms of disk I/O and some fairly heavy CPU processing), neither of these is the actual data about available updates that we have to fetch over the network from updates.drupal.org. That information is stored in the 'update_available_releases' collection -- it needs to persist longer than 1 hour and never get invalidated just by visiting a page on the site.

Parameters

string $key

The key of data to return. Valid options are 'update_project_data' and 'update_project_projects'.

Return Value

array

The stored value of the $projects array generated by update_calculate_project_data() or \Drupal\update\UpdateManager::getProjects(), or an empty array when the storage is cleared. array when the storage is cleared.

fetchDataBatch(array $context)

Processes a step in batch for fetching available update data.

Before calling this method, call UpdateManagerInterface::refreshUpdateData() to clear existing update data and initiate re-fetching.

Parameters

array $context

Reference to an array used for Batch API storage.