Elgg  Version 3.0
cron.php
Go to the documentation of this file.
1 <?php
15 function _elgg_cron_init() {
16  elgg_set_config('elgg_cron_periods', array_keys(\Elgg\Cron::$intervals));
17 
18  elgg_register_menu_item('page', [
19  'name' => 'cron',
20  'text' => elgg_echo('admin:cron'),
21  'href' => 'admin/cron',
22  'section' => 'information',
23  'context' => 'admin',
24  ]);
25 }
26 
35 function _elgg_cron_page_handler($segments) {
36 
37  if (_elgg_config()->security_protect_cron) {
39  }
40 
41  $interval = strtolower(array_shift($segments));
42 
43  $intervals = null;
44  if ($interval !== 'run') {
45  $intervals = [$interval];
46  }
47 
48  $output = '';
49  try {
50  $force = (bool) get_input('force');
51  $jobs = _elgg_services()->cron->run($intervals, $force);
52  foreach ($jobs as $job) {
53  $output .= $job->getOutput() . PHP_EOL;
54  }
55  } catch (CronException $ex) {
56  $output .= "Exception: {$ex->getMessage()}";
57  }
58 
59  echo nl2br($output);
60  return true;
61 }
62 
66 return function (\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
67  $events->registerHandler('init', 'system', '_elgg_cron_init');
68 };
Events service.
elgg_signed_request_gatekeeper()
Validates if the HMAC signature of the current request is valid Issues 403 response if signature is i...
Definition: elgglib.php:1105
catch(LoginException $e) if($request->isXhr()) $output
Definition: login.php:56
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
Configuration exception.
Base class for events and hooks.
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg_set_config($name, $value)
Set an Elgg configuration value.
elgg echo
Translates a string.
Definition: languages.js:43
_elgg_cron_init()
Cron initialization.
Definition: cron.php:15
elgg_register_menu_item($menu_name, $menu_item)
Register an item for an Elgg menu.
Definition: navigation.php:100
_elgg_cron_page_handler($segments)
/cron handler
Definition: cron.php:35
_elgg_config()
Get the Elgg config service.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292