Passed
Push — master ( 9a6d60...09efdf )
by Morris
12:40 queued 01:53
created
lib/private/AppFramework/OCS/V1Response.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -27,52 +27,52 @@
 block discarded – undo
27 27
 
28 28
 class V1Response extends BaseResponse {
29 29
 
30
-	/**
31
-	 * The V1 endpoint has very limited http status codes basically everything
32
-	 * is status 200 except 401
33
-	 *
34
-	 * @return int
35
-	 */
36
-	public function getStatus() {
37
-		$status  = parent::getStatus();
38
-		if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) {
39
-			return Http::STATUS_UNAUTHORIZED;
40
-		}
30
+    /**
31
+     * The V1 endpoint has very limited http status codes basically everything
32
+     * is status 200 except 401
33
+     *
34
+     * @return int
35
+     */
36
+    public function getStatus() {
37
+        $status  = parent::getStatus();
38
+        if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) {
39
+            return Http::STATUS_UNAUTHORIZED;
40
+        }
41 41
 
42
-		return Http::STATUS_OK;
43
-	}
42
+        return Http::STATUS_OK;
43
+    }
44 44
 
45
-	/**
46
-	 * In v1 all OK is 100
47
-	 *
48
-	 * @return int
49
-	 */
50
-	public function getOCSStatus() {
51
-		$status = parent::getOCSStatus();
45
+    /**
46
+     * In v1 all OK is 100
47
+     *
48
+     * @return int
49
+     */
50
+    public function getOCSStatus() {
51
+        $status = parent::getOCSStatus();
52 52
 
53
-		if ($status === Http::STATUS_OK) {
54
-			return 100;
55
-		}
53
+        if ($status === Http::STATUS_OK) {
54
+            return 100;
55
+        }
56 56
 
57
-		return $status;
58
-	}
57
+        return $status;
58
+    }
59 59
 
60
-	/**
61
-	 * Construct the meta part of the response
62
-	 * And then late the base class render
63
-	 *
64
-	 * @return string
65
-	 */
66
-	public function render() {
67
-		$meta = [
68
-			'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure',
69
-			'statuscode' => $this->getOCSStatus(),
70
-			'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage,
71
-		];
60
+    /**
61
+     * Construct the meta part of the response
62
+     * And then late the base class render
63
+     *
64
+     * @return string
65
+     */
66
+    public function render() {
67
+        $meta = [
68
+            'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure',
69
+            'statuscode' => $this->getOCSStatus(),
70
+            'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage,
71
+        ];
72 72
 
73
-		$meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : '';
74
-		$meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: '';
73
+        $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : '';
74
+        $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: '';
75 75
 
76
-		return $this->renderResult($meta);
77
-	}
76
+        return $this->renderResult($meta);
77
+    }
78 78
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return int
35 35
 	 */
36 36
 	public function getStatus() {
37
-		$status  = parent::getStatus();
37
+		$status = parent::getStatus();
38 38
 		if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) {
39 39
 			return Http::STATUS_UNAUTHORIZED;
40 40
 		}
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 			'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage,
71 71
 		];
72 72
 
73
-		$meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : '';
74
-		$meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: '';
73
+		$meta['totalitems'] = $this->itemsCount !== null ? (string) $this->itemsCount : '';
74
+		$meta['itemsperpage'] = $this->itemsPerPage !== null ? (string) $this->itemsPerPage : '';
75 75
 
76 76
 		return $this->renderResult($meta);
77 77
 	}
Please login to merge, or discard this patch.
lib/private/AppFramework/Routing/RouteConfig.php 2 patches
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -36,242 +36,242 @@
 block discarded – undo
36 36
  * @package OC\AppFramework\routing
37 37
  */
38 38
 class RouteConfig {
39
-	/** @var DIContainer */
40
-	private $container;
41
-
42
-	/** @var IRouter */
43
-	private $router;
44
-
45
-	/** @var array */
46
-	private $routes;
47
-
48
-	/** @var string */
49
-	private $appName;
50
-
51
-	/** @var string[] */
52
-	private $controllerNameCache = [];
53
-
54
-	/**
55
-	 * @param \OC\AppFramework\DependencyInjection\DIContainer $container
56
-	 * @param \OCP\Route\IRouter $router
57
-	 * @param array $routes
58
-	 * @internal param $appName
59
-	 */
60
-	public function __construct(DIContainer $container, IRouter $router, $routes) {
61
-		$this->routes = $routes;
62
-		$this->container = $container;
63
-		$this->router = $router;
64
-		$this->appName = $container['AppName'];
65
-	}
66
-
67
-	/**
68
-	 * The routes and resource will be registered to the \OCP\Route\IRouter
69
-	 */
70
-	public function register() {
71
-
72
-		// parse simple
73
-		$this->processSimpleRoutes($this->routes);
74
-
75
-		// parse resources
76
-		$this->processResources($this->routes);
77
-
78
-		/*
39
+    /** @var DIContainer */
40
+    private $container;
41
+
42
+    /** @var IRouter */
43
+    private $router;
44
+
45
+    /** @var array */
46
+    private $routes;
47
+
48
+    /** @var string */
49
+    private $appName;
50
+
51
+    /** @var string[] */
52
+    private $controllerNameCache = [];
53
+
54
+    /**
55
+     * @param \OC\AppFramework\DependencyInjection\DIContainer $container
56
+     * @param \OCP\Route\IRouter $router
57
+     * @param array $routes
58
+     * @internal param $appName
59
+     */
60
+    public function __construct(DIContainer $container, IRouter $router, $routes) {
61
+        $this->routes = $routes;
62
+        $this->container = $container;
63
+        $this->router = $router;
64
+        $this->appName = $container['AppName'];
65
+    }
66
+
67
+    /**
68
+     * The routes and resource will be registered to the \OCP\Route\IRouter
69
+     */
70
+    public function register() {
71
+
72
+        // parse simple
73
+        $this->processSimpleRoutes($this->routes);
74
+
75
+        // parse resources
76
+        $this->processResources($this->routes);
77
+
78
+        /*
79 79
 		 * OCS routes go into a different collection
80 80
 		 */
81
-		$oldCollection = $this->router->getCurrentCollection();
82
-		$this->router->useCollection($oldCollection.'.ocs');
83
-
84
-		// parse ocs simple routes
85
-		$this->processOCS($this->routes);
86
-
87
-		$this->router->useCollection($oldCollection);
88
-	}
89
-
90
-	private function processOCS(array $routes) {
91
-		$ocsRoutes = isset($routes['ocs']) ? $routes['ocs'] : [];
92
-		foreach ($ocsRoutes as $ocsRoute) {
93
-			$name = $ocsRoute['name'];
94
-			$postfix = '';
95
-
96
-			if (isset($ocsRoute['postfix'])) {
97
-				$postfix = $ocsRoute['postfix'];
98
-			}
99
-
100
-			if (isset($ocsRoute['root'])) {
101
-				$root = $ocsRoute['root'];
102
-			} else {
103
-				$root = '/apps/'.$this->appName;
104
-			}
105
-
106
-			$url = $root . $ocsRoute['url'];
107
-			$verb = isset($ocsRoute['verb']) ? strtoupper($ocsRoute['verb']) : 'GET';
108
-
109
-			$split = explode('#', $name, 2);
110
-			if (count($split) != 2) {
111
-				throw new \UnexpectedValueException('Invalid route name');
112
-			}
113
-			$controller = $split[0];
114
-			$action = $split[1];
115
-
116
-			$controllerName = $this->buildControllerName($controller);
117
-			$actionName = $this->buildActionName($action);
118
-
119
-			// register the route
120
-			$handler = new RouteActionHandler($this->container, $controllerName, $actionName);
121
-
122
-			$router = $this->router->create('ocs.'.$this->appName.'.'.$controller.'.'.$action . $postfix, $url)
123
-				->method($verb)
124
-				->action($handler);
125
-
126
-			// optionally register requirements for route. This is used to
127
-			// tell the route parser how url parameters should be matched
128
-			if(array_key_exists('requirements', $ocsRoute)) {
129
-				$router->requirements($ocsRoute['requirements']);
130
-			}
131
-
132
-			// optionally register defaults for route. This is used to
133
-			// tell the route parser how url parameters should be default valued
134
-			if(array_key_exists('defaults', $ocsRoute)) {
135
-				$router->defaults($ocsRoute['defaults']);
136
-			}
137
-		}
138
-	}
139
-
140
-	/**
141
-	 * Creates one route base on the give configuration
142
-	 * @param array $routes
143
-	 * @throws \UnexpectedValueException
144
-	 */
145
-	private function processSimpleRoutes($routes)
146
-	{
147
-		$simpleRoutes = isset($routes['routes']) ? $routes['routes'] : array();
148
-		foreach ($simpleRoutes as $simpleRoute) {
149
-			$name = $simpleRoute['name'];
150
-			$postfix = '';
151
-
152
-			if (isset($simpleRoute['postfix'])) {
153
-				$postfix = $simpleRoute['postfix'];
154
-			}
155
-
156
-			$url = $simpleRoute['url'];
157
-			$verb = isset($simpleRoute['verb']) ? strtoupper($simpleRoute['verb']) : 'GET';
158
-
159
-			$split = explode('#', $name, 2);
160
-			if (count($split) != 2) {
161
-				throw new \UnexpectedValueException('Invalid route name');
162
-			}
163
-			$controller = $split[0];
164
-			$action = $split[1];
165
-
166
-			$controllerName = $this->buildControllerName($controller);
167
-			$actionName = $this->buildActionName($action);
168
-
169
-			// register the route
170
-			$handler = new RouteActionHandler($this->container, $controllerName, $actionName);
171
-			$router = $this->router->create($this->appName.'.'.$controller.'.'.$action . $postfix, $url)
172
-							->method($verb)
173
-							->action($handler);
174
-
175
-			// optionally register requirements for route. This is used to
176
-			// tell the route parser how url parameters should be matched
177
-			if(array_key_exists('requirements', $simpleRoute)) {
178
-				$router->requirements($simpleRoute['requirements']);
179
-			}
180
-
181
-			// optionally register defaults for route. This is used to
182
-			// tell the route parser how url parameters should be default valued
183
-			if(array_key_exists('defaults', $simpleRoute)) {
184
-				$router->defaults($simpleRoute['defaults']);
185
-			}
186
-		}
187
-	}
188
-
189
-	/**
190
-	 * For a given name and url restful routes are created:
191
-	 *  - index
192
-	 *  - show
193
-	 *  - new
194
-	 *  - create
195
-	 *  - update
196
-	 *  - destroy
197
-	 *
198
-	 * @param array $routes
199
-	 */
200
-	private function processResources($routes)
201
-	{
202
-		// declaration of all restful actions
203
-		$actions = array(
204
-			array('name' => 'index', 'verb' => 'GET', 'on-collection' => true),
205
-			array('name' => 'show', 'verb' => 'GET'),
206
-			array('name' => 'create', 'verb' => 'POST', 'on-collection' => true),
207
-			array('name' => 'update', 'verb' => 'PUT'),
208
-			array('name' => 'destroy', 'verb' => 'DELETE'),
209
-		);
210
-
211
-		$resources = isset($routes['resources']) ? $routes['resources'] : array();
212
-		foreach ($resources as $resource => $config) {
213
-
214
-			// the url parameter used as id to the resource
215
-			foreach($actions as $action) {
216
-				$url = $config['url'];
217
-				$method = $action['name'];
218
-				$verb = isset($action['verb']) ? strtoupper($action['verb']) : 'GET';
219
-				$collectionAction = isset($action['on-collection']) ? $action['on-collection'] : false;
220
-				if (!$collectionAction) {
221
-					$url = $url . '/{id}';
222
-				}
223
-				if (isset($action['url-postfix'])) {
224
-					$url = $url . '/' . $action['url-postfix'];
225
-				}
226
-
227
-				$controller = $resource;
228
-
229
-				$controllerName = $this->buildControllerName($controller);
230
-				$actionName = $this->buildActionName($method);
231
-
232
-				$routeName = $this->appName . '.' . strtolower($resource) . '.' . strtolower($method);
233
-
234
-				$this->router->create($routeName, $url)->method($verb)->action(
235
-					new RouteActionHandler($this->container, $controllerName, $actionName)
236
-				);
237
-			}
238
-		}
239
-	}
240
-
241
-	/**
242
-	 * Based on a given route name the controller name is generated
243
-	 * @param string $controller
244
-	 * @return string
245
-	 */
246
-	private function buildControllerName($controller)
247
-	{
248
-		if (!isset($this->controllerNameCache[$controller])) {
249
-			$this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller';
250
-		}
251
-		return $this->controllerNameCache[$controller];
252
-	}
253
-
254
-	/**
255
-	 * Based on the action part of the route name the controller method name is generated
256
-	 * @param string $action
257
-	 * @return string
258
-	 */
259
-	private function buildActionName($action) {
260
-		return $this->underScoreToCamelCase($action);
261
-	}
262
-
263
-	/**
264
-	 * Underscored strings are converted to camel case strings
265
-	 * @param string $str
266
-	 * @return string
267
-	 */
268
-	private function underScoreToCamelCase($str) {
269
-		$pattern = "/_[a-z]?/";
270
-		return preg_replace_callback(
271
-			$pattern,
272
-			function ($matches) {
273
-				return strtoupper(ltrim($matches[0], "_"));
274
-			},
275
-			$str);
276
-	}
81
+        $oldCollection = $this->router->getCurrentCollection();
82
+        $this->router->useCollection($oldCollection.'.ocs');
83
+
84
+        // parse ocs simple routes
85
+        $this->processOCS($this->routes);
86
+
87
+        $this->router->useCollection($oldCollection);
88
+    }
89
+
90
+    private function processOCS(array $routes) {
91
+        $ocsRoutes = isset($routes['ocs']) ? $routes['ocs'] : [];
92
+        foreach ($ocsRoutes as $ocsRoute) {
93
+            $name = $ocsRoute['name'];
94
+            $postfix = '';
95
+
96
+            if (isset($ocsRoute['postfix'])) {
97
+                $postfix = $ocsRoute['postfix'];
98
+            }
99
+
100
+            if (isset($ocsRoute['root'])) {
101
+                $root = $ocsRoute['root'];
102
+            } else {
103
+                $root = '/apps/'.$this->appName;
104
+            }
105
+
106
+            $url = $root . $ocsRoute['url'];
107
+            $verb = isset($ocsRoute['verb']) ? strtoupper($ocsRoute['verb']) : 'GET';
108
+
109
+            $split = explode('#', $name, 2);
110
+            if (count($split) != 2) {
111
+                throw new \UnexpectedValueException('Invalid route name');
112
+            }
113
+            $controller = $split[0];
114
+            $action = $split[1];
115
+
116
+            $controllerName = $this->buildControllerName($controller);
117
+            $actionName = $this->buildActionName($action);
118
+
119
+            // register the route
120
+            $handler = new RouteActionHandler($this->container, $controllerName, $actionName);
121
+
122
+            $router = $this->router->create('ocs.'.$this->appName.'.'.$controller.'.'.$action . $postfix, $url)
123
+                ->method($verb)
124
+                ->action($handler);
125
+
126
+            // optionally register requirements for route. This is used to
127
+            // tell the route parser how url parameters should be matched
128
+            if(array_key_exists('requirements', $ocsRoute)) {
129
+                $router->requirements($ocsRoute['requirements']);
130
+            }
131
+
132
+            // optionally register defaults for route. This is used to
133
+            // tell the route parser how url parameters should be default valued
134
+            if(array_key_exists('defaults', $ocsRoute)) {
135
+                $router->defaults($ocsRoute['defaults']);
136
+            }
137
+        }
138
+    }
139
+
140
+    /**
141
+     * Creates one route base on the give configuration
142
+     * @param array $routes
143
+     * @throws \UnexpectedValueException
144
+     */
145
+    private function processSimpleRoutes($routes)
146
+    {
147
+        $simpleRoutes = isset($routes['routes']) ? $routes['routes'] : array();
148
+        foreach ($simpleRoutes as $simpleRoute) {
149
+            $name = $simpleRoute['name'];
150
+            $postfix = '';
151
+
152
+            if (isset($simpleRoute['postfix'])) {
153
+                $postfix = $simpleRoute['postfix'];
154
+            }
155
+
156
+            $url = $simpleRoute['url'];
157
+            $verb = isset($simpleRoute['verb']) ? strtoupper($simpleRoute['verb']) : 'GET';
158
+
159
+            $split = explode('#', $name, 2);
160
+            if (count($split) != 2) {
161
+                throw new \UnexpectedValueException('Invalid route name');
162
+            }
163
+            $controller = $split[0];
164
+            $action = $split[1];
165
+
166
+            $controllerName = $this->buildControllerName($controller);
167
+            $actionName = $this->buildActionName($action);
168
+
169
+            // register the route
170
+            $handler = new RouteActionHandler($this->container, $controllerName, $actionName);
171
+            $router = $this->router->create($this->appName.'.'.$controller.'.'.$action . $postfix, $url)
172
+                            ->method($verb)
173
+                            ->action($handler);
174
+
175
+            // optionally register requirements for route. This is used to
176
+            // tell the route parser how url parameters should be matched
177
+            if(array_key_exists('requirements', $simpleRoute)) {
178
+                $router->requirements($simpleRoute['requirements']);
179
+            }
180
+
181
+            // optionally register defaults for route. This is used to
182
+            // tell the route parser how url parameters should be default valued
183
+            if(array_key_exists('defaults', $simpleRoute)) {
184
+                $router->defaults($simpleRoute['defaults']);
185
+            }
186
+        }
187
+    }
188
+
189
+    /**
190
+     * For a given name and url restful routes are created:
191
+     *  - index
192
+     *  - show
193
+     *  - new
194
+     *  - create
195
+     *  - update
196
+     *  - destroy
197
+     *
198
+     * @param array $routes
199
+     */
200
+    private function processResources($routes)
201
+    {
202
+        // declaration of all restful actions
203
+        $actions = array(
204
+            array('name' => 'index', 'verb' => 'GET', 'on-collection' => true),
205
+            array('name' => 'show', 'verb' => 'GET'),
206
+            array('name' => 'create', 'verb' => 'POST', 'on-collection' => true),
207
+            array('name' => 'update', 'verb' => 'PUT'),
208
+            array('name' => 'destroy', 'verb' => 'DELETE'),
209
+        );
210
+
211
+        $resources = isset($routes['resources']) ? $routes['resources'] : array();
212
+        foreach ($resources as $resource => $config) {
213
+
214
+            // the url parameter used as id to the resource
215
+            foreach($actions as $action) {
216
+                $url = $config['url'];
217
+                $method = $action['name'];
218
+                $verb = isset($action['verb']) ? strtoupper($action['verb']) : 'GET';
219
+                $collectionAction = isset($action['on-collection']) ? $action['on-collection'] : false;
220
+                if (!$collectionAction) {
221
+                    $url = $url . '/{id}';
222
+                }
223
+                if (isset($action['url-postfix'])) {
224
+                    $url = $url . '/' . $action['url-postfix'];
225
+                }
226
+
227
+                $controller = $resource;
228
+
229
+                $controllerName = $this->buildControllerName($controller);
230
+                $actionName = $this->buildActionName($method);
231
+
232
+                $routeName = $this->appName . '.' . strtolower($resource) . '.' . strtolower($method);
233
+
234
+                $this->router->create($routeName, $url)->method($verb)->action(
235
+                    new RouteActionHandler($this->container, $controllerName, $actionName)
236
+                );
237
+            }
238
+        }
239
+    }
240
+
241
+    /**
242
+     * Based on a given route name the controller name is generated
243
+     * @param string $controller
244
+     * @return string
245
+     */
246
+    private function buildControllerName($controller)
247
+    {
248
+        if (!isset($this->controllerNameCache[$controller])) {
249
+            $this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller';
250
+        }
251
+        return $this->controllerNameCache[$controller];
252
+    }
253
+
254
+    /**
255
+     * Based on the action part of the route name the controller method name is generated
256
+     * @param string $action
257
+     * @return string
258
+     */
259
+    private function buildActionName($action) {
260
+        return $this->underScoreToCamelCase($action);
261
+    }
262
+
263
+    /**
264
+     * Underscored strings are converted to camel case strings
265
+     * @param string $str
266
+     * @return string
267
+     */
268
+    private function underScoreToCamelCase($str) {
269
+        $pattern = "/_[a-z]?/";
270
+        return preg_replace_callback(
271
+            $pattern,
272
+            function ($matches) {
273
+                return strtoupper(ltrim($matches[0], "_"));
274
+            },
275
+            $str);
276
+    }
277 277
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 				$root = '/apps/'.$this->appName;
104 104
 			}
