class ModifiedFiles in Automatic Updates 8
Same name in this branch
- 8 src/ReadinessChecker/ModifiedFiles.php \Drupal\automatic_updates\ReadinessChecker\ModifiedFiles
- 8 src/Services/ModifiedFiles.php \Drupal\automatic_updates\Services\ModifiedFiles
Modified code checker.
Hierarchy
- class \Drupal\automatic_updates\ReadinessChecker\ModifiedFiles implements ReadinessCheckerInterface uses ProjectInfoTrait, StringTranslationTrait
Expanded class hierarchy of ModifiedFiles
1 file declares its use of ModifiedFiles
- ModifiedFilesTest.php in tests/
src/ Kernel/ ReadinessChecker/ ModifiedFilesTest.php
1 string reference to 'ModifiedFiles'
1 service uses ModifiedFiles
File
- src/
ReadinessChecker/ ModifiedFiles.php, line 14
Namespace
Drupal\automatic_updates\ReadinessCheckerView source
class ModifiedFiles implements ReadinessCheckerInterface {
use StringTranslationTrait;
use ProjectInfoTrait;
/**
* The modified files service.
*
* @var \Drupal\automatic_updates\Services\ModifiedFilesInterface
*/
protected $modifiedFiles;
/**
* The module extension list.
*
* @var \Drupal\Core\Extension\ExtensionList
*/
protected $module;
/**
* The profile extension list.
*
* @var \Drupal\Core\Extension\ExtensionList
*/
protected $profile;
/**
* The theme extension list.
*
* @var \Drupal\Core\Extension\ExtensionList
*/
protected $theme;
/**
* An array of array of strings of extension paths.
*
* @var string[]string[]
*/
protected $paths;
/**
* ModifiedFiles constructor.
*
* @param \Drupal\automatic_updates\Services\ModifiedFilesInterface $modified_files
* The modified files service.
* The config factory.
* @param \Drupal\Core\Extension\ExtensionList $modules
* The module extension list.
* @param \Drupal\Core\Extension\ExtensionList $profiles
* The profile extension list.
* @param \Drupal\Core\Extension\ExtensionList $themes
* The theme extension list.
*/
public function __construct(ModifiedFilesInterface $modified_files, ExtensionList $modules, ExtensionList $profiles, ExtensionList $themes) {
$this->modifiedFiles = $modified_files;
$this->module = $modules;
$this->profile = $profiles;
$this->theme = $themes;
}
/**
* {@inheritdoc}
*/
public function run() {
return $this
->modifiedFilesCheck();
}
/**
* Check if the site contains any modified code.
*
* @return array
* An array of translatable strings if any checks fail.
*/
protected function modifiedFilesCheck() {
$messages = [];
$extensions = [];
foreach ($this
->getExtensionsTypes() as $extension_type) {
$extensions[] = $this
->getInfos($extension_type);
}
$extensions = array_merge(...$extensions);
$filtered_modified_files = new IgnoredPathsIteratorFilter($this->modifiedFiles
->getModifiedFiles($extensions));
foreach ($filtered_modified_files as $file) {
$messages[] = $this
->t('The hash for @file does not match its original. Updates that include that file will fail and require manual intervention.', [
'@file' => $file,
]);
}
return $messages;
}
/**
* Get the extension types.
*
* @return array
* The extension types.
*/
protected function getExtensionsTypes() {
return [
'module',
'profile',
'theme',
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ModifiedFiles:: |
protected | property | The modified files service. | |
ModifiedFiles:: |
protected | property | The module extension list. | |
ModifiedFiles:: |
protected | property | An array of array of strings of extension paths. | |
ModifiedFiles:: |
protected | property | The profile extension list. | |
ModifiedFiles:: |
protected | property | The theme extension list. | |
ModifiedFiles:: |
protected | function | Get the extension types. | |
ModifiedFiles:: |
protected | function | Check if the site contains any modified code. | |
ModifiedFiles:: |
public | function |
Run check. Overrides ReadinessCheckerInterface:: |
|
ModifiedFiles:: |
public | function | ModifiedFiles constructor. | |
ProjectInfoTrait:: |
protected | function | Get the composer.json as a JSON array. | |
ProjectInfoTrait:: |
protected | function | Get extension list. | |
ProjectInfoTrait:: |
protected | function | Get the extension version. | |
ProjectInfoTrait:: |
protected | function | Returns an array of info files information of available extensions. | 1 |
ProjectInfoTrait:: |
protected | function | Get the extension's project name. | |
ProjectInfoTrait:: |
protected | function | Get string suffix. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |