Browse code

Adjust legacy code to account for missing class aliases in Contao 5.x

Benjamin Roth authored on24/10/2023 16:02:29
Showing2 changed files
... ...
@@ -23,6 +23,12 @@
23 23
     "contao/manager-plugin": "^2.0",
24 24
     "friendsofphp/php-cs-fixer": "^2.6"
25 25
   },
26
+  "config": {
27
+    "allow-plugins": {
28
+      "contao-components/installer": true,
29
+      "contao/manager-plugin": true
30
+    }
31
+  },
26 32
   "extra": {
27 33
     "contao-manager-plugin": "EsalesMedia\\ContaoSwiperBundle\\ContaoManager\\Plugin"
28 34
   },
... ...
@@ -8,6 +8,12 @@
8 8
  * @license LGPL-3.0+
9 9
  */
10 10
 
11
+use Contao\Backend;
12
+use Contao\ContentModel;
13
+use Contao\Database;
14
+use Contao\DataContainer;
15
+use Contao\Input;
16
+use Contao\Message;
11 17
 
12 18
 /**
13 19
  * Table tl_content
... ...
@@ -321,7 +327,7 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_bgOpacity'] = array
321 327
 $GLOBALS['TL_DCA']['tl_content']['fields']['multiSRC']['load_callback'][] = array('tl_content_eSM_slider', 'setMultiSrcFlags');
322 328
 
323 329
 
324
-class tl_content_eSM_slider extends \Backend
330
+class tl_content_eSM_slider extends Backend
325 331
 {
326 332
 
327 333
   /**
... ...
@@ -336,11 +342,11 @@ class tl_content_eSM_slider extends \Backend
336 342
   /**
337 343
    * Show a hint if a JavaScript library needs to be included in the page layout
338 344
    *
339
-   * @param object
345
+   * @param DataContainer $dc
340 346
    */
341
-  public function showJsLibraryHint($dc)
347
+  public function showJsLibraryHint(DataContainer $dc)
342 348
   {
343
-    if ($_POST || \Input::get('act') != 'edit')
349
+    if ($_POST || Input::get('act') != 'edit')
344 350
     {
345 351
       return;
346 352
     }
... ...
@@ -351,7 +357,7 @@ class tl_content_eSM_slider extends \Backend
351 357
       return;
352 358
     }
353 359
 
354
-    $objCte = \ContentModel::findByPk($dc->id);
360
+    $objCte = ContentModel::findByPk($dc->id);
355 361
 
356 362
     if ($objCte === null)
357 363
     {
... ...
@@ -365,7 +371,7 @@ class tl_content_eSM_slider extends \Backend
365 371
       case 'swiperSliderSlideStart':
366 372
       case 'swiperSliderSlideStop':
367 373
       case 'swiperSliderImage':
368
-        \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplatesJQuery'], 'js_swiper'));
374
+        Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplatesJQuery'], 'js_swiper'));
369 375
         break;
370 376
     }
371 377
   }
... ...
@@ -373,9 +379,9 @@ class tl_content_eSM_slider extends \Backend
373 379
   /**
374 380
    * Automatically insert end element if start element ist about to be added
375 381
    *
376
-   * @param \DataContainer $dc
382
+   * @param DataContainer $dc
377 383
    */
378
-  public function insertEndElement(\DataContainer $dc)
384
+  public function insertEndElement(DataContainer $dc)
379 385
   {
380 386
     $activeRecord = $dc->activeRecord;
381 387
     if (!$activeRecord) {
... ...
@@ -385,7 +391,7 @@ class tl_content_eSM_slider extends \Backend
385 391
     if ($activeRecord->type === 'swiperSliderStart' || $activeRecord->type === 'swiperSliderSlideStart') {
386 392
 
387 393
       // Find the next wrapper element
388
-      $nextElement = \Database::getInstance()
394
+      $nextElement = Database::getInstance()
389 395
         ->prepare("
390 396
 					SELECT type
391 397
 					FROM tl_content
... ...
@@ -409,7 +415,7 @@ class tl_content_eSM_slider extends \Backend
409 415
         || ($activeRecord->type === 'swiperSliderStart' && ($nextElement->type === 'swiperSliderStart'))
410 416
         || ($activeRecord->type === 'swiperSliderSlideStart' && ($nextElement->type === 'swiperSliderSlideStart' || $nextElement->type === 'swiperSliderStart' || $nextElement->type === 'swiperSliderStop'))
411 417
       ) {
412
-        \Database::getInstance()
418
+        Database::getInstance()
413 419
           ->prepare('INSERT INTO tl_content %s')
414 420
           ->set(array(
415 421
             'pid' => $activeRecord->pid,
... ...
@@ -428,11 +434,11 @@ class tl_content_eSM_slider extends \Backend
428 434
    * Dynamically add flags to the "multiSRC" field
429 435
    *
430 436
    * @param mixed                $varValue
431
-   * @param \DataContainer $dc
437
+   * @param DataContainer $dc
432 438
    *
433 439
    * @return mixed
434 440
    */
435
-  public function setMultiSrcFlags($varValue, \DataContainer $dc)
441
+  public function setMultiSrcFlags($varValue, DataContainer $dc)
436 442
   {
437 443
     if ($dc->activeRecord)
438 444
     {