@@ -12,62 +12,62 @@ |
||
12 | 12 | class CMSExternalLinksController extends Controller |
13 | 13 | { |
14 | 14 | |
15 | - private static $allowed_actions = [ |
|
16 | - 'getJobStatus', |
|
17 | - 'start' |
|
18 | - ]; |
|
15 | + private static $allowed_actions = [ |
|
16 | + 'getJobStatus', |
|
17 | + 'start' |
|
18 | + ]; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Respond to Ajax requests for info on a running job |
|
22 | - * |
|
23 | - * @return string JSON string detailing status of the job |
|
24 | - */ |
|
25 | - public function getJobStatus() |
|
26 | - { |
|
27 | - // Set headers |
|
28 | - HTTP::set_cache_age(0); |
|
29 | - HTTP::add_cache_headers($this->response); |
|
30 | - $this->response |
|
31 | - ->addHeader('Content-Type', 'application/json') |
|
32 | - ->addHeader('Content-Encoding', 'UTF-8') |
|
33 | - ->addHeader('X-Content-Type-Options', 'nosniff'); |
|
20 | + /** |
|
21 | + * Respond to Ajax requests for info on a running job |
|
22 | + * |
|
23 | + * @return string JSON string detailing status of the job |
|
24 | + */ |
|
25 | + public function getJobStatus() |
|
26 | + { |
|
27 | + // Set headers |
|
28 | + HTTP::set_cache_age(0); |
|
29 | + HTTP::add_cache_headers($this->response); |
|
30 | + $this->response |
|
31 | + ->addHeader('Content-Type', 'application/json') |
|
32 | + ->addHeader('Content-Encoding', 'UTF-8') |
|
33 | + ->addHeader('X-Content-Type-Options', 'nosniff'); |
|
34 | 34 | |
35 | - // Format status |
|
36 | - $track = BrokenExternalPageTrackStatus::get_latest(); |
|
37 | - if ($track) { |
|
38 | - return json_encode([ |
|
39 | - 'TrackID' => $track->ID, |
|
40 | - 'Status' => $track->Status, |
|
41 | - 'Completed' => $track->getCompletedPages(), |
|
42 | - 'Total' => $track->getTotalPages() |
|
43 | - ]); |
|
44 | - } |
|
45 | - } |
|
35 | + // Format status |
|
36 | + $track = BrokenExternalPageTrackStatus::get_latest(); |
|
37 | + if ($track) { |
|
38 | + return json_encode([ |
|
39 | + 'TrackID' => $track->ID, |
|
40 | + 'Status' => $track->Status, |
|
41 | + 'Completed' => $track->getCompletedPages(), |
|
42 | + 'Total' => $track->getTotalPages() |
|
43 | + ]); |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Starts a broken external link check |
|
50 | - */ |
|
51 | - public function start() |
|
52 | - { |
|
53 | - // return if the a job is already running |
|
54 | - $status = BrokenExternalPageTrackStatus::get_latest(); |
|
55 | - if ($status && $status->Status == 'Running') { |
|
56 | - return; |
|
57 | - } |
|
48 | + /** |
|
49 | + * Starts a broken external link check |
|
50 | + */ |
|
51 | + public function start() |
|
52 | + { |
|
53 | + // return if the a job is already running |
|
54 | + $status = BrokenExternalPageTrackStatus::get_latest(); |
|
55 | + if ($status && $status->Status == 'Running') { |
|
56 | + return; |
|
57 | + } |
|
58 | 58 | |
59 | - // Create a new job |
|
60 | - if (class_exists(QueuedJobService::class)) { |
|
61 | - // Force the creation of a new run |
|
62 | - BrokenExternalPageTrackStatus::create_status(); |
|
63 | - $checkLinks = new CheckExternalLinksJob(); |
|
64 | - singleton(QueuedJobService::class)->queueJob($checkLinks); |
|
65 | - } else { |
|
66 | - //TODO this hangs as it waits for the connection to be released |
|
67 | - // should return back and continue processing |
|
68 | - // http://us3.php.net/manual/en/features.connection-handling.php |
|
69 | - $task = CheckExternalLinksTask::create(); |
|
70 | - $task->runLinksCheck(); |
|
71 | - } |
|
72 | - } |
|
59 | + // Create a new job |
|
60 | + if (class_exists(QueuedJobService::class)) { |
|
61 | + // Force the creation of a new run |
|
62 | + BrokenExternalPageTrackStatus::create_status(); |
|
63 | + $checkLinks = new CheckExternalLinksJob(); |
|
64 | + singleton(QueuedJobService::class)->queueJob($checkLinks); |
|
65 | + } else { |
|
66 | + //TODO this hangs as it waits for the connection to be released |
|
67 | + // should return back and continue processing |
|
68 | + // http://us3.php.net/manual/en/features.connection-handling.php |
|
69 | + $task = CheckExternalLinksTask::create(); |
|
70 | + $task->runLinksCheck(); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | } |