Code Duplication    Length = 34-34 lines in 2 locations

lib/private/Template/CSSResourceLocator.php 1 location

@@ 119-152 (lines=34) @@
116
		if (!$scss) {
117
			parent::append($root, $file, $webRoot, $throw);
118
		} else {
119
			if (!$webRoot) {
120
				$tmpRoot = $root;
121
				/*
122
				 * traverse the potential web roots upwards in the path
123
				 *
124
				 * example:
125
				 *   - root: /srv/www/apps/myapp
126
				 *   - available mappings: ['/srv/www']
127
				 *
128
				 * First we check if a mapping for /srv/www/apps/myapp is available,
129
				 * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
130
				 * valid web root
131
				 */
132
				do {
133
					if (isset($this->mapping[$tmpRoot])) {
134
						$webRoot = $this->mapping[$tmpRoot];
135
						break;
136
					}
137
138
					if ($tmpRoot === '/') {
139
						$webRoot = '';
140
						$this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
141
							'app' => 'lib',
142
							'root' => $root,
143
							'file' => $file,
144
							'webRoot' => $webRoot,
145
							'throw' => $throw ? 'true' : 'false'
146
						]);
147
						break;
148
					}
149
					$tmpRoot = dirname($tmpRoot);
150
				} while(true);
151
152
			}
153
154
			if ($throw && $tmpRoot === '/') {
155
				throw new ResourceNotFoundException($file, $webRoot);

lib/private/Template/ResourceLocator.php 1 location

@@ 127-160 (lines=34) @@
124
			return;
125
		}
126
127
		if (!$webRoot) {
128
			$tmpRoot = $root;
129
			/*
130
			 * traverse the potential web roots upwards in the path
131
			 *
132
			 * example:
133
			 *   - root: /srv/www/apps/myapp
134
			 *   - available mappings: ['/srv/www']
135
			 *
136
			 * First we check if a mapping for /srv/www/apps/myapp is available,
137
			 * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
138
			 * valid web root
139
			 */
140
			do {
141
				if (isset($this->mapping[$tmpRoot])) {
142
					$webRoot = $this->mapping[$tmpRoot];
143
					break;
144
				}
145
146
				if ($tmpRoot === '/') {
147
					$webRoot = '';
148
					$this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
149
						'app' => 'lib',
150
						'root' => $root,
151
						'file' => $file,
152
						'webRoot' => $webRoot,
153
						'throw' => $throw ? 'true' : 'false'
154
					]);
155
					break;
156
				}
157
				$tmpRoot = dirname($tmpRoot);
158
			} while(true);
159
160
		}
161
		$this->resources[] = array($root, $webRoot, $file);
162
163
		if ($throw && !is_file($root . '/' . $file)) {