ProxyDBExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateProxy() 0 6 1
1
<?php
2
3
namespace SilverStripe\FullTextSearch\Search\Extensions;
4
5
use SilverStripe\Core\Extension;
6
use TractorCow\ClassProxy\Generators\ProxyGenerator;
7
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
8
9
/**
10
 * This database connector proxy will allow {@link SearchUpdater::handle_manipulation} to monitor database schema
11
 * changes that may need to be propagated through to search indexes.
12
 *
13
 */
14
class ProxyDBExtension extends Extension
15
{
16
    /**
17
     * @param ProxyGenerator $proxy
18
     *
19
     * Ensure the search index is kept up to date by monitoring SilverStripe database manipulations
20
     */
21
    public function updateProxy(ProxyGenerator &$proxy)
22
    {
23
        $proxy = $proxy->addMethod('manipulate', function ($args, $next) {
24
            $manipulation = $args[0];
25
            SearchUpdater::handle_manipulation($manipulation);
26
            return $next(...$args);
27
        });
28
    }
29
}
30