1 | <?php |
||
2 | |||
3 | namespace Sunnysideup\HealthCheckProvider\Checks\Database; |
||
4 | |||
5 | use Exception; |
||
6 | |||
7 | use SilverStripe\ORM\DatabaseAdmin; |
||
8 | use Sunnysideup\HealthCheckProvider\Checks\HealthCheckItemRunner; |
||
9 | |||
10 | class DevBuild extends HealthCheckItemRunner |
||
11 | { |
||
12 | private static $include_dev_build = false; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
13 | |||
14 | public function getCalculatedAnswer(): string |
||
15 | { |
||
16 | if ($this->Config()->get('include_dev_build')) { |
||
17 | $db = new DatabaseAdmin(); |
||
18 | $start = microtime(true); |
||
19 | $answer = ''; |
||
20 | try { |
||
21 | $db->doBuild(true, false, false); |
||
22 | $end = microtime(true) - $start; |
||
23 | |||
24 | $answer = sprintf( |
||
25 | 'Completed in %s seconds', |
||
26 | round($end, 2) |
||
27 | ); |
||
28 | } catch (Exception $exception) { |
||
29 | $answer = 'Error retrieving data: ' . $exception->getMessage(); |
||
30 | } |
||
31 | |||
32 | return $answer; |
||
33 | } |
||
34 | return ' |
||
35 | Feature not enabled on host. |
||
36 | Please set DevBuild::$include_dev_build = true in yml config files. |
||
37 | '; |
||
38 | } |
||
39 | } |
||
40 |