Passed
Pull Request — 2.0 (#36)
by
unknown
02:34
created

CwpCanonicalURLMiddleware::isEnabled()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace CWP\Core\Control;
4
5
use SilverStripe\Control\Director;
6
use SilverStripe\Control\Middleware\CanonicalURLMiddleware;
7
8
/**
9
 * @internal Used to override CanonicalURLMiddleware to prevent canonical URL causing a redirect on CLI unless
10
 * explicitly enabled. See https://github.com/silverstripe/cwp-core/commit/cf330def0f0afb7f82876a30eab4c0c658d40a1d
11
 * Note, it is very likely that this class will deprecated after CWP 2.0.
12
 */
13
class CwpCanonicalURLMiddleware extends CanonicalURLMiddleware
14
{
15
    protected function isEnabled()
16
    {
17
        // If CLI, EnabledEnvs must contain CLI
18
        if (Director::is_cli() && !in_array('cli', $enabledEnvs)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $enabledEnvs seems to be never defined.
Loading history...
19
            return false;
20
        }
21
        return parent::isEnabled();
22
    }
23
}
24