Elgg  Version 6.1
Cron.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Controllers;
4 
7 use Elgg\Request;
8 
15 class Cron {
16 
24  public function __invoke(Request $request) {
25 
26  if (_elgg_services()->config->security_protect_cron) {
28  }
29 
30  $segments = explode('/', trim((string) $request->getParam('segments'), '/'));
31 
32  $interval = elgg_strtolower(array_shift($segments));
33 
34  $intervals = null;
35  if ($interval !== 'run') {
36  $intervals = [$interval];
37  }
38 
39  $output = '';
40  try {
41  $force = (bool) $request->getParam('force');
42  $jobs = _elgg_services()->cron->run($intervals, $force);
43  foreach ($jobs as $job) {
44  $output .= $job->getOutput() . PHP_EOL;
45  }
46  } catch (CronException $ex) {
47  $output .= "Exception: {$ex->getMessage()}";
48  }
49 
50  return elgg_ok_response(nl2br($output));
51  }
52 }
elgg_signed_request_gatekeeper()
Validates if the HMAC signature of the current request is valid Issues 403 response if signature is i...
Definition: gatekeepers.php:49
elgg_ok_response($content= '', string|array $message= '', string $forward_url=null, int $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
$request
Definition: livesearch.php:12
Controller to handle /cron requests.
Definition: Cron.php:15
elgg_strtolower()
Wrapper function for mb_strtolower().
Definition: mb_wrapper.php:125
getParam($key, $default=null, $filter=true)
Get an element of the params array.
Definition: Request.php:67
__invoke(Request $request)
Respond to a request.
Definition: Cron.php:24
Request container.
Definition: Request.php:12
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
$segments
Definition: admin.php:13
A generic parent class for cron exceptions.
$output
Definition: download.php:9