You are here

function hacked_preprocess_update_project_status in Hacked! 8.2

Prepares variables for hacked project status templates.

Default template: hacked-project-status.html.twig.

Parameters

array $variables: An associative array containing:

  • project: An array of information about the project.

File

./hacked.report.inc, line 63

Code

function hacked_preprocess_update_project_status(&$variables) {
  $route = \Drupal::routeMatch()
    ->getRouteName();
  if ($route == 'hacked.report') {

    // Storing by reference because we are sorting the project values.
    $project =& $variables['project'];
    $variables['install_type'] = $project['install_type'];
    if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
      $variables['datestamp'] = Drupal::service('date.formatter')
        ->format($project['datestamp'], 'custom', 'Y-M-d');
    }
    $variables['existing_version'] = $project['existing_version'];
    $variables['versions'] = [
      [
        '#theme' => 'hacked_project_summary',
        '#project' => $project,
      ],
    ];
    switch ($project['status']) {
      case HACKED_STATUS_UNHACKED:
        $uri = 'core/misc/icons/73b355/check.svg';
        $text = t('Unchanged');
        $project['status'] = UpdateManagerInterface::CURRENT;
        break;
      case HACKED_STATUS_HACKED:
        $uri = 'core/misc/icons/e32700/error.svg';
        $text = t('Changed!');
        $project['status'] = UpdateFetcherInterface::NOT_CHECKED;
        break;
      case HACKED_STATUS_UNCHECKED:
      default:
        $uri = 'core/misc/icons/e29700/warning.svg';
        $text = t('Unchecked');
        $project['status'] = UpdateFetcherInterface::NOT_CHECKED;
        break;
    }
    $variables['status']['label'] = $text;
    $variables['status']['icon'] = [
      '#theme' => 'image',
      '#width' => 18,
      '#height' => 18,
      '#uri' => $uri,
      '#alt' => $text,
      '#title' => $text,
    ];
  }
}