Completed
Push — master ( 31e3fa...9e9db7 )
by Martijn van
02:34
created

MaintenanceModeExtension::onBeforeInit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
3
/**
4
 * Class MaintenanceModeExtension
5
 *
6
 * @property Controller $owner
7
 */
8
class MaintenanceModeExtension extends Extension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    
11
    /**
12
     * @throws SS_HTTPResponse_Exception
13
     */
14
    public function onBeforeInit()
15
    {
16
        if($this->isDownForMaintenance())
17
        {
18
            $this->owner->httpError(503, 'Website is down for maintenance');
19
        }
20
    }
21
22
    /**
23
     * @return bool
24
     */
25
    public function isDownForMaintenance()
26
    {
27
        return file_exists(BASE_PATH.'/framework/down');
28
    }
29
}
30