Passed
Push — master ( b3f5f1...8fefff )
by Simon
18:07 queued 16:16
created

SubsitesExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 3
dl 0
loc 11
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A onAfterInit() 0 6 1
1
<?php
2
/**
3
 * Class SubsitesExtension|Firesphere\SolrSubsites\Extensions\SubsitesExtension Add Subsite filter field to the index
4
 *
5
 * @package Firesphere\SolrSubsites\Extensions
6
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
7
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
8
 */
9
10
namespace Firesphere\SolrSubsites\Extensions;
11
12
use Firesphere\SolrSearch\Indexes\BaseIndex;
13
use SilverStripe\Core\Extension;
14
15
/**
16
 * Class \Firesphere\SolrSubsites\Extensions\SubsitesExtension
17
 *
18
 * Add support for subsites in the Index for filtering
19
 *
20
 * @package Firesphere\SolrSearch\Subsites
21
 * @property BaseIndex|SubsitesExtension $owner
22
 */
23
class SubsitesExtension extends Extension
24
{
25
    /**
26
     * Add the subsite ID for each page, if subsites is enabled.
27
     */
28 1
    public function onAfterInit()
29
    {
30
        // Add default support for Subsites.
31
        /** @var BaseIndex $owner */
32 1
        $owner = $this->owner;
33 1
        $owner->addFilterField('SubsiteID');
34 1
    }
35
}
36