-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerfbaseCronDecorator.php
More file actions
58 lines (47 loc) · 1.2 KB
/
PerfbaseCronDecorator.php
File metadata and controls
58 lines (47 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Perfbase\Drupal\Runtime;
use Drupal\Core\CronInterface;
use Perfbase\Drupal\Config\ConfigResolver;
use Perfbase\Drupal\Lifecycle\CronLifecycle;
use Perfbase\Drupal\Support\ErrorHandler;
/**
*
*/
class PerfbaseCronDecorator implements CronInterface {
private CronInterface $inner;
private PerfbaseFactoryInterface $factory;
private ConfigResolver $configResolver;
private ErrorHandler $errorHandler;
public function __construct(
CronInterface $inner,
PerfbaseFactoryInterface $factory,
ConfigResolver $configResolver,
ErrorHandler $errorHandler,
) {
$this->inner = $inner;
$this->factory = $factory;
$this->configResolver = $configResolver;
$this->errorHandler = $errorHandler;
}
/**
* @return mixed
*/
public function run() {
$lifecycle = new CronLifecycle(
'cron.run',
$this->factory,
$this->configResolver,
$this->errorHandler
);
$lifecycle->startProfiling();
try {
return $this->inner->run();
}
catch (\Throwable $exception) {
$lifecycle->setException($exception->getMessage());
throw $exception;
} finally {
$lifecycle->stopProfiling();
}
}
}