Passed
Push — hans/fluent ( 26c0fc )
by Simon
08:48
created

FluentExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 2
b 0
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModifiedData() 0 2 1
A onAfterInit() 0 10 3
1
<?php
2
3
namespace Firesphere\SolrSearch\Compat;
4
5
use Firesphere\SolrSearch\Indexes\BaseIndex;
6
use SilverStripe\Core\Extension;
7
use TractorCow\Fluent\Extension\FluentChangesExtension;
8
use TractorCow\Fluent\Model\Locale;
9
10
if (!class_exists('TractorCow\\Fluent\\Model\\Locale')) {
11
    return;
12
}
13
14
/**
15
 * Class FluentExtension
16
 *
17
 * @package Firesphere\SolrSearch\Compat
18
 * @property FluentExtension $owner
19
 */
20
class FluentExtension extends Extension
21
{
22
23
    /**
24
     * Add the needed language copy fields to Solr
25
     */
26
    public function onAfterInit()
27
    {
28
        $locales = Locale::get()->exclude(['IsGlobalDefault' => true]);
29
        /** @var BaseIndex $owner */
30
        $owner = $this->owner;
31
        $copyFields = $owner->getCopyFields();
32
        /** @var Locale $locale */
33
        foreach ($locales as $locale) {
34
            foreach ($copyFields as $copyField => $values) {
35
                $owner->addCopyField($locale->Locale . $copyField, $values);
36
            }
37
        }
38
    }
39
40
    /**
41
     * @param $foundData
42
     */
43
    public function getModifiedData($foundData)
0 ignored issues
show
Unused Code introduced by
The parameter $foundData is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

43
    public function getModifiedData(/** @scrutinizer ignore-unused */ $foundData)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        // @todo check modify the found data with the specifics for each language
46
        // Should return a set. Or maybe a simple array? If it's there, we can filter
47
    }
48
}
49