GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 27d633...3a74af )
by Guy
12s
created

saveMaintenanceLockEnabled()   A

Complexity

Conditions 6
Paths 5

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.2222
c 0
b 0
f 0
cc 6
nc 5
nop 1
1
<?php
2
3
namespace Symbiote\QueuedJobs\Extensions;
4
5
use SilverStripe\Forms\CheckboxField;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\ORM\DataExtension;
8
use SilverStripe\SiteConfig\SiteConfig;
9
use Symbiote\QueuedJobs\Services\QueuedJobService;
10
11
/**
12
 * Class MaintenanceLockExtension
13
 * Adds a maintenance lock UI to SiteConfig
14
 *
15
 * @property SiteConfig|$this owner
16
 * @package Symbiote\QueuedJobs\Extensions
17
 */
18
class MaintenanceLockExtension extends DataExtension
19
{
20
    /**
21
     * @param FieldList $fields
22
     */
23
    public function updateCMSFields(FieldList $fields)
24
    {
25
        if (!QueuedJobService::config()->get('lock_file_enabled')) {
26
            return;
27
        }
28
29
        $fields->addFieldsToTab('Root.QueueSettings', [
30
            $lockField = CheckboxField::create(
31
                'MaintenanceLockEnabled',
32
                _t(__CLASS__ . '.LOCK_ENABLED', 'Maintenance Lock Enabled'),
33
                QueuedJobService::singleton()->isMaintenanceLockActive()
34
            ),
35
        ]);
36
37
        $lockField->setDescription(
38
            _t(
39
                __CLASS__ . '.LOCK_DESCRIPTION',
40
                'Enable maintenance lock to prevent new queued jobs from being started'
41
            )
42
        );
43
    }
44
45
    /**
46
     * @param bool $value
47
     */
48
    public function saveMaintenanceLockEnabled($value)
49
    {
50
        if (!QueuedJobService::config()->get('lock_file_enabled')) {
51
            return;
52
        }
53
54
        if ($value && !QueuedJobService::singleton()->isMaintenanceLockActive()) {
55
            QueuedJobService::singleton()->enableMaintenanceLock();
56
        }
57
58
        if (!$value && QueuedJobService::singleton()->isMaintenanceLockActive()) {
59
            QueuedJobService::singleton()->disableMaintenanceLock();
60
        }
61
    }
62
}
63