Completed
Pull Request — master (#72)
by
unknown
12:10
created
Classes/Service/SvgStoreService.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
         #$this->defs = []; # https://bugs.chromium.org/p/chromium/issues/detail?id=751733#c14
26 26
         $this->svgs = [];
27 27
 
28
-        $this->sitePath = \TYPO3\CMS\Core\Core\Environment::getPublicPath();// [^/]$
28
+        $this->sitePath = \TYPO3\CMS\Core\Core\Environment::getPublicPath(); // [^/]$
29 29
 
30 30
         if (isset($GLOBALS['TSFE']->config['config']['svgstore.']['outputDir']) && !empty($GLOBALS['TSFE']->config['config']['svgstore.']['outputDir'])) {
31
-            $this->outputDir = '/typo3temp/'.$GLOBALS['TSFE']->config['config']['svgstore.']['outputDir'];// TODO; please beautify
31
+            $this->outputDir = '/typo3temp/'.$GLOBALS['TSFE']->config['config']['svgstore.']['outputDir']; // TODO; please beautify
32 32
         }
33 33
 
34 34
         $this->connPool = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         }
54 54
 
55 55
         # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes
56
-        $html['body'] = preg_replace_callback('/<img(?<pre>[^>]*)src="(?<src>\/[^"]+\.svg)"(?<post>[^>]*?)[\s\/]*>/s', function (array $matches): string {// ^[/]
56
+        $html['body'] = preg_replace_callback('/<img(?<pre>[^>]*)src="(?<src>\/[^"]+\.svg)"(?<post>[^>]*?)[\s\/]*>/s', function(array $matches): string {// ^[/]
57 57
             if (!isset($this->svgFileArr[$matches['src']])) { // check usage
58 58
                 return $matches[0];
59 59
             }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         }, $html['body']);
64 64
 
65 65
         # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attributes
66
-        $html['body'] = preg_replace_callback('/<object(?<pre>[^>]*)data="(?<data>\/[^"]+\.svg)"(?<post>[^>]*?)[\s\/]*>(?:<\/object>)/s', function (array $matches): string {// ^[/]
66
+        $html['body'] = preg_replace_callback('/<object(?<pre>[^>]*)data="(?<data>\/[^"]+\.svg)"(?<post>[^>]*?)[\s\/]*>(?:<\/object>)/s', function(array $matches): string {// ^[/]
67 67
             if (!isset($this->svgFileArr[$matches['data']])) { // check usage
68 68
                 return $matches[0];
69 69
             }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     private function convertFilePath(string $path): string
79 79
     {
80
-        return preg_replace('/.svg$|[^\w\-]/', '', str_replace('/', '-', ltrim($path, '/')));// ^[^/]
80
+        return preg_replace('/.svg$|[^\w\-]/', '', str_replace('/', '-', ltrim($path, '/'))); // ^[^/]
81 81
     }
82 82
 
83 83
     private function addFileToSpriteArr(string $hash, string $path): ?array
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         }
88 88
 
89 89
         if (1 === preg_match('/<(?:style|defs|url\()/', $svg)) {
90
-            return null;# check links @ __construct
90
+            return null; # check links @ __construct
91 91
         }
92 92
 
93 93
         $svg = preg_replace('/<\/svg>.*|xlink:|\s(?:(?:width|height|version|xmlns)|(?:[a-z\-]+\:[a-z\-]+))="[^"]*"/s', '', $svg); // clean !?: \s+(?<atr>[\w\-]+)=["\'](?<val>[^"\']+)["\']
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         $svg = preg_replace_callback(
128 128
             '/<use(?<pre>.*?)(?:xlink:)?href="(?<href>\/.+?\.svg)#[^"]+"(?<post>.*?)[\s\/]*>(?:<\/use>)?/s',
129
-            function (array $matches): string {
129
+            function(array $matches): string {
130 130
                 return sprintf('<use%s href="#%s"/>', $matches['pre'].$matches['post'], $this->convertFilePath($matches['href']));
131 131
             },
132 132
             '<svg xmlns="http://www.w3.org/2000/svg">'
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $storageResources = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class)->findAll();
169 169
         foreach ($storageResources as $storage) {
170 170
             if ('relative' == $storage->getConfiguration()['pathType']) {
171
-                $storageResources[$storage->getUid()] = rtrim($storage->getConfiguration()['basePath'], '/');// [^/]$
171
+                $storageResources[$storage->getUid()] = rtrim($storage->getConfiguration()['basePath'], '/'); // [^/]$
172 172
             }
173 173
         }
174 174
         unset($storageResources[0]); // keep!
Please login to merge, or discard this patch.