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

CwpCanonicalURLMiddleware   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 7 3
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