Completed
Pull Request — master (#4)
by
unknown
01:42
created

ClientDiServiceDefinitionsProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Modera\BackendGoogleAnalyticsBundle\Contributions;
4
5
use Sli\ExpanderBundle\Ext\ContributorInterface;
6
7
/**
8
 * Contributes a plugin to MJR that would allow to track page views.
9
 *
10
 * @internal
11
 *
12
 * @author    Sergei Lissovski <[email protected]>
13
 * @copyright 2016 Modera Foundation
14
 */
15
class ClientDiServiceDefinitionsProvider implements ContributorInterface
16
{
17
    /** @var boolean $enabled */
18
    private $enabled;
19
20
    /**
21
     * @param $enabled
22
     */
23
    public function __construct($enabled)
24
    {
25
        $this->enabled = $enabled;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function getItems()
32
    {
33
        $items = array(
34
            'modera_backend_google_analytics.runtime.tracking_injection_plugin' => array(
35
                'className' => 'Modera.backend.googleanalytics.runtime.TrackingInjectionPlugin',
36
                'args' => [
37
                    array(
38
                        'executionContext' => '@root_execution_context',
39
                        'configProvider' => '@config_provider',
40
                    ),
41
                ],
42
                'tags' => ['runtime_plugin'],
43
            ),
44
            'modera_backend_google_analytics.profiling.ga_backend' => array(
45
                'className' => 'Modera.backend.googleanalytics.profiling.GABackend',
46
                'args' => [
47
                    array(
48
                        'trackingPlugin' => '@modera_backend_google_analytics.runtime.tracking_injection_plugin',
49
                    ),
50
                ],
51
                'tags' => [
52
                    'profiler_backend',
53
                ],
54
            ),
55
            'activity_profiling_auto_start_plugin' => array(
56
                'className' => 'MF.profiling.ActivityProfilingAutoStartPlugin',
57
                'args' => [
58
                    array(
59
                        'workbench' => '@workbench',
60
                        'profiler' => '@profiler',
61
                    ),
62
                ],
63
                'tags' => [
64
                    'runtime_plugin',
65
                ],
66
            ),
67
        );
68
69
        if (!$this->enabled) {
70
            $items = array();
71
        }
72
73
        return $items;
74
    }
75
}
76