Passed
Push — master ( 5586bd...e55976 )
by Aimeos
03:52
created
Classes/Base.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 use \TYPO3\CMS\Core\Utility\GeneralUtility;
15 15
 
16 16
 
17
-$aimeosExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('aimeos');
17
+$aimeosExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'aimeos' );
18 18
 
19
-if (file_exists($aimeosExtPath . '/Resources/Libraries/autoload.php') === true) {
19
+if( file_exists( $aimeosExtPath . '/Resources/Libraries/autoload.php' ) === true ) {
20 20
     require_once $aimeosExtPath . '/Resources/Libraries/autoload.php';
21 21
 }
22 22
 
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $name = 'Aimeos\Aimeos\Base\Aimeos';
42 42
 
43
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos'])) {
44
-            if (($name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos']) instanceof \Closure) {
43
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos'] ) ) {
44
+            if( ( $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos'] ) instanceof \Closure ) {
45 45
                 return $name();
46 46
             }
47 47
         }
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
      * @param array $local Multi-dimensional associative list with local configuration
57 57
      * @return \Aimeos\Base\Config\Iface Configuration object
58 58
      */
59
-    public static function config(array $local = []) : \Aimeos\Base\Config\Iface
59
+    public static function config( array $local = [] ) : \Aimeos\Base\Config\Iface
60 60
     {
61 61
         $name = 'Aimeos\Aimeos\Base\Config';
62 62
 
63
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_config'])) {
64
-            if (($name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_config']) instanceof \Closure) {
65
-                return $name(self::aimeos()->getConfigPaths(), $local);
63
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_config'] ) ) {
64
+            if( ( $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_config'] ) instanceof \Closure ) {
65
+                return $name( self::aimeos()->getConfigPaths(), $local );
66 66
             }
67 67
         }
68 68
 
69
-        return $name::get(self::aimeos()->getConfigPaths(), $local);
69
+        return $name::get( self::aimeos()->getConfigPaths(), $local );
70 70
     }
71 71
 
72 72
 
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
      * @param \Aimeos\Base\Config\Iface Configuration object
77 77
      * @return \Aimeos\MShop\ContextIface Context object
78 78
      */
79
-    public static function context(\Aimeos\Base\Config\Iface $config) : \Aimeos\MShop\ContextIface
79
+    public static function context( \Aimeos\Base\Config\Iface $config ) : \Aimeos\MShop\ContextIface
80 80
     {
81 81
         $name = 'Aimeos\Aimeos\Base\Context';
82 82
 
83
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context'])) {
84
-            if (($name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context']) instanceof \Closure) {
85
-                return $name($config);
83
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context'] ) ) {
84
+            if( ( $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context'] ) instanceof \Closure ) {
85
+                return $name( $config );
86 86
             }
87 87
         }
88 88
 
89
-        return $name::get($config);
89
+        return $name::get( $config );
90 90
     }
91 91
 
92 92
 
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
      * @param mixed Value returned if no value in extension configuration was found
98 98
      * @return mixed Value associated with the configuration setting
99 99
      */
100
-    public static function getExtConfig(string $name, $default = null)
100
+    public static function getExtConfig( string $name, $default = null )
101 101
     {
102
-        if (self::$extConfig === null) {
103
-            self::$extConfig = GeneralUtility::makeInstance('TYPO3\CMS\Core\Configuration\ExtensionConfiguration')->get('aimeos');
102
+        if( self::$extConfig === null ) {
103
+            self::$extConfig = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\Configuration\ExtensionConfiguration' )->get( 'aimeos' );
104 104
         }
105 105
 
106
-        if (isset(self::$extConfig[$name])) {
106
+        if( isset( self::$extConfig[$name] ) ) {
107 107
             return self::$extConfig[$name];
108 108
         }
109 109
 
@@ -118,17 +118,17 @@  discard block
 block discarded – undo
118 118
      * @param array $local List of local translation entries overwriting the standard ones
119 119
      * @return array List of translation objects implementing MW_Translation_Interface
120 120
      */
121
-    public static function i18n(array $languageIds, array $local = []) : array
121
+    public static function i18n( array $languageIds, array $local = [] ) : array
122 122
     {
123 123
         $name = 'Aimeos\Aimeos\Base\I18n';
124 124
 
125
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_i18n'])) {
126
-            if (($name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_i18n']) instanceof \Closure) {
127
-                return $name(self::aimeos()->getI18nPaths(), $languageIds, $local);
125
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_i18n'] ) ) {
126
+            if( ( $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_i18n'] ) instanceof \Closure ) {
127
+                return $name( self::aimeos()->getI18nPaths(), $languageIds, $local );
128 128
             }
129 129
         }
130 130
 
131
-        return $name::get(self::aimeos()->getI18nPaths(), $languageIds, $local);
131
+        return $name::get( self::aimeos()->getI18nPaths(), $languageIds, $local );
132 132
     }
133 133
 
134 134
 
@@ -139,22 +139,22 @@  discard block
 block discarded – undo
139 139
      * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface|null $request Request object
140 140
      * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
141 141
      */
142
-    public static function locale(\Aimeos\MShop\ContextIface $context,
143
-        \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null) : \Aimeos\MShop\Locale\Item\Iface
142
+    public static function locale( \Aimeos\MShop\ContextIface $context,
143
+        \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null ) : \Aimeos\MShop\Locale\Item\Iface
144 144
     {
145
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_frontend'])) {
146
-            if (($name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_frontend']) instanceof \Closure) {
147
-                return $name($context, $request);
145
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_frontend'] ) ) {
146
+            if( ( $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_frontend'] ) instanceof \Closure ) {
147
+                return $name( $context, $request );
148 148
             }
149 149
         }
150 150
 
151 151
         $name = 'Aimeos\Aimeos\Base\Locale';
152 152
 
153
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale'])) {
153
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale'] ) ) {
154 154
             $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale'];
155 155
         }
156 156
 
157
-        return $name::get($context, $request);
157
+        return $name::get( $context, $request );
158 158
     }
159 159
 
160 160
 
@@ -165,22 +165,22 @@  discard block
 block discarded – undo
165 165
      * @param string $sitecode Unique site code
166 166
      * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
167 167
      */
168
-    public static function getLocaleBackend(\Aimeos\MShop\ContextIface $context,
169
-        string $sitecode) : \Aimeos\MShop\Locale\Item\Iface
168
+    public static function getLocaleBackend( \Aimeos\MShop\ContextIface $context,
169
+        string $sitecode ) : \Aimeos\MShop\Locale\Item\Iface
170 170
     {
171
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_backend'])) {
172
-            if (($name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_backend']) instanceof \Closure) {
173
-                return $name($context, $sitecode);
171
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_backend'] ) ) {
172
+            if( ( $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_backend'] ) instanceof \Closure ) {
173
+                return $name( $context, $sitecode );
174 174
             }
175 175
         }
176 176
 
177 177
         $name = 'Aimeos\Aimeos\Base\Locale';
178 178
 
179
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale'])) {
179
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale'] ) ) {
180 180
             $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale'];
181 181
         }
182 182
 
183
-        return $name::getBackend($context, $sitecode);
183
+        return $name::getBackend( $context, $sitecode );
184 184
     }
185 185
 
186 186
 
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
     public static function getVersion() : string
193 193
     {
194 194
         $match = [];
195
-        $content = @file_get_contents(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'ext_emconf.php');
195
+        $content = @file_get_contents( dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'ext_emconf.php' );
196 196
 
197
-        if (preg_match("/'version' => '([^']+)'/", $content, $match) === 1) {
197
+        if( preg_match( "/'version' => '([^']+)'/", $content, $match ) === 1 ) {
198 198
             return $match[1];
199 199
         }
200 200
 
@@ -212,18 +212,18 @@  discard block
 block discarded – undo
212 212
      * @param string|null $langid ISO code of the current language ("de"/"de_CH") or null for no translation
213 213
      * @return \Aimeos\Base\View\Iface View object
214 214
      */
215
-    public static function view(\Aimeos\MShop\ContextIface $context, $uriBuilder, array $templatePaths,
216
-        \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null, string $langid = null) : \Aimeos\Base\View\Iface
215
+    public static function view( \Aimeos\MShop\ContextIface $context, $uriBuilder, array $templatePaths,
216
+        \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null, string $langid = null ) : \Aimeos\Base\View\Iface
217 217
     {
218 218
         $name = 'Aimeos\Aimeos\Base\View';
219 219
 
220
-        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view'])) {
221
-            if (($name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view']) instanceof \Closure) {
222
-                return $name($context, $uriBuilder, $templatePaths, $request, $langid);
220
+        if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view'] ) ) {
221
+            if( ( $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view'] ) instanceof \Closure ) {
222
+                return $name( $context, $uriBuilder, $templatePaths, $request, $langid );
223 223
             }
224 224
         }
225 225
 
226
-        return $name::get($context, $uriBuilder, $templatePaths, $request, $langid);
226
+        return $name::get( $context, $uriBuilder, $templatePaths, $request, $langid );
227 227
     }
228 228
 
229 229
 
@@ -234,24 +234,24 @@  discard block
 block discarded – undo
234 234
      * @return array Mulit-dimensional, associative list of key/value pairs
235 235
      * @throws Exception If parsing the configuration string fails
236 236
      */
237
-    public static function parseTS(string $tsString) : array
237
+    public static function parseTS( string $tsString ) : array
238 238
     {
239
-        $parser = GeneralUtility::makeInstance('TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser');
240
-        $parser->parse(TypoScriptParser::checkIncludeLines($tsString));
239
+        $parser = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser' );
240
+        $parser->parse( TypoScriptParser::checkIncludeLines( $tsString ) );
241 241
 
242
-        if (!empty($parser->errors)) {
243
-            throw new \InvalidArgumentException('Invalid TypoScript: \"' . $tsString . "\"\n" . print_r($parser->errors, true));
242
+        if( !empty( $parser->errors ) ) {
243
+            throw new \InvalidArgumentException( 'Invalid TypoScript: \"' . $tsString . "\"\n" . print_r( $parser->errors, true ) );
244 244
         }
245 245
 
246
-        $service = GeneralUtility::makeInstance('TYPO3\CMS\Core\TypoScript\TypoScriptService');
247
-        $tsConfig = $service->convertTypoScriptArrayToPlainArray($parser->setup);
246
+        $service = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\TypoScript\TypoScriptService' );
247
+        $tsConfig = $service->convertTypoScriptArrayToPlainArray( $parser->setup );
248 248
 
249 249
         // Allows "plugin.tx_aimeos.settings." prefix everywhere
250
-        if (isset($tsConfig['plugin']['tx_aimeos']['settings'])
251
-            && is_array($tsConfig['plugin']['tx_aimeos']['settings'])
250
+        if( isset( $tsConfig['plugin']['tx_aimeos']['settings'] )
251
+            && is_array( $tsConfig['plugin']['tx_aimeos']['settings'] )
252 252
         ) {
253
-            $tsConfig = array_replace_recursive($tsConfig['plugin']['tx_aimeos']['settings'], $tsConfig);
254
-            unset($tsConfig['plugin']['tx_aimeos']);
253
+            $tsConfig = array_replace_recursive( $tsConfig['plugin']['tx_aimeos']['settings'], $tsConfig );
254
+            unset( $tsConfig['plugin']['tx_aimeos'] );
255 255
         }
256 256
 
257 257
         return $tsConfig;
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
      */
266 266
     public static function logout()
267 267
     {
268
-        $context = self::context(self::config());
269
-        $context->setLocale(self::locale($context));
268
+        $context = self::context( self::config() );
269
+        $context->setLocale( self::locale( $context ) );
270 270
 
271 271
         \Aimeos\Controller\Frontend::create( $context, 'basket' )->clear();
272 272
 
273 273
         $session = $context->session();
274
-        $session->remove(array_keys($session->get('aimeos/basket/list', [])));
275
-        $session->remove(array_keys($session->get('aimeos/basket/cache', [])));
274
+        $session->remove( array_keys( $session->get( 'aimeos/basket/list', [] ) ) );
275
+        $session->remove( array_keys( $session->get( 'aimeos/basket/cache', [] ) ) );
276 276
     }
277 277
 
278 278
 
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
      *
286 286
      * @return void
287 287
      */
288
-    public static function clearCache(array $cacheType)
288
+    public static function clearCache( array $cacheType )
289 289
     {
290
-        if (isset($cacheType['cacheCmd']) && $cacheType['cacheCmd'] === 'all'
291
-            && (bool) static::getExtConfig('useAPC', false) === true
292
-            && function_exists('apcu_clear_cache')
290
+        if( isset( $cacheType['cacheCmd'] ) && $cacheType['cacheCmd'] === 'all'
291
+            && (bool) static::getExtConfig( 'useAPC', false ) === true
292
+            && function_exists( 'apcu_clear_cache' )
293 293
         ) {
294 294
             apcu_clear_cache();
295 295
         }
Please login to merge, or discard this patch.