Elgg
Version master
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
classes
Elgg
Controllers
Cron.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Elgg\Controllers
;
4
5
use
Elgg\Exceptions\CronException
;
6
use
Elgg\Http\ResponseBuilder
;
7
use
Elgg\Request
;
8
15
class
Cron
{
16
24
public
function
__invoke
(
Request
$request
) {
25
26
if
(
_elgg_services
()->config->security_protect_cron) {
27
elgg_signed_request_gatekeeper
();
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
}
ResponseBuilder
elgg_signed_request_gatekeeper
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
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.
Definition:
pagehandler.php:224
$request
$request
Definition:
livesearch.php:12
Elgg\Controllers\Cron
Controller to handle /cron requests.
Definition:
Cron.php:15
Request
elgg_strtolower
elgg_strtolower()
Wrapper function for mb_strtolower().
Definition:
mb_wrapper.php:125
Elgg\Request\getParam
getParam($key, $default=null, $filter=true)
Get an element of the params array.
Definition:
Request.php:67
trim
Elgg\Controllers
Definition:
CommentEntityRedirector.php:3
Elgg\Controllers\Cron\__invoke
__invoke(Request $request)
Respond to a request.
Definition:
Cron.php:24
Elgg\Request
Request container.
Definition:
Request.php:12
_elgg_services
_elgg_services()
Get the global service provider.
Definition:
elgglib.php:351
$segments
$segments
Definition:
admin.php:13
Elgg\Exceptions\CronException
A generic parent class for cron exceptions.
Definition:
CronException.php:10
$output
$output
Definition:
download.php:9
CronException
Generated on Sat Dec 21 2024 00:02:51 for Elgg by
1.8.11