3 namespace Drupal\hacked\Controller;
5 use Drupal\Core\Controller\ControllerBase;
6 use Drupal\hacked\hackedProject;
9 * Controller routines for hacked routes.
11 class HackedController extends ControllerBase {
14 * @param \Drupal\hacked\hackedProject $project
17 public function hackedProject(hackedProject $project) {
19 '#theme' => 'hacked_detailed_report',
20 '#project' => $project->compute_details()
25 * Menu title callback for the hacked details page.
27 public function hackedProjectTitle(hackedProject $project) {
28 return $this->t('Hacked status for @project', ['@project' => $project->title()]);
32 * Page callback to build up a full report.
34 public function hackedStatus() {
35 // We're going to be borrowing heavily from the update module
36 $build = ['#theme' => 'update_report'];
37 if ($available = update_get_available(TRUE)) {
38 $build = ['#theme' => 'hacked_report'];
39 $this->moduleHandler()->loadInclude('update', 'compare.inc');
40 $data = update_calculate_project_data($available);
41 $build['#data'] = $this->getProjectData($data);
42 if (!is_array($build['#data'])) {
43 return $build['#data'];
50 * Page callback to rebuild the hacked report.
52 public function hackedStatusManually() {
53 // We're going to be borrowing heavily from the update module
54 if ($available = update_get_available(TRUE)) {
55 $this->moduleHandler()->loadInclude('update', 'compare.inc');
56 $data = update_calculate_project_data($available);
57 return $this->getProjectData($data, TRUE, 'admin/reports/hacked');
59 return $this->redirect('hacked.report');
63 * Compute the report data for hacked.
66 * @param bool|FALSE $force
67 * @param null $redirect
70 protected function getProjectData($projects, $force = FALSE, $redirect = NULL) {
71 // Try to get the report form cache if we can.
72 $cache = \Drupal::cache(HACKED_CACHE_TABLE)->get('hacked:full-report');
73 if (!empty($cache->data) && !$force) {
77 // Enter a batch to build the report.
79 foreach ($projects as $project) {
81 'hacked_build_report_batch',
87 'operations' => $operations,
88 'finished' => 'hacked_build_report_batch_finished',
89 'file' => drupal_get_path('module', 'hacked') . '/hacked.report.inc',
90 'title' => t('Building report'),
94 // End page execution and run the batch.
95 return batch_process($redirect);