Completed
Pull Request — master (#358)
by Simon
04:22
created

ControllerPath::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.4285
1
<?php
2
/**
3
 * (c) shopware AG <[email protected]>
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace ShopwarePlugins\Connect\Subscribers;
9
10
use Enlight\Event\SubscriberInterface;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
13
class ControllerPath implements SubscriberInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    private $pluginPath;
19
20
    /**
21
     * @var ContainerInterface
22
     */
23
    private $container;
24
25
    /**
26
     * @var \Shopware_Components_Snippet_Manager
27
     */
28
    private $snippetManager;
29
30
    /**
31
     * @param string $pluginPath
32
     * @param ContainerInterface $container
33
     * @param \Shopware_Components_Snippet_Manager $snippetManager
34
     */
35
    public function __construct(
36
        $pluginPath,
37
        ContainerInterface $container,
38
        \Shopware_Components_Snippet_Manager $snippetManager
39
    ) {
40
        $this->pluginPath = $pluginPath;
41
        $this->container = $container;
42
        $this->snippetManager = $snippetManager;
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public static function getSubscribedEvents()
49
    {
50
        return [
51
            'Enlight_Controller_Dispatcher_ControllerPath_Backend_ConnectGateway' => 'onGetControllerPathGateway',
52
            'Enlight_Controller_Dispatcher_ControllerPath_Frontend_Connect' => 'onGetControllerPathFrontend',
53
            'Enlight_Controller_Dispatcher_ControllerPath_Frontend_ConnectProductGateway' => 'onGetControllerPathFrontendConnectControllerGateway',
54
            'Enlight_Controller_Dispatcher_ControllerPath_Backend_Connect' => 'onGetControllerPathBackend',
55
            'Enlight_Controller_Dispatcher_ControllerPath_Backend_LastChanges' => 'onGetLastChangesControllerPath',
56
            'Enlight_Controller_Dispatcher_ControllerPath_Backend_ConnectConfig' => 'onGetControllerPathConnectConfig',
57
            'Enlight_Controller_Dispatcher_ControllerPath_Backend_Import' => 'onGetControllerPathImport'
58
        ];
59
    }
60
61
    /**
62
     * Register the connect backend controller
63
     *
64
     * @param   \Enlight_Event_EventArgs $args
65
     * @return  string
66
     * @Enlight\Event Enlight_Controller_Dispatcher_ControllerPath_Backend_Connect
67
     */
68 View Code Duplication
    public function onGetControllerPathBackend(\Enlight_Event_EventArgs $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
    {
70
        $this->container->get('Template')->addTemplateDir($this->pluginPath . 'Views/', 'connect');
71
        $this->snippetManager->addConfigDir($this->pluginPath . 'Snippets/');
72
73
        return $this->pluginPath . 'Controllers/Backend/Connect.php';
74
    }
75
76
    /**
77
     * Register the connect backend controller
78
     *
79
     * @param   \Enlight_Event_EventArgs $args
80
     * @return  string
81
     * @Enlight\Event Enlight_Controller_Dispatcher_ControllerPath_Backend_Connect
82
     */
83 View Code Duplication
    public function onGetLastChangesControllerPath(\Enlight_Event_EventArgs $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
84
    {
85
        $this->container->get('Template')->addTemplateDir($this->pluginPath . 'Views/', 'connect');
86
        $this->snippetManager->addConfigDir($this->pluginPath . 'Snippets/');
87
88
        return $this->pluginPath . 'Controllers/Backend/LastChanges.php';
89
    }
90
91
    /**
92
     * Register the connectGateway backend controller
93
     *
94
     * @param   \Enlight_Event_EventArgs $args
95
     * @return  string
96
     */
97 View Code Duplication
    public function onGetControllerPathGateway(\Enlight_Event_EventArgs $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
    {
99
        $this->container->get('Template')->addTemplateDir($this->pluginPath . 'Views/', 'connect');
100
        $this->snippetManager->addConfigDir($this->pluginPath . 'Snippets/');
101
102
        return $this->pluginPath . '/Controllers/Backend/ConnectGateway.php';
103
    }
104
105
    /**
106
     * Register the connect frontend controller
107
     *
108
     * @param   \Enlight_Event_EventArgs $args
109
     * @return  string
110
     */
111
    public function onGetControllerPathFrontend(\Enlight_Event_EventArgs $args)
112
    {
113
        $this->container->get('Template')->addTemplateDir($this->pluginPath . 'Views/responsive/', 'connect');
114
115
        return $this->pluginPath . 'Controllers/Frontend/Connect.php';
116
    }
117
118
    /**
119
     * Register the connect product frontend controller
120
     *
121
     * @param   \Enlight_Event_EventArgs $args
122
     * @return  string
123
     */
124
    public function onGetControllerPathFrontendConnectControllerGateway(\Enlight_Event_EventArgs $args)
125
    {
126
        $this->container->get('Template')->addTemplateDir($this->pluginPath . 'Views/responsive/', 'connect');
127
128
        return $this->pluginPath . 'Controllers/Frontend/ConnectProductGateway.php';
129
    }
130
131
    /**
132
     * Register the connect config backend controller
133
     *
134
     * @param   \Enlight_Event_EventArgs $args
135
     * @return  string
136
     * @Enlight\Event Enlight_Controller_Dispatcher_ControllerPath_Backend_ConnectConfig
137
     */
138 View Code Duplication
    public function onGetControllerPathConnectConfig(\Enlight_Event_EventArgs $args)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
139
    {
140
        $this->container->get('Template')->addTemplateDir($this->pluginPath . 'Views/', 'connect');
141
        $this->snippetManager->addConfigDir($this->pluginPath . 'Snippets/');
142
143
        return $this->pluginPath . 'Controllers/Backend/ConnectConfig.php';
144
    }
145
146
    /**
147
     * Register the connect import backend controller
148
     *
149
     * @param   \Enlight_Event_EventArgs $args
150
     * @return  string
151
     * @Enlight\Event Enlight_Controller_Dispatcher_ControllerPath_Backend_Import
152
     */
153
    public function onGetControllerPathImport(\Enlight_Event_EventArgs $args)
154
    {
155
        return $this->pluginPath . 'Controllers/Backend/Import.php';
156
    }
157
}
158