You are here

public function ModifiedFilesController::modified in Automatic Updates 8

Test modified files service.

Parameters

string $project_type: The project type.

string $extension: The extension name.

Return value

\Symfony\Component\HttpFoundation\Response A status message of modified files .

1 string reference to 'ModifiedFilesController::modified'
test_automatic_updates.routing.yml in tests/modules/test_automatic_updates/test_automatic_updates.routing.yml
tests/modules/test_automatic_updates/test_automatic_updates.routing.yml

File

tests/modules/test_automatic_updates/src/Controller/ModifiedFilesController.php, line 55

Class

ModifiedFilesController
Class ModifiedFilesController.

Namespace

Drupal\test_automatic_updates\Controller

Code

public function modified($project_type, $extension) {

  // Special edge case for core.
  if ($project_type === 'core') {
    $infos = $this
      ->getInfos('module');
    $extensions = array_filter($infos, static function (array $info) {
      return $info['project'] === 'drupal';
    });
  }
  else {
    $infos = $this
      ->getInfos($project_type);
    $extensions = array_filter($infos, static function (array $info) use ($extension, $project_type) {
      return $info['install path'] === "{$project_type}s/contrib/{$extension}";
    });
  }
  $response = Response::create('No modified files!');
  $filtered_modified_files = new IgnoredPathsIteratorFilter($this->modifiedFiles
    ->getModifiedFiles($extensions));
  if (iterator_count($filtered_modified_files)) {
    $response
      ->setContent('Modified files include: ' . implode(', ', iterator_to_array($filtered_modified_files)));
  }
  return $response;
}