105 105
 
106
-			$url = $root . $ocsRoute['url'];
106
+			$url = $root.$ocsRoute['url'];
107 107
 			$verb = isset($ocsRoute['verb']) ? strtoupper($ocsRoute['verb']) : 'GET';
108 108
 
109 109
 			$split = explode('#', $name, 2);
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 			// register the route
120 120
 			$handler = new RouteActionHandler($this->container, $controllerName, $actionName);
121 121
 
122
-			$router = $this->router->create('ocs.'.$this->appName.'.'.$controller.'.'.$action . $postfix, $url)
122
+			$router = $this->router->create('ocs.'.$this->appName.'.'.$controller.'.'.$action.$postfix, $url)
123 123
 				->method($verb)
124 124
 				->action($handler);
125 125
 
126 126
 			// optionally register requirements for route. This is used to
127 127
 			// tell the route parser how url parameters should be matched
128
-			if(array_key_exists('requirements', $ocsRoute)) {
128
+			if (array_key_exists('requirements', $ocsRoute)) {
129 129
 				$router->requirements($ocsRoute['requirements']);
130 130
 			}
131 131
 
132 132
 			// optionally register defaults for route. This is used to
133 133
 			// tell the route parser how url parameters should be default valued
134
-			if(array_key_exists('defaults', $ocsRoute)) {
134
+			if (array_key_exists('defaults', $ocsRoute)) {
135 135
 				$router->defaults($ocsRoute['defaults']);
136 136
 			}
137 137
 		}
@@ -168,19 +168,19 @@  discard block
 block discarded – undo
168 168
 
169 169
 			// register the route
170 170
 			$handler = new RouteActionHandler($this->container, $controllerName, $actionName);
171
-			$router = $this->router->create($this->appName.'.'.$controller.'.'.$action . $postfix, $url)
171
+			$router = $this->router->create($this->appName.'.'.$controller.'.'.$action.$postfix, $url)
172 172
 							->method($verb)
173 173
 							->action($handler);
174 174
 
175 175
 			// optionally register requirements for route. This is used to
176 176
 			// tell the route parser how url parameters should be matched
177
-			if(array_key_exists('requirements', $simpleRoute)) {
177
+			if (array_key_exists('requirements', $simpleRoute)) {
178 178
 				$router->requirements($simpleRoute['requirements']);
179 179
 			}
180 180
 
181 181
 			// optionally register defaults for route. This is used to
182 182
 			// tell the route parser how url parameters should be default valued
183
-			if(array_key_exists('defaults', $simpleRoute)) {
183
+			if (array_key_exists('defaults', $simpleRoute)) {
184 184
 				$router->defaults($simpleRoute['defaults']);
185 185
 			}
186 186
 		}
@@ -212,16 +212,16 @@  discard block
 block discarded – undo
212 212
 		foreach ($resources as $resource => $config) {
213 213
 
214 214
 			// the url parameter used as id to the resource
215
-			foreach($actions as $action) {
215
+			foreach ($actions as $action) {
216 216
 				$url = $config['url'];
217 217
 				$method = $action['name'];
218 218
 				$verb = isset($action['verb']) ? strtoupper($action['verb']) : 'GET';
219 219
 				$collectionAction = isset($action['on-collection']) ? $action['on-collection'] : false;
220 220
 				if (!$collectionAction) {
221
-					$url = $url . '/{id}';
221
+					$url = $url.'/{id}';
222 222
 				}
223 223
 				if (isset($action['url-postfix'])) {
224
-					$url = $url . '/' . $action['url-postfix'];
224
+					$url = $url.'/'.$action['url-postfix'];
225 225
 				}
226 226
 
227 227
 				$controller = $resource;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 				$controllerName = $this->buildControllerName($controller);
230 230
 				$actionName = $this->buildActionName($method);
231 231
 
232
-				$routeName = $this->appName . '.' . strtolower($resource) . '.' . strtolower($method);
232
+				$routeName = $this->appName.'.'.strtolower($resource).'.'.strtolower($method);
233 233
 
234 234
 				$this->router->create($routeName, $url)->method($verb)->action(
235 235
 					new RouteActionHandler($this->container, $controllerName, $actionName)
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	private function buildControllerName($controller)
247 247
 	{
248 248
 		if (!isset($this->controllerNameCache[$controller])) {
249
-			$this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller';
249
+			$this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)).'Controller';
250 250
 		}
251 251
 		return $this->controllerNameCache[$controller];
252 252
 	}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		$pattern = "/_[a-z]?/";
270 270
 		return preg_replace_callback(
271 271
 			$pattern,
272
-			function ($matches) {
272
+			function($matches) {
273 273
 				return strtoupper(ltrim($matches[0], "_"));
274 274
 			},
275 275
 			$str);
Please login to merge, or discard this patch.
lib/private/AppFramework/Routing/RouteActionHandler.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@
 block discarded – undo
29 29
 use \OC\AppFramework\DependencyInjection\DIContainer;
30 30
 
31 31
 class RouteActionHandler {
32
-	private $controllerName;
33
-	private $actionName;
34
-	private $container;
32
+    private $controllerName;
33
+    private $actionName;
34
+    private $container;
35 35
 
36
-	/**
37
-	 * @param string $controllerName
38
-	 * @param string $actionName
39
-	 */
40
-	public function __construct(DIContainer $container, $controllerName, $actionName) {
41
-		$this->controllerName = $controllerName;
42
-		$this->actionName = $actionName;
43
-		$this->container = $container;
44
-	}
36
+    /**
37
+     * @param string $controllerName
38
+     * @param string $actionName
39
+     */
40
+    public function __construct(DIContainer $container, $controllerName, $actionName) {
41
+        $this->controllerName = $controllerName;
42
+        $this->actionName = $actionName;
43
+        $this->container = $container;
44
+    }
45 45
 
46
-	public function __invoke($params) {
47
-		App::main($this->controllerName, $this->actionName, $this->container, $params);
48
-	}
46
+    public function __invoke($params) {
47
+        App::main($this->controllerName, $this->actionName, $this->container, $params);
48
+    }
49 49
 }
Please login to merge, or discard this patch.
lib/private/Share/SearchResultSorter.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -26,51 +26,51 @@
 block discarded – undo
26 26
 use OCP\ILogger;
27 27
 
28 28
 class SearchResultSorter {
29
-	private $search;
30
-	private $encoding;
31
-	private $key;
32
-	private $log;
29
+    private $search;
30
+    private $encoding;
31
+    private $key;
32
+    private $log;
33 33
 
34
-	/**
35
-	 * @param string $search the search term as was given by the user
36
-	 * @param string $key the array key containing the value that should be compared
37
-	 * against
38
-	 * @param string $encoding optional, encoding to use, defaults to UTF-8
39
-	 * @param ILogger $log optional
40
-	 */
41
-	public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
42
-		$this->encoding = $encoding;
43
-		$this->key = $key;
44
-		$this->log = $log;
45
-		$this->search = mb_strtolower($search, $this->encoding);
46
-	}
34
+    /**
35
+     * @param string $search the search term as was given by the user
36
+     * @param string $key the array key containing the value that should be compared
37
+     * against
38
+     * @param string $encoding optional, encoding to use, defaults to UTF-8
39
+     * @param ILogger $log optional
40
+     */
41
+    public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
42
+        $this->encoding = $encoding;
43
+        $this->key = $key;
44
+        $this->log = $log;
45
+        $this->search = mb_strtolower($search, $this->encoding);
46
+    }
47 47
 
48
-	/**
49
-	 * User and Group names matching the search term at the beginning shall appear
50
-	 * on top of the share dialog. Following entries in alphabetical order.
51
-	 * Callback function for usort. http://php.net/usort
52
-	 */
53
-	public function sort($a, $b) {
54
-		if(!isset($a[$this->key]) || !isset($b[$this->key])) {
55
-			if(!is_null($this->log)) {
56
-				$this->log->error('Sharing dialogue: cannot sort due to ' .
57
-								  'missing array key', array('app' => 'core'));
58
-			}
59
-			return 0;
60
-		}
61
-		$nameA = mb_strtolower($a[$this->key], $this->encoding);
62
-		$nameB = mb_strtolower($b[$this->key], $this->encoding);
63
-		$i = mb_strpos($nameA, $this->search, 0, $this->encoding);
64
-		$j = mb_strpos($nameB, $this->search, 0, $this->encoding);
48
+    /**
49
+     * User and Group names matching the search term at the beginning shall appear
50
+     * on top of the share dialog. Following entries in alphabetical order.
51
+     * Callback function for usort. http://php.net/usort
52
+     */
53
+    public function sort($a, $b) {
54
+        if(!isset($a[$this->key]) || !isset($b[$this->key])) {
55
+            if(!is_null($this->log)) {
56
+                $this->log->error('Sharing dialogue: cannot sort due to ' .
57
+                                    'missing array key', array('app' => 'core'));
58
+            }
59
+            return 0;
60
+        }
61
+        $nameA = mb_strtolower($a[$this->key], $this->encoding);
62
+        $nameB = mb_strtolower($b[$this->key], $this->encoding);
63
+        $i = mb_strpos($nameA, $this->search, 0, $this->encoding);
64
+        $j = mb_strpos($nameB, $this->search, 0, $this->encoding);
65 65
 
66
-		if($i === $j || $i > 0 && $j > 0) {
67
-			return strcmp(mb_strtolower($nameA, $this->encoding),
68
-						  mb_strtolower($nameB, $this->encoding));
69
-		} elseif ($i === 0) {
70
-			return -1;
71
-		} else {
72
-			return 1;
73
-		}
74
-	}
66
+        if($i === $j || $i > 0 && $j > 0) {
67
+            return strcmp(mb_strtolower($nameA, $this->encoding),
68
+                            mb_strtolower($nameB, $this->encoding));
69
+        } elseif ($i === 0) {
70
+            return -1;
71
+        } else {
72
+            return 1;
73
+        }
74
+    }
75 75
 }
76 76
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 	 * Callback function for usort. http://php.net/usort
52 52
 	 */
53 53
 	public function sort($a, $b) {
54
-		if(!isset($a[$this->key]) || !isset($b[$this->key])) {
55
-			if(!is_null($this->log)) {
56
-				$this->log->error('Sharing dialogue: cannot sort due to ' .
54
+		if (!isset($a[$this->key]) || !isset($b[$this->key])) {
55
+			if (!is_null($this->log)) {
56
+				$this->log->error('Sharing dialogue: cannot sort due to '.
57 57
 								  'missing array key', array('app' => 'core'));
58 58
 			}
59 59
 			return 0;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$i = mb_strpos($nameA, $this->search, 0, $this->encoding);
64 64
 		$j = mb_strpos($nameB, $this->search, 0, $this->encoding);
65 65
 
66
-		if($i === $j || $i > 0 && $j > 0) {
66
+		if ($i === $j || $i > 0 && $j > 0) {
67 67
 			return strcmp(mb_strtolower($nameA, $this->encoding),
68 68
 						  mb_strtolower($nameB, $this->encoding));
69 69
 		} elseif ($i === 0) {
Please login to merge, or discard this patch.
lib/private/Share/Constants.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
 	const FORMAT_NONE = -1;
37 37
 	const FORMAT_STATUSES = -2;
38
-	const FORMAT_SOURCES = -3;  // ToDo Check if it is still in use otherwise remove it
38
+	const FORMAT_SOURCES = -3; // ToDo Check if it is still in use otherwise remove it
39 39
 
40 40
 	const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls
41 41
 
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@
 block discarded – undo
29 29
 
30 30
 class Constants {
31 31
 
32
-	const SHARE_TYPE_USER = 0;
33
-	const SHARE_TYPE_GROUP = 1;
34
-	// const SHARE_TYPE_USERGROUP = 2; // Internal type used by DefaultShareProvider
35
-	const SHARE_TYPE_LINK = 3;
36
-	const SHARE_TYPE_EMAIL = 4;
37
-	const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
38
-	const SHARE_TYPE_REMOTE = 6;
39
-	const SHARE_TYPE_CIRCLE = 7;
40
-	const SHARE_TYPE_GUEST = 8;
41
-	const SHARE_TYPE_REMOTE_GROUP = 9;
42
-	const SHARE_TYPE_ROOM = 10;
43
-	// const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider
32
+    const SHARE_TYPE_USER = 0;
33
+    const SHARE_TYPE_GROUP = 1;
34
+    // const SHARE_TYPE_USERGROUP = 2; // Internal type used by DefaultShareProvider
35
+    const SHARE_TYPE_LINK = 3;
36
+    const SHARE_TYPE_EMAIL = 4;
37
+    const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
38
+    const SHARE_TYPE_REMOTE = 6;
39
+    const SHARE_TYPE_CIRCLE = 7;
40
+    const SHARE_TYPE_GUEST = 8;
41
+    const SHARE_TYPE_REMOTE_GROUP = 9;
42
+    const SHARE_TYPE_ROOM = 10;
43
+    // const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider
44 44
 
45
-	const FORMAT_NONE = -1;
46
-	const FORMAT_STATUSES = -2;
47
-	const FORMAT_SOURCES = -3;  // ToDo Check if it is still in use otherwise remove it
45
+    const FORMAT_NONE = -1;
46
+    const FORMAT_STATUSES = -2;
47
+    const FORMAT_SOURCES = -3;  // ToDo Check if it is still in use otherwise remove it
48 48
 
49
-	const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls
49
+    const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls
50 50
 
51
-	const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility
51
+    const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility
52 52
 
53
-	protected static $shareTypeUserAndGroups = -1;
54
-	protected static $shareTypeGroupUserUnique = 2;
55
-	protected static $backends = array();
56
-	protected static $backendTypes = array();
57
-	protected static $isResharingAllowed;
53
+    protected static $shareTypeUserAndGroups = -1;
54
+    protected static $shareTypeGroupUserUnique = 2;
55
+    protected static $backends = array();
56
+    protected static $backendTypes = array();
57
+    protected static $isResharingAllowed;
58 58
 }
Please login to merge, or discard this patch.
lib/private/Repair/RemoveRootShares.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -35,107 +35,107 @@
 block discarded – undo
35 35
  */
36 36
 class RemoveRootShares implements IRepairStep {
37 37
 
38
-	/** @var IDBConnection */
39
-	protected $connection;
40
-
41
-	/** @var IUserManager */
42
-	protected $userManager;
43
-
44
-	/** @var IRootFolder */
45
-	protected $rootFolder;
46
-
47
-	/**
48
-	 * RemoveRootShares constructor.
49
-	 *
50
-	 * @param IDBConnection $connection
51
-	 * @param IUserManager $userManager
52
-	 * @param IRootFolder $rootFolder
53
-	 */
54
-	public function __construct(IDBConnection $connection,
55
-								IUserManager $userManager,
56
-								IRootFolder $rootFolder) {
57
-		$this->connection = $connection;
58
-		$this->userManager = $userManager;
59
-		$this->rootFolder = $rootFolder;
60
-	}
61
-
62
-	/**
63
-	 * @return string
64
-	 */
65
-	public function getName() {
66
-		return 'Remove shares of a users root folder';
67
-	}
68
-
69
-	/**
70
-	 * @param IOutput $output
71
-	 */
72
-	public function run(IOutput $output) {
73
-		if ($this->rootSharesExist()) {
74
-			$this->removeRootShares($output);
75
-		}
76
-	}
77
-
78
-	/**
79
-	 * @param IOutput $output
80
-	 */
81
-	private function removeRootShares(IOutput $output) {
82
-		$function = function(IUser $user) use ($output) {
83
-			$userFolder = $this->rootFolder->getUserFolder($user->getUID());
84
-			$fileId = $userFolder->getId();
85
-
86
-			$qb = $this->connection->getQueryBuilder();
87
-			$qb->delete('share')
88
-				->where($qb->expr()->eq('file_source', $qb->createNamedParameter($fileId)))
89
-				->andWhere($qb->expr()->orX(
90
-					$qb->expr()->eq('item_type', $qb->expr()->literal('file')),
91
-					$qb->expr()->eq('item_type', $qb->expr()->literal('folder'))
92
-				));
93
-
94
-			$qb->execute();
95
-
96
-			$output->advance();
97
-		};
98
-
99
-		$output->startProgress($this->userManager->countSeenUsers());
100
-
101
-		$this->userManager->callForSeenUsers($function);
102
-
103
-		$output->finishProgress();
104
-	}
105
-
106
-	/**
107
-	 * Verify if this repair steps is required
108
-	 * It *should* not be necessary in most cases and it can be very
109
-	 * costly.
110
-	 *
111
-	 * @return bool
112
-	 */
113
-	private function rootSharesExist() {
114
-		$qb = $this->connection->getQueryBuilder();
115
-		$qb2 = $this->connection->getQueryBuilder();
116
-
117
-		$qb->select('fileid')
118
-			->from('filecache')
119
-			->where($qb->expr()->eq('path', $qb->expr()->literal('files')));
120
-
121
-		$qb2->select('id')
122
-			->from('share')
123
-			->where($qb2->expr()->in('file_source', $qb2->createFunction($qb->getSQL())))
124
-			->andWhere($qb2->expr()->orX(
125
-				$qb2->expr()->eq('item_type', $qb->expr()->literal('file')),
126
-				$qb2->expr()->eq('item_type', $qb->expr()->literal('folder'))
127
-			))
128
-			->setMaxResults(1);
129
-
130
-		$cursor = $qb2->execute();
131
-		$data = $cursor->fetch();
132
-		$cursor->closeCursor();
133
-
134
-		if ($data === false) {
135
-			return false;
136
-		}
137
-
138
-		return true;
139
-	}
38
+    /** @var IDBConnection */
39
+    protected $connection;
40
+
41
+    /** @var IUserManager */
42
+    protected $userManager;
43
+
44
+    /** @var IRootFolder */
45
+    protected $rootFolder;
46
+
47
+    /**
48
+     * RemoveRootShares constructor.
49
+     *
50
+     * @param IDBConnection $connection
51
+     * @param IUserManager $userManager
52
+     * @param IRootFolder $rootFolder
53
+     */
54
+    public function __construct(IDBConnection $connection,
55
+                                IUserManager $userManager,
56
+                                IRootFolder $rootFolder) {
57
+        $this->connection = $connection;
58
+        $this->userManager = $userManager;
59
+        $this->rootFolder = $rootFolder;
60
+    }
61
+
62
+    /**
63
+     * @return string
64
+     */
65
+    public function getName() {
66
+        return 'Remove shares of a users root folder';
67
+    }
68
+
69
+    /**
70
+     * @param IOutput $output
71
+     */
72
+    public function run(IOutput $output) {
73
+        if ($this->rootSharesExist()) {
74
+            $this->removeRootShares($output);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * @param IOutput $output
80
+     */
81
+    private function removeRootShares(IOutput $output) {
82
+        $function = function(IUser $user) use ($output) {
83
+            $userFolder = $this->rootFolder->getUserFolder($user->getUID());
84
+            $fileId = $userFolder->getId();
85
+
86
+            $qb = $this->connection->getQueryBuilder();
87
+            $qb->delete('share')
88
+                ->where($qb->expr()->eq('file_source', $qb->createNamedParameter($fileId)))
89
+                ->andWhere($qb->expr()->orX(
90
+                    $qb->expr()->eq('item_type', $qb->expr()->literal('file')),
91
+                    $qb->expr()->eq('item_type', $qb->expr()->literal('folder'))
92
+                ));
93
+
94
+            $qb->execute();
95
+
96
+            $output->advance();
97
+        };
98
+
99
+        $output->startProgress($this->userManager->countSeenUsers());
100
+
101
+        $this->userManager->callForSeenUsers($function);
102
+
103
+        $output->finishProgress();
104
+    }
105
+
106
+    /**
107
+     * Verify if this repair steps is required
108
+     * It *should* not be necessary in most cases and it can be very
109
+     * costly.
110
+     *
111
+     * @return bool
112
+     */
113
+    private function rootSharesExist() {
114
+        $qb = $this->connection->getQueryBuilder();
115
+        $qb2 = $this->connection->getQueryBuilder();
116
+
117
+        $qb->select('fileid')
118
+            ->from('filecache')
119
+            ->where($qb->expr()->eq('path', $qb->expr()->literal('files')));
120
+
121
+        $qb2->select('id')
122
+            ->from('share')
123
+            ->where($qb2->expr()->in('file_source', $qb2->createFunction($qb->getSQL())))
124
+            ->andWhere($qb2->expr()->orX(
125
+                $qb2->expr()->eq('item_type', $qb->expr()->literal('file')),
126
+                $qb2->expr()->eq('item_type', $qb->expr()->literal('folder'))
127
+            ))
128
+            ->setMaxResults(1);
129
+
130
+        $cursor = $qb2->execute();
131
+        $data = $cursor->fetch();
132
+        $cursor->closeCursor();
133
+
134
+        if ($data === false) {
135
+            return false;
136
+        }
137
+
138
+        return true;
139
+    }
140 140
 }
141 141
 
Please login to merge, or discard this patch.
lib/private/Repair/MoveUpdaterStepFile.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -28,53 +28,53 @@
 block discarded – undo
28 28
 
29 29
 class MoveUpdaterStepFile implements IRepairStep {
30 30
 
31
-	/** @var \OCP\IConfig */
32
-	protected $config;
31
+    /** @var \OCP\IConfig */
32
+    protected $config;
33 33
 
34
-	/**
35
-	 * @param \OCP\IConfig $config
36
-	 */
37
-	public function __construct($config) {
38
-		$this->config = $config;
39
-	}
34
+    /**
35
+     * @param \OCP\IConfig $config
36
+     */
37
+    public function __construct($config) {
38
+        $this->config = $config;
39
+    }
40 40
 
41
-	public function getName() {
42
-		return 'Move .step file of updater to backup location';
43
-	}
41
+    public function getName() {
42
+        return 'Move .step file of updater to backup location';
43
+    }
44 44
 
45
-	public function run(IOutput $output) {
45
+    public function run(IOutput $output) {
46 46
 
47
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
48
-		$instanceId = $this->config->getSystemValue('instanceid', null);
47
+        $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
48
+        $instanceId = $this->config->getSystemValue('instanceid', null);
49 49
 
50
-		if(!is_string($instanceId) || empty($instanceId)) {
51
-			return;
52
-		}
50
+        if(!is_string($instanceId) || empty($instanceId)) {
51
+            return;
52
+        }
53 53
 
54
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55
-		$stepFile = $updaterFolderPath . '/.step';
56
-		if(file_exists($stepFile)) {
57
-			$output->info('.step file exists');
54
+        $updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55
+        $stepFile = $updaterFolderPath . '/.step';
56
+        if(file_exists($stepFile)) {
57
+            $output->info('.step file exists');
58 58
 
59
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
59
+            $previousStepFile = $updaterFolderPath . '/.step-previous-update';
60 60
 
61
-			// cleanup
62
-			if(file_exists($previousStepFile)) {
63
-				if(\OC_Helper::rmdirr($previousStepFile)) {
64
-					$output->info('.step-previous-update removed');
65
-				} else {
66
-					$output->info('.step-previous-update can\'t be removed - abort move of .step file');
67
-					return;
68
-				}
69
-			}
61
+            // cleanup
62
+            if(file_exists($previousStepFile)) {
63
+                if(\OC_Helper::rmdirr($previousStepFile)) {
64
+                    $output->info('.step-previous-update removed');
65
+                } else {
66
+                    $output->info('.step-previous-update can\'t be removed - abort move of .step file');
67
+                    return;
68
+                }
69
+            }
70 70
 
71
-			// move step file
72
-			if(rename($stepFile, $previousStepFile)) {
73
-				$output->info('.step file moved to .step-previous-update');
74
-			} else {
75
-				$output->warning('.step file can\'t be moved');
76
-			}
77
-		}
78
-	}
71
+            // move step file
72
+            if(rename($stepFile, $previousStepFile)) {
73
+                $output->info('.step file moved to .step-previous-update');
74
+            } else {
75
+                $output->warning('.step file can\'t be moved');
76
+            }
77
+        }
78
+    }
79 79
 }
80 80
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
 
45 45
 	public function run(IOutput $output) {
46 46
 
47
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
47
+		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
48 48
 		$instanceId = $this->config->getSystemValue('instanceid', null);
49 49
 
50
-		if(!is_string($instanceId) || empty($instanceId)) {
50
+		if (!is_string($instanceId) || empty($instanceId)) {
51 51
 			return;
52 52
 		}
53 53
 
54
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55
-		$stepFile = $updaterFolderPath . '/.step';
56
-		if(file_exists($stepFile)) {
54
+		$updaterFolderPath = $dataDir.'/updater-'.$instanceId;
55
+		$stepFile = $updaterFolderPath.'/.step';
56
+		if (file_exists($stepFile)) {
57 57
 			$output->info('.step file exists');
58 58
 
59
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
59
+			$previousStepFile = $updaterFolderPath.'/.step-previous-update';
60 60
 
61 61
 			// cleanup
62
-			if(file_exists($previousStepFile)) {
63
-				if(\OC_Helper::rmdirr($previousStepFile)) {
62
+			if (file_exists($previousStepFile)) {
63
+				if (\OC_Helper::rmdirr($previousStepFile)) {
64 64
 					$output->info('.step-previous-update removed');
65 65
 				} else {
66 66
 					$output->info('.step-previous-update can\'t be removed - abort move of .step file');
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			}
70 70
 
71 71
 			// move step file
72
-			if(rename($stepFile, $previousStepFile)) {
72
+			if (rename($stepFile, $previousStepFile)) {
73 73
 				$output->info('.step file moved to .step-previous-update');
74 74
 			} else {
75 75
 				$output->warning('.step file can\'t be moved');
Please login to merge, or discard this patch.
lib/private/Repair/NC11/FixMountStorages.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -29,50 +29,50 @@
 block discarded – undo
29 29
 
30 30
 class FixMountStorages implements IRepairStep {
31 31
 
32
-	/** @var IDBConnection */
33
-	private $db;
32
+    /** @var IDBConnection */
33
+    private $db;
34 34
 
35
-	/**
36
-	 * @param IDBConnection $db
37
-	 */
38
-	public function __construct(IDBConnection $db) {
39
-		$this->db = $db;
40
-	}
35
+    /**
36
+     * @param IDBConnection $db
37
+     */
38
+    public function __construct(IDBConnection $db) {
39
+        $this->db = $db;
40
+    }
41 41
 
42
-	/**
43
-	 * @return string
44
-	 */
45
-	public function getName() {
46
-		return 'Fix potential broken mount points';
47
-	}
42
+    /**
43
+     * @return string
44
+     */
45
+    public function getName() {
46
+        return 'Fix potential broken mount points';
47
+    }
48 48
 
49
-	public function run(IOutput $output) {
50
-		$query = $this->db->getQueryBuilder();
51
-		$query->select('m.id', 'f.storage')
52
-			->from('mounts', 'm')
53
-			->leftJoin('m', 'filecache', 'f', $query->expr()->eq('m.root_id', 'f.fileid'))
54
-			->where($query->expr()->neq('m.storage_id', 'f.storage'));
49
+    public function run(IOutput $output) {
50
+        $query = $this->db->getQueryBuilder();
51
+        $query->select('m.id', 'f.storage')
52
+            ->from('mounts', 'm')
53
+            ->leftJoin('m', 'filecache', 'f', $query->expr()->eq('m.root_id', 'f.fileid'))
54
+            ->where($query->expr()->neq('m.storage_id', 'f.storage'));
55 55
 
56
-		$update = $this->db->getQueryBuilder();
57
-		$update->update('mounts')
58
-			->set('storage_id', $update->createParameter('storage'))
59
-			->where($query->expr()->eq('id', $update->createParameter('mount')));
56
+        $update = $this->db->getQueryBuilder();
57
+        $update->update('mounts')
58
+            ->set('storage_id', $update->createParameter('storage'))
59
+            ->where($query->expr()->eq('id', $update->createParameter('mount')));
60 60
 
61
-		$result = $query->execute();
62
-		$entriesUpdated = 0;
63
-		while ($row = $result->fetch()) {
64
-			$update->setParameter('storage', $row['storage'], IQueryBuilder::PARAM_INT)
65
-				->setParameter('mount', $row['id'], IQueryBuilder::PARAM_INT);
66
-			$update->execute();
67
-			$entriesUpdated++;
68
-		}
69
-		$result->closeCursor();
61
+        $result = $query->execute();
62
+        $entriesUpdated = 0;
63
+        while ($row = $result->fetch()) {
64
+            $update->setParameter('storage', $row['storage'], IQueryBuilder::PARAM_INT)
65
+                ->setParameter('mount', $row['id'], IQueryBuilder::PARAM_INT);
66
+            $update->execute();
67
+            $entriesUpdated++;
68
+        }
69
+        $result->closeCursor();
70 70
 
71
-		if ($entriesUpdated > 0) {
72
-			$output->info($entriesUpdated . ' mounts updated');
73
-			return;
74
-		}
71
+        if ($entriesUpdated > 0) {
72
+            $output->info($entriesUpdated . ' mounts updated');
73
+            return;
74
+        }
75 75
 
76
-		$output->info('No mounts updated');
77
-	}
76
+        $output->info('No mounts updated');
77
+    }
78 78
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 		$result->closeCursor();
70 70
 
71 71
 		if ($entriesUpdated > 0) {
72
-			$output->info($entriesUpdated . ' mounts updated');
72
+			$output->info($entriesUpdated.' mounts updated');
73 73
 			return;
74 74
 		}
75 75
 
Please login to merge, or discard this patch.
lib/private/Repair/SqliteAutoincrement.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -36,66 +36,66 @@
 block discarded – undo
36 36
  * altered in order to retrigger SQL schema generation through OCSqlitePlatform.
37 37
  */
38 38
 class SqliteAutoincrement implements IRepairStep {
39
-	/**
40
-	 * @var \OC\DB\Connection
41
-	 */
42
-	protected $connection;
39
+    /**
40
+     * @var \OC\DB\Connection
41
+     */
42
+    protected $connection;
43 43
 
44
-	/**
45
-	 * @param \OC\DB\Connection $connection
46
-	 */
47
-	public function __construct($connection) {
48
-		$this->connection = $connection;
49
-	}
44
+    /**
45
+     * @param \OC\DB\Connection $connection
46
+     */
47
+    public function __construct($connection) {
48
+        $this->connection = $connection;
49
+    }
50 50
 
51
-	public function getName() {
52
-		return 'Repair SQLite autoincrement';
53
-	}
51
+    public function getName() {
52
+        return 'Repair SQLite autoincrement';
53
+    }
54 54
 
55
-	/**
56
-	 * Fix mime types
57
-	 */
58
-	public function run(IOutput $out) {
59
-		if (!$this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
60
-			return;
61
-		}
55
+    /**
56
+     * Fix mime types
57
+     */
58
+    public function run(IOutput $out) {
59
+        if (!$this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
60
+            return;
61
+        }
62 62
 
63
-		$sourceSchema = $this->connection->getSchemaManager()->createSchema();
63
+        $sourceSchema = $this->connection->getSchemaManager()->createSchema();
64 64
 
65
-		$schemaDiff = new SchemaDiff();
65
+        $schemaDiff = new SchemaDiff();
66 66
 
67
-		foreach ($sourceSchema->getTables() as $tableSchema) {
68
-			$primaryKey = $tableSchema->getPrimaryKey();
69
-			if (!$primaryKey) {
70
-				continue;
71
-			}
67
+        foreach ($sourceSchema->getTables() as $tableSchema) {
68
+            $primaryKey = $tableSchema->getPrimaryKey();
69
+            if (!$primaryKey) {
70
+                continue;
71
+            }
72 72
 
73
-			$columnNames = $primaryKey->getColumns();
73
+            $columnNames = $primaryKey->getColumns();
74 74
 
75
-			// add a column diff for every primary key column,
76
-			// but do not actually change anything, this will
77
-			// force the generation of SQL statements to alter
78
-			// those tables, which will then trigger the
79
-			// specific SQL code from OCSqlitePlatform
80
-			try {
81
-				$tableDiff = new TableDiff($tableSchema->getName());
82
-				$tableDiff->fromTable = $tableSchema;
83
-				foreach ($columnNames as $columnName) {
84
-					$columnSchema = $tableSchema->getColumn($columnName);
85
-					$columnDiff = new ColumnDiff($columnSchema->getName(), $columnSchema);
86
-					$tableDiff->changedColumns[] = $columnDiff;
87
-					$schemaDiff->changedTables[] = $tableDiff;
88
-				}
89
-			} catch (SchemaException $e) {
90
-				// ignore
91
-			}
92
-		}
75
+            // add a column diff for every primary key column,
76
+            // but do not actually change anything, this will
77
+            // force the generation of SQL statements to alter
78
+            // those tables, which will then trigger the
79
+            // specific SQL code from OCSqlitePlatform
80
+            try {
81
+                $tableDiff = new TableDiff($tableSchema->getName());
82
+                $tableDiff->fromTable = $tableSchema;
83
+                foreach ($columnNames as $columnName) {
84
+                    $columnSchema = $tableSchema->getColumn($columnName);
85
+                    $columnDiff = new ColumnDiff($columnSchema->getName(), $columnSchema);
86
+                    $tableDiff->changedColumns[] = $columnDiff;
87
+                    $schemaDiff->changedTables[] = $tableDiff;
88
+                }
89
+            } catch (SchemaException $e) {
90
+                // ignore
91
+            }
92
+        }
93 93
 
94
-		$this->connection->beginTransaction();
95
-		foreach ($schemaDiff->toSql($this->connection->getDatabasePlatform()) as $sql) {
96
-			$this->connection->query($sql);
97
-		}
98
-		$this->connection->commit();
99
-	}
94
+        $this->connection->beginTransaction();
95
+        foreach ($schemaDiff->toSql($this->connection->getDatabasePlatform()) as $sql) {
96
+            $this->connection->query($sql);
97
+        }
98
+        $this->connection->commit();
99
+    }
100 100
 }
101 101
 
Please login to merge, or discard this patch.