-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCronLifecycle.php
More file actions
67 lines (56 loc) · 1.5 KB
/
CronLifecycle.php
File metadata and controls
67 lines (56 loc) · 1.5 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
59
60
61
62
63
64
65
66
67
<?php
namespace Perfbase\Drupal\Lifecycle;
use Perfbase\Drupal\Config\ConfigResolver;
use Perfbase\Drupal\Runtime\PerfbaseFactoryInterface;
use Perfbase\Drupal\Support\ErrorHandler;
use Perfbase\Drupal\Support\FilterMatcher;
use Perfbase\Drupal\Support\SpanNaming;
/**
*
*/
class CronLifecycle extends AbstractDrupalProfiler {
private string $taskName;
public function __construct(
string $taskName,
PerfbaseFactoryInterface $factory,
ConfigResolver $configResolver,
ErrorHandler $errorHandler,
) {
$this->taskName = $taskName;
parent::__construct(
SpanNaming::forCron($taskName),
$factory,
$configResolver,
$errorHandler
);
}
/**
*
*/
protected function shouldProfile(): bool {
if (!$this->configResolver->isEnabled($this->config)) {
return FALSE;
}
if (empty($this->config['profile_cron']) || !$this->isProfilerAvailable()) {
return FALSE;
}
return FilterMatcher::passesFilters(
[$this->taskName],
is_array($this->config['include']) ? $this->config['include'] : [],
is_array($this->config['exclude']) ? $this->config['exclude'] : [],
'cron'
);
}
/**
*
*/
protected function setDefaultAttributes(): void {
parent::setDefaultAttributes();
$this->setAttributes([
'source' => 'cron',
'action' => $this->taskName,
'environment' => $this->getEnvironment(),
'app_version' => $this->getAppVersion(),
]);
}
}