ModifiedFiles.php in Automatic Updates 8
File
src/ReadinessChecker/ModifiedFiles.php
View source
<?php
namespace Drupal\automatic_updates\ReadinessChecker;
use Drupal\automatic_updates\IgnoredPathsIteratorFilter;
use Drupal\automatic_updates\ProjectInfoTrait;
use Drupal\automatic_updates\Services\ModifiedFilesInterface;
use Drupal\Core\Extension\ExtensionList;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class ModifiedFiles implements ReadinessCheckerInterface {
use StringTranslationTrait;
use ProjectInfoTrait;
protected $modifiedFiles;
protected $module;
protected $profile;
protected $theme;
protected $paths;
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;
}
public function run() {
return $this
->modifiedFilesCheck();
}
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;
}
protected function getExtensionsTypes() {
return [
'module',
'profile',
'theme',
];
}
}