Completed
Push — master ( d6e5bd...91fdab )
by Sander
13:05
created

AdminBundle/Helper/DomainConfiguration.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\AdminBundle\Helper;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
use Symfony\Component\HttpFoundation\RequestStack;
7
8
/**
9
 * Class DomainConfiguration
10
 *
11
 * Default (single domain) configuration handling
12
 *
13
 * @package Kunstmaan\AdminBundle\Helper
14
 */
15
class DomainConfiguration implements DomainConfigurationInterface
16
{
17
    /** @var ContainerInterface */
18
    protected $container;
19
20
    /** @var RequestStack */
21
    private $requestStack;
22
23
    /** @var bool */
24
    protected $multiLanguage;
25
26
    /** @var array */
27
    protected $requiredLocales;
28
29
    /** @var string */
30
    protected $defaultLocale;
31
32
    /**
33
     * @param ContainerInterface|string $multilanguage
34
     */
35 View Code Duplication
    public function __construct(/*ContainerInterface|RequestStack*/ $requestStack, $multilanguage = null, $defaultLocale = null, $requiredLocales = null)
0 ignored issues
show
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...
36
    {
37
        if ($requestStack instanceof ContainerInterface) {
38
            @trigger_error('Container injection and the usage of the container is deprecated in KunstmaanNodeBundle 5.1 and will be removed in KunstmaanNodeBundle 6.0.', E_USER_DEPRECATED);
39
40
            $this->container = $requestStack;
41
            $this->multiLanguage = $this->container->getParameter(
42
                'multilanguage'
43
            );
44
            $this->defaultLocale = $this->container->getParameter(
45
                'defaultlocale'
46
            );
47
            $this->requiredLocales = explode(
48
                '|',
49
                $this->container->getParameter('requiredlocales')
50
            );
51
            $this->requestStack = $this->container->get('request_stack');
52
53
            return;
54
        }
55
56
        $this->requestStack = $requestStack;
57
        $this->multiLanguage = $multilanguage;
58
        $this->defaultLocale = $defaultLocale;
59
60
        $this->requiredLocales = explode('|', $requiredLocales);
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getHost()
67
    {
68
        $request = $this->getMasterRequest();
69
        $host = is_null($request) ? '' : $request->getHost();
70
71
        return $host;
72
    }
73
74
    /**
75
     * @return array
76
     */
77
    public function getHosts()
78
    {
79
        return array($this->getHost());
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getDefaultLocale()
86
    {
87
        return $this->defaultLocale;
88
    }
89
90
    /**
91
     * @param string|null $host
92
     *
93
     * @return bool
94
     */
95
    public function isMultiLanguage($host = null)
96
    {
97
        return $this->multiLanguage;
98
    }
99
100
    /**
101
     * @param string|null $host
102
     *
103
     * @return array
104
     */
105
    public function getFrontendLocales($host = null)
106
    {
107
        return $this->requiredLocales;
108
    }
109
110
    /**
111
     * @param string|null $host
112
     *
113
     * @return array
114
     */
115
    public function getBackendLocales($host = null)
116
    {
117
        return $this->requiredLocales;
118
    }
119
120
    /**
121
     * @return bool
122
     */
123
    public function isMultiDomainHost()
124
    {
125
        return false;
126
    }
127
128
    /**
129
     * @param string|null $host
130
     *
131
     * @return null
132
     */
133
    public function getRootNode($host = null)
134
    {
135
        return null;
136
    }
137
138
    /**
139
     * @return array
140
     */
141
    public function getExtraData()
142
    {
143
        return array();
144
    }
145
146
    /**
147
     * @return array
148
     */
149
    public function getLocalesExtraData()
150
    {
151
        return array();
152
    }
153
154
    /**
155
     * @return null|\Symfony\Component\HttpFoundation\Request
156
     */
157
    protected function getMasterRequest()
158
    {
159
        return $this->requestStack->getMasterRequest();
160
    }
161
162
    /**
163
     * @return array
164
     */
165
    public function getFullHostConfig()
166
    {
167
        return array();
168
    }
169
170
    /**
171
     * @param string|null $host
172
     *
173
     * @return null
174
     */
175
    public function getFullHost($host = null)
176
    {
177
        return null;
178
    }
179
180
    /**
181
     * @param int $id
182
     *
183
     * @return null
184
     */
185
    public function getFullHostById($id)
186
    {
187
        return null;
188
    }
189
190
    /**
191
     * @return null
192
     */
193
    public function getHostSwitched()
194
    {
195
        return null;
196
    }
197
198
    /**
199
     * @param string|null $host
200
     *
201
     * @return null
202
     */
203
    public function getHostBaseUrl($host = null)
204
    {
205
        return null;
206
    }
207
208
}
209