Passed
Push — master ( 84fe44...e690f0 )
by Joas
13:21 queued 12s
created
lib/private/Template/CSSResourceLocator.php 2 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -36,116 +36,116 @@
 block discarded – undo
36 36
 
37 37
 class CSSResourceLocator extends ResourceLocator {
38 38
 
39
-	/** @var SCSSCacher */
40
-	protected $scssCacher;
41
-
42
-	/**
43
-	 * @param ILogger $logger
44
-	 * @param string $theme
45
-	 * @param array $core_map
46
-	 * @param array $party_map
47
-	 * @param SCSSCacher $scssCacher
48
-	 */
49
-	public function __construct(ILogger $logger, $theme, $core_map, $party_map, $scssCacher) {
50
-		$this->scssCacher = $scssCacher;
51
-
52
-		parent::__construct($logger, $theme, $core_map, $party_map);
53
-	}
54
-
55
-	/**
56
-	 * @param string $style
57
-	 */
58
-	public function doFind($style) {
59
-		$app = substr($style, 0, strpos($style, '/'));
60
-		if (strpos($style, '3rdparty') === 0
61
-			&& $this->appendIfExist($this->thirdpartyroot, $style.'.css')
62
-			|| $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $app)
63
-			|| $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss')
64
-			|| $this->appendIfExist($this->serverroot, $style.'.css')
65
-			|| $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
66
-		) {
67
-			return;
68
-		}
69
-		$style = substr($style, strpos($style, '/')+1);
70
-		$app_path = \OC_App::getAppPath($app);
71
-		$app_url = \OC_App::getAppWebPath($app);
72
-
73
-		if ($app_path === false && $app_url === false) {
74
-			$this->logger->error('Could not find resource {resource} to load', [
75
-				'resource' => $app . '/' . $style . '.css',
76
-				'app' => 'cssresourceloader',
77
-			]);
78
-			return;
79
-		}
80
-
81
-		// Account for the possibility of having symlinks in app path. Doing
82
-		// this here instead of above as an empty argument to realpath gets
83
-		// turned into cwd.
84
-		$app_path = realpath($app_path);
85
-
86
-		if (!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) {
87
-			$this->append($app_path, $style.'.css', $app_url);
88
-		}
89
-	}
90
-
91
-	/**
92
-	 * @param string $style
93
-	 */
94
-	public function doFindTheme($style) {
95
-		$theme_dir = 'themes/'.$this->theme.'/';
96
-		$this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$style.'.css')
97
-			|| $this->appendIfExist($this->serverroot, $theme_dir.$style.'.css')
98
-			|| $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$style.'.css');
99
-	}
100
-
101
-	/**
102
-	 * cache and append the scss $file if exist at $root
103
-	 *
104
-	 * @param string $root path to check
105
-	 * @param string $file the filename
106
-	 * @return bool True if the resource was found and cached, false otherwise
107
-	 */
108
-	protected function cacheAndAppendScssIfExist($root, $file, $app = 'core') {
109
-		if (is_file($root.'/'.$file)) {
110
-			if ($this->scssCacher !== null) {
111
-				if ($this->scssCacher->process($root, $file, $app)) {
112
-					$this->append($this->serverroot, $this->scssCacher->getCachedSCSS($app, $file), \OC::$WEBROOT, true, true);
113
-					return true;
114
-				} else {
115
-					$this->logger->warning('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']);
116
-					return false;
117
-				}
118
-			} else {
119
-				return true;
120
-			}
121
-		}
122
-		return false;
123
-	}
124
-
125
-	public function append($root, $file, $webRoot = null, $throw = true, $scss = false) {
126
-		if (!$scss) {
127
-			parent::append($root, $file, $webRoot, $throw);
128
-		} else {
129
-			if (!$webRoot) {
130
-				$webRoot = $this->findWebRoot($root);
131
-
132
-				if ($webRoot === null) {
133
-					$webRoot = '';
134
-					$this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
135
-						'app' => 'lib',
136
-						'root' => $root,
137
-						'file' => $file,
138
-						'webRoot' => $webRoot,
139
-						'throw' => $throw ? 'true' : 'false'
140
-					]);
141
-
142
-					if ($throw && $root === '/') {
143
-						throw new ResourceNotFoundException($file, $webRoot);
144
-					}
145
-				}
146
-			}
147
-
148
-			$this->resources[] = [$webRoot ?: \OC::$WEBROOT, $webRoot, $file];
149
-		}
150
-	}
39
+    /** @var SCSSCacher */
40
+    protected $scssCacher;
41
+
42
+    /**
43
+     * @param ILogger $logger
44
+     * @param string $theme
45
+     * @param array $core_map
46
+     * @param array $party_map
47
+     * @param SCSSCacher $scssCacher
48
+     */
49
+    public function __construct(ILogger $logger, $theme, $core_map, $party_map, $scssCacher) {
50
+        $this->scssCacher = $scssCacher;
51
+
52
+        parent::__construct($logger, $theme, $core_map, $party_map);
53
+    }
54
+
55
+    /**
56
+     * @param string $style
57
+     */
58
+    public function doFind($style) {
59
+        $app = substr($style, 0, strpos($style, '/'));
60
+        if (strpos($style, '3rdparty') === 0
61
+            && $this->appendIfExist($this->thirdpartyroot, $style.'.css')
62
+            || $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $app)
63
+            || $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss')
64
+            || $this->appendIfExist($this->serverroot, $style.'.css')
65
+            || $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
66
+        ) {
67
+            return;
68
+        }
69
+        $style = substr($style, strpos($style, '/')+1);
70
+        $app_path = \OC_App::getAppPath($app);
71
+        $app_url = \OC_App::getAppWebPath($app);
72
+
73
+        if ($app_path === false && $app_url === false) {
74
+            $this->logger->error('Could not find resource {resource} to load', [
75
+                'resource' => $app . '/' . $style . '.css',
76
+                'app' => 'cssresourceloader',
77
+            ]);
78
+            return;
79
+        }
80
+
81
+        // Account for the possibility of having symlinks in app path. Doing
82
+        // this here instead of above as an empty argument to realpath gets
83
+        // turned into cwd.
84
+        $app_path = realpath($app_path);
85
+
86
+        if (!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) {
87
+            $this->append($app_path, $style.'.css', $app_url);
88
+        }
89
+    }
90
+
91
+    /**
92
+     * @param string $style
93
+     */
94
+    public function doFindTheme($style) {
95
+        $theme_dir = 'themes/'.$this->theme.'/';
96
+        $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$style.'.css')
97
+            || $this->appendIfExist($this->serverroot, $theme_dir.$style.'.css')
98
+            || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$style.'.css');
99
+    }
100
+
101
+    /**
102
+     * cache and append the scss $file if exist at $root
103
+     *
104
+     * @param string $root path to check
105
+     * @param string $file the filename
106
+     * @return bool True if the resource was found and cached, false otherwise
107
+     */
108
+    protected function cacheAndAppendScssIfExist($root, $file, $app = 'core') {
109
+        if (is_file($root.'/'.$file)) {
110
+            if ($this->scssCacher !== null) {
111
+                if ($this->scssCacher->process($root, $file, $app)) {
112
+                    $this->append($this->serverroot, $this->scssCacher->getCachedSCSS($app, $file), \OC::$WEBROOT, true, true);
113
+                    return true;
114
+                } else {
115
+                    $this->logger->warning('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']);
116
+                    return false;
117
+                }
118
+            } else {
119
+                return true;
120
+            }
121
+        }
122
+        return false;
123
+    }
124
+
125
+    public function append($root, $file, $webRoot = null, $throw = true, $scss = false) {
126
+        if (!$scss) {
127
+            parent::append($root, $file, $webRoot, $throw);
128
+        } else {
129
+            if (!$webRoot) {
130
+                $webRoot = $this->findWebRoot($root);
131
+
132
+                if ($webRoot === null) {
133
+                    $webRoot = '';
134
+                    $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
135
+                        'app' => 'lib',
136
+                        'root' => $root,
137
+                        'file' => $file,
138
+                        'webRoot' => $webRoot,
139
+                        'throw' => $throw ? 'true' : 'false'
140
+                    ]);
141
+
142
+                    if ($throw && $root === '/') {
143
+                        throw new ResourceNotFoundException($file, $webRoot);
144
+                    }
145
+                }
146
+            }
147
+
148
+            $this->resources[] = [$webRoot ?: \OC::$WEBROOT, $webRoot, $file];
149
+        }
150
+    }
151 151
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@
 block discarded – undo
66 66
 		) {
67 67
 			return;
68 68
 		}
69
-		$style = substr($style, strpos($style, '/')+1);
69
+		$style = substr($style, strpos($style, '/') + 1);
70 70
 		$app_path = \OC_App::getAppPath($app);
71 71
 		$app_url = \OC_App::getAppWebPath($app);
72 72
 
73 73
 		if ($app_path === false && $app_url === false) {
74 74
 			$this->logger->error('Could not find resource {resource} to load', [
75
-				'resource' => $app . '/' . $style . '.css',
75
+				'resource' => $app.'/'.$style.'.css',
76 76
 				'app' => 'cssresourceloader',
77 77
 			]);
78 78
 			return;
Please login to merge, or discard this patch.