[BUGFIX] Avoid duplicated classes in typolink VH 49/49949/6
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Tue, 20 Sep 2016 15:41:16 +0000 (17:41 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Wed, 21 Sep 2016 08:40:46 +0000 (10:40 +0200)
To avoid duplicated classes in the TypolinkViewHelper,
array_unique is used.

Resolves: #77943
Releases: master, 7.6
Change-Id: I2f87347492700fd21b938ddad3fe3064054e1cae
Reviewed-on: https://review.typo3.org/49949
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/fluid/Classes/ViewHelpers/Link/TypolinkViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/TypolinkViewHelperTest.php

index 53cfa70..20c75e7 100644 (file)
@@ -161,10 +161,8 @@ class TypolinkViewHelper extends AbstractViewHelper
 
         // Combine classes if given in both "parameter" string and "class" argument
         if ($class) {
-            if ($typolinkConfiguration['class']) {
-                $typolinkConfiguration['class'] .= ' ';
-            }
-            $typolinkConfiguration['class'] .= $class;
+            $classes = explode(' ', trim($typolinkConfiguration['class']) . ' ' . trim($class));
+            $typolinkConfiguration['class'] = implode(' ', array_unique(array_filter($classes)));
         }
 
         // Override title if given in title argument
index fc1bb0d..365cd92 100644 (file)
@@ -98,6 +98,14 @@ class TypolinkViewHelperTest extends ViewHelperBaseTestcase
                 '',
                 '42 - "css-class fluid_class"',
             ],
+            'classes are unique' => [
+                '42 - css-class',
+                '',
+                'css-class',
+                '',
+                '',
+                '42 - css-class',
+            ],
             'page with overridden title' => [
                 '42 - - "a link title"',
                 '',