Passed
Push — develop ( 278ae4...27fb2a )
by Jens
02:34
created
cloudcontrol/library/components/cms/ImagesRouting.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,26 +13,26 @@
 block discarded – undo
13 13
 class ImagesRouting implements CmsRouting
14 14
 {
15 15
 
16
-    /**
17
-     * ImagesRouting constructor.
18
-     * @param \library\cc\Request $request
19
-     * @param mixed|string $relativeCmsUri
20
-     * @param CmsComponent $cmsComponent
21
-     */
22
-    public function __construct($request, $relativeCmsUri, $cmsComponent)
23
-    {
24
-        if ($relativeCmsUri == '/images') {
16
+	/**
17
+	 * ImagesRouting constructor.
18
+	 * @param \library\cc\Request $request
19
+	 * @param mixed|string $relativeCmsUri
20
+	 * @param CmsComponent $cmsComponent
21
+	 */
22
+	public function __construct($request, $relativeCmsUri, $cmsComponent)
23
+	{
24
+		if ($relativeCmsUri == '/images') {
25 25
 			$this->overviewRoute($cmsComponent);
26
-        } elseif ($relativeCmsUri == '/images.json') {
26
+		} elseif ($relativeCmsUri == '/images.json') {
27 27
 			$this->jsonRoute($cmsComponent);
28
-        } elseif ($relativeCmsUri == '/images/new') {
28
+		} elseif ($relativeCmsUri == '/images/new') {
29 29
 			$this->newRoute($request, $cmsComponent);
30
-        } elseif ($relativeCmsUri == '/images/delete' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) {
30
+		} elseif ($relativeCmsUri == '/images/delete' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) {
31 31
 			$this->deleteRoute($request, $cmsComponent);
32
-        } elseif ($relativeCmsUri == '/images/show' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) {
32
+		} elseif ($relativeCmsUri == '/images/show' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) {
33 33
 			$this->showRoute($request, $cmsComponent);
34
-        }
35
-    }
34
+		}
35
+	}
36 36
 
37 37
 	/**
38 38
 	 * @param $cmsComponent
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_IMAGES);
65 65
 		if (isset($_FILES[CmsComponent::FILES_PARAMETER_FILE])) {
66 66
 			$cmsComponent->storage->addImage($_FILES[CmsComponent::FILES_PARAMETER_FILE]);
67
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/images');
67
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/images');
68 68
 			exit;
69 69
 		}
70 70
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	private function deleteRoute($request, $cmsComponent)
77 77
 	{
78 78
 		$cmsComponent->storage->deleteImageByName($request::$get[CmsComponent::FILES_PARAMETER_FILE]);
79
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/images');
79
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/images');
80 80
 		exit;
81 81
 	}
82 82
 
Please login to merge, or discard this patch.
cloudcontrol/library/components/cms/DocumentRouting.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,58 +12,58 @@
 block discarded – undo
12 12
 
13 13
 class DocumentRouting implements CmsRouting
14 14
 {
15
-    /**
16
-     * DocumentRouting constructor.
17
-     * @param $request
18
-     * @param $relativeCmsUri
19
-     * @param CmsComponent $cmsComponent
20
-     */
21
-    public function __construct($request, $relativeCmsUri, $cmsComponent)
22
-    {
23
-        if ($relativeCmsUri == '/documents') {
24
-            $cmsComponent->subTemplate = 'cms/documents';
25
-            $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENTS, $cmsComponent->storage->getDocuments());
26
-            $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS);
27
-        }
28
-        $this->documentRouting($request, $relativeCmsUri, $cmsComponent);
29
-        $this->folderRouting($request, $relativeCmsUri, $cmsComponent);
30
-    }
31
-
32
-
33
-    /**
34
-     * @param $request
35
-     * @param $relativeCmsUri
36
-     * @param CmsComponent $cmsComponent
37
-     * @throws \Exception
38
-     */
39
-    private function documentRouting($request, $relativeCmsUri, $cmsComponent)
40
-    {
41
-        if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) {
15
+	/**
16
+	 * DocumentRouting constructor.
17
+	 * @param $request
18
+	 * @param $relativeCmsUri
19
+	 * @param CmsComponent $cmsComponent
20
+	 */
21
+	public function __construct($request, $relativeCmsUri, $cmsComponent)
22
+	{
23
+		if ($relativeCmsUri == '/documents') {
24
+			$cmsComponent->subTemplate = 'cms/documents';
25
+			$cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENTS, $cmsComponent->storage->getDocuments());
26
+			$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS);
27
+		}
28
+		$this->documentRouting($request, $relativeCmsUri, $cmsComponent);
29
+		$this->folderRouting($request, $relativeCmsUri, $cmsComponent);
30
+	}
31
+
32
+
33
+	/**
34
+	 * @param $request
35
+	 * @param $relativeCmsUri
36
+	 * @param CmsComponent $cmsComponent
37
+	 * @throws \Exception
38
+	 */
39
+	private function documentRouting($request, $relativeCmsUri, $cmsComponent)
40
+	{
41
+		if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) {
42 42
 			$this->documentOverviewRoute($request, $cmsComponent);
43
-        } elseif ($relativeCmsUri == '/documents/edit-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
43
+		} elseif ($relativeCmsUri == '/documents/edit-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
44 44
 			$this->editDocumentRoute($request, $cmsComponent);
45
-        } elseif ($relativeCmsUri == '/documents/get-brick' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
45
+		} elseif ($relativeCmsUri == '/documents/get-brick' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
46 46
 			$this->getBrickRoute($request, $cmsComponent);
47
-        } else if ($relativeCmsUri == '/documents/delete-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
47
+		} else if ($relativeCmsUri == '/documents/delete-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
48 48
 			$this->deleteDocumentRoute($request, $cmsComponent);
49
-        }
50
-    }
51
-
52
-    /**
53
-     * @param $request
54
-     * @param $relativeCmsUri
55
-     * @param CmsComponent $cmsComponent
56
-     */
57
-    private function folderRouting($request, $relativeCmsUri, $cmsComponent)
58
-    {
59
-        if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) {
49
+		}
50
+	}
51
+
52
+	/**
53
+	 * @param $request
54
+	 * @param $relativeCmsUri
55
+	 * @param CmsComponent $cmsComponent
56
+	 */
57
+	private function folderRouting($request, $relativeCmsUri, $cmsComponent)
58
+	{
59
+		if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) {
60 60
 			$this->newFolderRoute($request, $cmsComponent);
61
-        } else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
61
+		} else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
62 62
 			$this->editFolderRoute($request, $cmsComponent);
63
-        } else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
63
+		} else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
64 64
 			$this->deleteFolderRoute($request, $cmsComponent);
65
-        }
66
-    }
65
+		}
66
+	}
67 67
 
68 68
 	/**
69 69
 	 * @param $request
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		if (isset($request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE])) {
80 80
 			if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE], $request::$get[CmsComponent::GET_PARAMETER_PATH])) {
81 81
 				$cmsComponent->storage->addDocument($request::$post);
82
-				header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
82
+				header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
83 83
 				exit;
84 84
 			}
85 85
 			$cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT_TYPE, $cmsComponent->storage->getDocumentTypeBySlug($request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE], true));
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		} else {
88 88
 			$documentTypes = $cmsComponent->storage->getDocumentTypes();
89 89
 			if (count($documentTypes) < 1) {
90
-				throw new \Exception('No Document Types defined yet. <a href="' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/configuration/document-types/new">Please do so first.</a>');
90
+				throw new \Exception('No Document Types defined yet. <a href="'.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/configuration/document-types/new">Please do so first.</a>');
91 91
 			}
92 92
 			$cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT_TYPES, $documentTypes);
93 93
 		}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_SMALLEST_IMAGE, $cmsComponent->storage->getSmallestImageSet()->slug);
105 105
 		if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
106 106
 			$cmsComponent->storage->saveDocument($request::$post);
107
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
107
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
108 108
 			exit;
109 109
 		}
110 110
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT, $cmsComponent->storage->getDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]));
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	private function deleteDocumentRoute($request, $cmsComponent)
142 142
 	{
143 143
 		$cmsComponent->storage->deleteDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]);
144
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
144
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
145 145
 		exit;
146 146
 	}
147 147
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS);
156 156
 		if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post[CmsComponent::GET_PARAMETER_PATH])) {
157 157
 			$cmsComponent->storage->addDocumentFolder($request::$post);
158
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
158
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
159 159
 			exit;
160 160
 		}
161 161
 	}
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 		array_pop($path);
175 175
 		$path = implode('/', $path);
176 176
 
177
-		$request::$get[CmsComponent::GET_PARAMETER_PATH] = '/' . $path;
177
+		$request::$get[CmsComponent::GET_PARAMETER_PATH] = '/'.$path;
178 178
 
179 179
 		if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post['content'])) {
180 180
 			$cmsComponent->storage->saveDocumentFolder($request::$post);
181
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
181
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
182 182
 			exit;
183 183
 		}
184 184
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	private function deleteFolderRoute($request, $cmsComponent)
194 194
 	{
195 195
 		$cmsComponent->storage->deleteDocumentFolderBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]);
196
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
196
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
197 197
 		exit;
198 198
 	}
199 199
 }
200 200
\ No newline at end of file
Please login to merge, or discard this patch.
cloudcontrol/library/components/FormComponent.php 2 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	/**
112 112
 	 * Sets variables needed for rendering the form template
113 113
 	 *
114
-	 * @param $storage
114
+	 * @param Storage $storage
115 115
 	 */
116 116
 	private function initialize($storage)
117 117
 	{
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * submitting the form
148 148
 	 *
149 149
 	 * @param $postValues
150
-	 * @param $storage
150
+	 * @param Storage $storage
151 151
 	 */
152 152
 	protected function postSubmit($postValues, $storage)
153 153
 	{
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	/**
172 172
 	 * Checks if this form has been submitted
173 173
 	 *
174
-	 * @param $request
174
+	 * @param \library\cc\Request $request
175 175
 	 *
176 176
 	 * @return bool
177 177
 	 */
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	/**
184 184
 	 *
185 185
 	 *
186
-	 * @param $request
186
+	 * @param \library\cc\Request $request
187 187
 	 */
188 188
 	private function getPostValues($request)
189 189
 	{
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 
309 309
 	/**
310 310
 	 * @param $get
311
-	 * @param $request
311
+	 * @param \library\cc\Request $request
312 312
 	 */
313 313
 	private function resetPathBackup($get, $request)
314 314
 	{
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	}
321 321
 
322 322
 	/**
323
-	 * @param $form
323
+	 * @param string|null $form
324 324
 	 */
325 325
 	private function setFormParameter($form)
326 326
 	{
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		if (isset($_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID])) {
163 163
 			$this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID];
164 164
 		} else {
165
-			$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string)microtime(true);
165
+			$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string) microtime(true);
166 166
 			$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] = false;
167 167
 			$this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID];
168 168
 		}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		$postValues = $request::$post;
191 191
 		$postValues[self::PARAMETER_DOCUMENT_TYPE] = $this->documentType;
192 192
 		$postValues[self::GET_PARAMETER_PATH] = $this->responseFolder;
193
-		$postValues['title'] = date('r') . ' - From: ' . $request::$requestUri;
193
+		$postValues['title'] = date('r').' - From: '.$request::$requestUri;
194 194
 
195 195
 		return $postValues;
196 196
 	}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	private function setFormParameter($form)
326 326
 	{
327 327
 		if ($this->isFormSubmitted($this->request) || $this->isSubmitAllowed() === false) {
328
-			$this->parameters[$this->formParameterName] = '<a name="' . $this->formId . '"></a>' . $this->thankYouMessage;
328
+			$this->parameters[$this->formParameterName] = '<a name="'.$this->formId.'"></a>'.$this->thankYouMessage;
329 329
 		} else {
330 330
 			$this->parameters[$this->formParameterName] = $form;
331 331
 		}
Please login to merge, or discard this patch.
cloudcontrol/library/components/CmsComponent.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 				$whitelistIps = explode(',', $this->parameters[self::PARAMETER_WHITELIST_IPS]);
160 160
 				$whitelistIps = array_map("trim", $whitelistIps);
161 161
 				if (!in_array($remoteAddress, $whitelistIps)) {
162
-					throw new \Exception('Ip address ' . $remoteAddress . ' is not on whitelist');
162
+					throw new \Exception('Ip address '.$remoteAddress.' is not on whitelist');
163 163
 				}
164 164
 			}
165 165
 		}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 				$blacklistIps = explode(',', $this->parameters[self::PARAMETER_BLACKLIST_IPS]);
176 176
 				$blacklistIps = array_map("trim", $blacklistIps);
177 177
 				if (in_array($remoteAddress, $blacklistIps)) {
178
-					throw new \Exception('Ip address ' . $remoteAddress . ' is on blacklist');
178
+					throw new \Exception('Ip address '.$remoteAddress.' is on blacklist');
179 179
 				}
180 180
 			}
181 181
 		}
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			if ($relativeCmsUri == '/log-off') {
220 220
 				$_SESSION[self::SESSION_PARAMETER_CLOUD_CONTROL] = null;
221 221
 				unset($_SESSION[self::SESSION_PARAMETER_CLOUD_CONTROL]);
222
-				header('Location: ' . $request::$subfolders . $this->parameters[self::PARAMETER_CMS_PREFIX]);
222
+				header('Location: '.$request::$subfolders.$this->parameters[self::PARAMETER_CMS_PREFIX]);
223 223
 				exit;
224 224
 			}
225 225
 		}
Please login to merge, or discard this patch.
cloudcontrol/library/storage/JsonStorage.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -892,6 +892,9 @@
 block discarded – undo
892 892
 			}
893 893
 		}
894 894
 
895
+		/**
896
+		 * @param string $path
897
+		 */
895 898
 		private function validateFilename($filename, $path)
896 899
 		{
897 900
 			$fileParts = explode('.', $filename);
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 			if (!empty($doesItExist)) {
122 122
 				throw new \Exception('Trying to add username that already exists.');
123 123
 			}
124
-            $users = $this->repository->users;
125
-            $users[] = $userObj;
126
-            $this->repository->users = $users;
124
+			$users = $this->repository->users;
125
+			$users[] = $userObj;
126
+			$this->repository->users = $users;
127 127
 			$this->save();
128 128
 		}
129 129
 
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
 				$imageObject->size = $postValues['size'];
796 796
 				$imageObject->set = $fileNames;
797 797
 
798
-                $images = $this->repository->images;
798
+				$images = $this->repository->images;
799 799
 				$images[] = $imageObject;
800
-                $this->repository->images = $images;
800
+				$this->repository->images = $images;
801 801
 
802 802
 				$this->save();
803 803
 			} else {
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 		/**
833 833
 		 * @param $filename
834 834
 		 * @return null
835
-         */
835
+		 */
836 836
 		public function getImageByName($filename)
837 837
 		{
838 838
 			$images = $this->getImages();
@@ -883,9 +883,9 @@  discard block
 block discarded – undo
883 883
 				$file->type = $postValues['type'];
884 884
 				$file->size = $postValues['size'];
885 885
 
886
-                $files = $this->repository->files;
886
+				$files = $this->repository->files;
887 887
 				$files[] = $file;
888
-                $this->repository->files = $files;
888
+				$this->repository->files = $files;
889 889
 				$this->save();
890 890
 			} else {
891 891
 				throw new \Exception('Error moving uploaded file');
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 		/**
925 925
 		 * @param $filename
926 926
 		 * @return null
927
-         */
927
+		 */
928 928
 		public function getFileByName($filename)
929 929
 		{
930 930
 			$files = $this->getFiles();
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 		/**
940 940
 		 * @param $filename
941 941
 		 * @throws \Exception
942
-         */
942
+		 */
943 943
 		public function deleteFileByName($filename)
944 944
 		{
945 945
 			$destinationPath = realpath(__DIR__ . '/../../www/files/');
@@ -984,9 +984,9 @@  discard block
 block discarded – undo
984 984
 		{
985 985
 			$documentTypeObject = $this->createDocumentTypeFromPostValues($postValues);
986 986
 
987
-            $documentTypes = $this->repository->documentTypes;
988
-            $documentTypes[] = $documentTypeObject;
989
-            $this->repository->documentTypes = $documentTypes;
987
+			$documentTypes = $this->repository->documentTypes;
988
+			$documentTypes[] = $documentTypeObject;
989
+			$this->repository->documentTypes = $documentTypes;
990 990
 
991 991
 			$this->save();
992 992
 		}
@@ -1132,9 +1132,9 @@  discard block
 block discarded – undo
1132 1132
 		{
1133 1133
 			$brickObject = $this->createBrickFromPostValues($postValues);
1134 1134
 
1135
-            $bricks = $this->repository->bricks;
1136
-            $bricks[] = $brickObject;
1137
-            $this->repository->bricks = $bricks;
1135
+			$bricks = $this->repository->bricks;
1136
+			$bricks[] = $brickObject;
1137
+			$this->repository->bricks = $bricks;
1138 1138
 
1139 1139
 			$this->save();
1140 1140
 		}
@@ -1339,9 +1339,9 @@  discard block
 block discarded – undo
1339 1339
 		{
1340 1340
 			$imageSetObject = $this->createImageSetFromPostValues($postValues);
1341 1341
 
1342
-            $imageSet = $this->repository->imageSet;
1343
-            $imageSet[] = $imageSetObject;
1344
-            $this->repository->imageSet = $imageSet;
1342
+			$imageSet = $this->repository->imageSet;
1343
+			$imageSet[] = $imageSetObject;
1344
+			$this->repository->imageSet = $imageSet;
1345 1345
 
1346 1346
 			$this->save();
1347 1347
 		}
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		 */
34 34
 		private function config()
35 35
 		{
36
-			$storagePath = __DIR__ . '/../../' . $this->storageDir;
36
+			$storagePath = __DIR__.'/../../'.$this->storageDir;
37 37
 			if (realpath($storagePath) === false) {
38 38
 				initFramework($storagePath);
39 39
 				if (Repository::create($storagePath)) {
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 					$repository->init();
42 42
 					$this->repository = $repository;
43 43
 				} else {
44
-					throw new \Exception('Could not create repository directory: ' . $storagePath);
44
+					throw new \Exception('Could not create repository directory: '.$storagePath);
45 45
 				}
46 46
 			} else {
47 47
 				$this->repository = new Repository($storagePath);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		 */
192 192
 		public function getDocumentBySlug($slug)
193 193
 		{
194
-			$documentContainer = $this->getDocumentContainerByPath('/' . $slug);
194
+			$documentContainer = $this->getDocumentContainerByPath('/'.$slug);
195 195
 			$indices = $documentContainer['indices'];
196 196
 
197 197
 			if ($indices === null) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 				// Check for duplicates
237 237
 				foreach ($this->repository->documents as $index => $document) {
238 238
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') {
239
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
239
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
240 240
 					}
241 241
 				}
242 242
 				$this->repository->documents[end($indices)] = $documentFolderObject;
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 				// Check for duplicates
245 245
 				foreach ($previousFolder->content as $index => $document) {
246 246
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'document') {
247
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
247
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
248 248
 					}
249 249
 				}
250
-				$previousFolder->content[end($indices)] = $documentFolderObject ;
250
+				$previousFolder->content[end($indices)] = $documentFolderObject;
251 251
 			}
252 252
 
253 253
 			$this->save();
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 				foreach ($this->repository->documents as $document) {
262 262
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'document') {
263 263
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
264
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
264
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
265 265
 					}
266 266
 				}
267 267
 				$this->repository->documents[] = $documentFolderObject;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 					foreach ($containerFolder->content as $document) {
273 273
 						if ($document->slug == $documentFolderObject->slug && $document->type == 'document') {
274 274
 							// TODO make it so it doesnt throw an exception, but instead shows a warning
275
-							throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
275
+							throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
276 276
 						}
277 277
 					}
278 278
 				}
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 				foreach ($this->repository->documents as $document) {
391 391
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') {
392 392
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
393
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
393
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
394 394
 					}
395 395
 				}
396 396
 				$this->repository->documents[] = $documentFolderObject;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 				foreach ($containerFolder->content as $document) {
412 412
 					if ($document->slug == $documentFolderObject->slug && $document->type == 'folder') {
413 413
 						// TODO make it so it doesnt throw an exception, but instead shows a warning
414
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
414
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
415 415
 					}
416 416
 				}
417 417
 				$folder->content[] = $documentFolderObject;
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
 		 */
464 464
 		public function getDocumentFolderBySlug($slug)
465 465
 		{
466
-			$documentContainer = $this->getDocumentContainerByPath('/' . $slug);
466
+			$documentContainer = $this->getDocumentContainerByPath('/'.$slug);
467 467
 			$indices = $documentContainer['indices'];
468 468
 
469 469
 			$folder = $this->repository->documents;
470 470
 			if ($indices === null) {
471
-				throw new \Exception('Can\'t find folder with slug `' . $slug . '`');
471
+				throw new \Exception('Can\'t find folder with slug `'.$slug.'`');
472 472
 			}
473 473
 			foreach ($indices as $index) {
474 474
 				if ($folder === $this->repository->documents) {
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 				// Check for duplicates
511 511
 				foreach ($this->repository->documents as $index => $document) {
512 512
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') {
513
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
513
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
514 514
 					}
515 515
 				}
516 516
 				$this->repository->documents[end($indices)] = $documentFolderObject;
@@ -518,10 +518,10 @@  discard block
 block discarded – undo
518 518
 				// Check for duplicates
519 519
 				foreach ($previousFolder->content as $index => $document) {
520 520
 					if (end($indices) !== $index && $document->slug == $documentFolderObject->slug && $document->type == 'folder') {
521
-						throw new \Exception('Duplicate slug: ' . $document->slug . ' in folder ' . $postValues['path']);
521
+						throw new \Exception('Duplicate slug: '.$document->slug.' in folder '.$postValues['path']);
522 522
 					}
523 523
 				}
524
-				$previousFolder->content[end($indices)] = $documentFolderObject ;
524
+				$previousFolder->content[end($indices)] = $documentFolderObject;
525 525
 			}
526 526
 
527 527
 			$this->save();
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 					'previousDocument' => $previousDocument
591 591
 				);
592 592
 			} else {
593
-				throw new \Exception('Invalid path: ' . $path);
593
+				throw new \Exception('Invalid path: '.$path);
594 594
 			}
595 595
 		}
596 596
 
@@ -776,13 +776,13 @@  discard block
 block discarded – undo
776 776
 
777 777
 		public function addImage($postValues)
778 778
 		{
779
-			$destinationPath = realpath(__DIR__ . '/../../www/images/');
779
+			$destinationPath = realpath(__DIR__.'/../../www/images/');
780 780
 
781 781
 			$filename = $this->validateFilename($postValues['name'], $destinationPath);
782
-			$destination = $destinationPath . '/' . $filename;
782
+			$destination = $destinationPath.'/'.$filename;
783 783
 
784 784
 			if ($postValues['error'] != '0') {
785
-				throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
785
+				throw new \Exception('Error uploading file. Error code: '.$postValues['error']);
786 786
 			}
787 787
 
788 788
 			if (move_uploaded_file($postValues['tmp_name'], $destination)) {
@@ -807,14 +807,14 @@  discard block
 block discarded – undo
807 807
 
808 808
 		public function deleteImageByName($filename)
809 809
 		{
810
-			$destinationPath = realpath(__DIR__ . '/../../www/images/');
810
+			$destinationPath = realpath(__DIR__.'/../../www/images/');
811 811
 
812 812
 			$images = $this->getImages();
813 813
 
814 814
 			foreach ($images as $key => $image) {
815 815
 				if ($image->file == $filename) {
816 816
 					foreach ($image->set as $imageSetFilename) {
817
-						$destination = $destinationPath . '/' . $imageSetFilename;
817
+						$destination = $destinationPath.'/'.$imageSetFilename;
818 818
 						if (file_exists($destination)) {
819 819
 							unlink($destination);
820 820
 						} else {
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		 */
857 857
 		public function getFiles()
858 858
 		{
859
-			$files =  $this->repository->files;
859
+			$files = $this->repository->files;
860 860
 			usort($files, array($this, 'compareFiles'));
861 861
 			return $files;
862 862
 		}
@@ -868,13 +868,13 @@  discard block
 block discarded – undo
868 868
 
869 869
 		public function addFile($postValues)
870 870
 		{
871
-			$destinationPath = realpath(__DIR__ . '/../../www/files/');
871
+			$destinationPath = realpath(__DIR__.'/../../www/files/');
872 872
 
873 873
 			$filename = $this->validateFilename($postValues['name'], $destinationPath);
874
-			$destination = $destinationPath . '/' . $filename;
874
+			$destination = $destinationPath.'/'.$filename;
875 875
 
876 876
 			if ($postValues['error'] != '0') {
877
-				throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
877
+				throw new \Exception('Error uploading file. Error code: '.$postValues['error']);
878 878
 			}
879 879
 
880 880
 			if (move_uploaded_file($postValues['tmp_name'], $destination)) {
@@ -900,23 +900,23 @@  discard block
 block discarded – undo
900 900
 				array_pop($fileParts);
901 901
 				$fileNameWithoutExtension = implode('-', $fileParts);
902 902
 				$fileNameWithoutExtension = slugify($fileNameWithoutExtension);
903
-				$filename = $fileNameWithoutExtension . '.' . $extension;
903
+				$filename = $fileNameWithoutExtension.'.'.$extension;
904 904
 			} else {
905 905
 				$filename = slugify($filename);
906 906
 			}
907 907
 
908
-			if (file_exists($path . '/' . $filename)) {
908
+			if (file_exists($path.'/'.$filename)) {
909 909
 				$fileParts = explode('.', $filename);
910 910
 				if (count($fileParts) > 1) {
911 911
 					$extension = end($fileParts);
912 912
 					array_pop($fileParts);
913 913
 					$fileNameWithoutExtension = implode('-', $fileParts);
914 914
 					$fileNameWithoutExtension .= '-copy';
915
-					$filename = $fileNameWithoutExtension . '.' . $extension;
915
+					$filename = $fileNameWithoutExtension.'.'.$extension;
916 916
 				} else {
917 917
 					$filename .= '-copy';
918 918
 				}
919
-				return $this->validateFilename($filename,$path);
919
+				return $this->validateFilename($filename, $path);
920 920
 			}
921 921
 			return $filename;
922 922
 		}
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
          */
943 943
 		public function deleteFileByName($filename)
944 944
 		{
945
-			$destinationPath = realpath(__DIR__ . '/../../www/files/');
946
-			$destination = $destinationPath . '/' . $filename;
945
+			$destinationPath = realpath(__DIR__.'/../../www/files/');
946
+			$destination = $destinationPath.'/'.$filename;
947 947
 
948 948
 			if (file_exists($destination)) {
949 949
 				$files = $this->getFiles();
Please login to merge, or discard this patch.
cloudcontrol/library/cc/autoloader.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 spl_autoload_extensions('.php');
3 3
 spl_autoload_register("autoloader");
4 4
 
5
-$rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)) . '/../../') . '/');
5
+$rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)).'/../../').'/');
6 6
 
7 7
 /**
8 8
  * The function to be registered as the default autoload functino
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 	
34 34
 	global $rootPath;
35
-	$file = $rootPath . str_replace('\\', '/', $class) . ".php";
35
+	$file = $rootPath.str_replace('\\', '/', $class).".php";
36 36
 	$debug_backtrace = debug_backtrace();
37 37
 	
38 38
 	if (file_exists($file)) {
39 39
 		require_once($file);
40 40
 		if ($throwException) {
41 41
 			if (class_exists($class, false) === false && interface_exists($class, false) === false) {
42
-				throw new \Exception('Could not load class "' . $class . '" in file ' . $file);
42
+				throw new \Exception('Could not load class "'.$class.'" in file '.$file);
43 43
 			} else {
44 44
 				return true;
45 45
 			}
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	} else {
49 49
 		if (isset($debug_backtrace[2]) && isset($debug_backtrace[2]['file']) && isset($debug_backtrace[2]['line'])) {			
50 50
 			if ($throwException) {
51
-				errorHandler(0, 'Could not load class \'' . $class . '\' in file ' . $rootPath . $file, $debug_backtrace[2]['file'], $debug_backtrace[2]['line']);
51
+				errorHandler(0, 'Could not load class \''.$class.'\' in file '.$rootPath.$file, $debug_backtrace[2]['file'], $debug_backtrace[2]['line']);
52 52
 			} else {
53 53
 				return false;
54 54
 			}			
55 55
 		} else {
56 56
 			if ($throwException) {
57
-				throw new \Exception('Could not load class "' . $class . '" in file ' . $file . "\n" . 'Called from unknown origin.');
57
+				throw new \Exception('Could not load class "'.$class.'" in file '.$file."\n".'Called from unknown origin.');
58 58
 			} else {
59 59
 				return false;
60 60
 			}
Please login to merge, or discard this patch.
cloudcontrol/library/storage/Repository.php 2 patches
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -10,131 +10,131 @@
 block discarded – undo
10 10
 
11 11
 class Repository
12 12
 {
13
-    protected $storagePath;
14
-
15
-    protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users');
16
-
17
-    protected $sitemap;
18
-    protected $sitemapChanges = false;
19
-
20
-    protected $applicationComponents;
21
-    protected $applicationComponentsChanges = false;
22
-
23
-    protected $documentTypes;
24
-    protected $documentTypesChanges = false;
25
-
26
-    protected $bricks;
27
-    protected $bricksChanges = false;
28
-
29
-    protected $imageSet;
30
-    protected $imageSetChanges = false;
31
-
32
-    protected $images;
33
-    protected $imagesChanges = false;
34
-
35
-    protected $files;
36
-    protected $filesChanges = false;
37
-
38
-    protected $users;
39
-    protected $usersChanges = false;
40
-
41
-    /**
42
-     * Repository constructor.
43
-     */
44
-    public function __construct($storagePath)
45
-    {
46
-        $storagePath = realpath($storagePath);
47
-        if (is_dir($storagePath) && $storagePath !== false) {
48
-            $this->storagePath = $storagePath;
49
-        } else {
50
-            throw new \Exception('Repository not yet initialized.');
51
-        }
52
-    }
53
-
54
-    public static function create($storagePath)
55
-    {
56
-        return mkdir($storagePath);
57
-    }
58
-
59
-    public function init()
60
-    {
61
-        $storageDefaultPath = realpath('../library/cc/install/_storage.json');
62
-        $json = file_get_contents($storageDefaultPath);
63
-        $json = json_decode($json);
64
-        $this->sitemap = $json->sitemap;
65
-        $this->sitemapChanges = true;
66
-        $this->applicationComponents = $json->applicationComponents;
67
-        $this->applicationComponentsChanges = true;
68
-        $this->documentTypes = $json->documentTypes;
69
-        $this->documentTypesChanges = true;
70
-        $this->bricks = $json->bricks;
71
-        $this->bricksChanges = true;
72
-        $this->imageSet = $json->imageSet;
73
-        $this->imageSetChanges = true;
74
-        $this->images = $json->images;
75
-        $this->imagesChanges = true;
76
-        $this->files = $json->files;
77
-        $this->filesChanges = true;
78
-        $this->users = $json->users;
79
-        $this->usersChanges = true;
80
-        $this->save();
81
-    }
82
-
83
-    public function __get($name)
84
-    {
85
-        if (isset($this->$name)) {
86
-            if (in_array($name, $this->fileBasedSubsets)) {
87
-                return $this->$name;
88
-            } else {
89
-                dump();
90
-            }
91
-        } else {
92
-            if (in_array($name, $this->fileBasedSubsets)) {
93
-                return $this->loadSubset($name);
94
-            } else {
95
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
96
-            }
97
-        }
98
-    }
99
-
100
-    public function __set($name, $value)
101
-    {
102
-        if (in_array($name, $this->fileBasedSubsets)) {
103
-            $this->$name = $value;
104
-            $changes = $name . 'Changes';
105
-            $this->$changes = true;
106
-        } else {
107
-            throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
108
-        }
109
-    }
110
-
111
-    public function save()
112
-    {
113
-        $this->sitemapChanges ? $this->saveSubset('sitemap') : null;
114
-        $this->applicationComponentsChanges ? $this->saveSubset('applicationComponents') : null;
115
-        $this->documentTypesChanges ? $this->saveSubset('documentTypes') : null;
116
-        $this->bricksChanges ? $this->saveSubset('bricks') : null;
117
-        $this->imageSetChanges ? $this->saveSubset('imageSet') : null;
118
-        $this->imagesChanges ? $this->saveSubset('images') : null;
119
-        $this->filesChanges ? $this->saveSubset('files') : null;
120
-        $this->usersChanges ? $this->saveSubset('users') : null;
121
-    }
122
-
123
-    protected function saveSubset($subset)
124
-    {
125
-        $json = json_encode($this->$subset);
126
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
127
-        file_put_contents($subsetStoragePath, $json);
128
-        $changes = $subset . 'Changes';
129
-        $this->$changes = false;
130
-    }
131
-
132
-    protected function loadSubset($subset)
133
-    {
134
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
135
-        $json = file_get_contents($subsetStoragePath);
136
-        $json = json_decode($json);
137
-        $this->$subset = $json;
138
-        return $json;
139
-    }
13
+	protected $storagePath;
14
+
15
+	protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users');
16
+
17
+	protected $sitemap;
18
+	protected $sitemapChanges = false;
19
+
20
+	protected $applicationComponents;
21
+	protected $applicationComponentsChanges = false;
22
+
23
+	protected $documentTypes;
24
+	protected $documentTypesChanges = false;
25
+
26
+	protected $bricks;
27
+	protected $bricksChanges = false;
28
+
29
+	protected $imageSet;
30
+	protected $imageSetChanges = false;
31
+
32
+	protected $images;
33
+	protected $imagesChanges = false;
34
+
35
+	protected $files;
36
+	protected $filesChanges = false;
37
+
38
+	protected $users;
39
+	protected $usersChanges = false;
40
+
41
+	/**
42
+	 * Repository constructor.
43
+	 */
44
+	public function __construct($storagePath)
45
+	{
46
+		$storagePath = realpath($storagePath);
47
+		if (is_dir($storagePath) && $storagePath !== false) {
48
+			$this->storagePath = $storagePath;
49
+		} else {
50
+			throw new \Exception('Repository not yet initialized.');
51
+		}
52
+	}
53
+
54
+	public static function create($storagePath)
55
+	{
56
+		return mkdir($storagePath);
57
+	}
58
+
59
+	public function init()
60
+	{
61
+		$storageDefaultPath = realpath('../library/cc/install/_storage.json');
62
+		$json = file_get_contents($storageDefaultPath);
63
+		$json = json_decode($json);
64
+		$this->sitemap = $json->sitemap;
65
+		$this->sitemapChanges = true;
66
+		$this->applicationComponents = $json->applicationComponents;
67
+		$this->applicationComponentsChanges = true;
68
+		$this->documentTypes = $json->documentTypes;
69
+		$this->documentTypesChanges = true;
70
+		$this->bricks = $json->bricks;
71
+		$this->bricksChanges = true;
72
+		$this->imageSet = $json->imageSet;
73
+		$this->imageSetChanges = true;
74
+		$this->images = $json->images;
75
+		$this->imagesChanges = true;
76
+		$this->files = $json->files;
77
+		$this->filesChanges = true;
78
+		$this->users = $json->users;
79
+		$this->usersChanges = true;
80
+		$this->save();
81
+	}
82
+
83
+	public function __get($name)
84
+	{
85
+		if (isset($this->$name)) {
86
+			if (in_array($name, $this->fileBasedSubsets)) {
87
+				return $this->$name;
88
+			} else {
89
+				dump();
90
+			}
91
+		} else {
92
+			if (in_array($name, $this->fileBasedSubsets)) {
93
+				return $this->loadSubset($name);
94
+			} else {
95
+				throw new \Exception('Trying to get undefined property from Repository: ' . $name);
96
+			}
97
+		}
98
+	}
99
+
100
+	public function __set($name, $value)
101
+	{
102
+		if (in_array($name, $this->fileBasedSubsets)) {
103
+			$this->$name = $value;
104
+			$changes = $name . 'Changes';
105
+			$this->$changes = true;
106
+		} else {
107
+			throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
108
+		}
109
+	}
110
+
111
+	public function save()
112
+	{
113
+		$this->sitemapChanges ? $this->saveSubset('sitemap') : null;
114
+		$this->applicationComponentsChanges ? $this->saveSubset('applicationComponents') : null;
115
+		$this->documentTypesChanges ? $this->saveSubset('documentTypes') : null;
116
+		$this->bricksChanges ? $this->saveSubset('bricks') : null;
117
+		$this->imageSetChanges ? $this->saveSubset('imageSet') : null;
118
+		$this->imagesChanges ? $this->saveSubset('images') : null;
119
+		$this->filesChanges ? $this->saveSubset('files') : null;
120
+		$this->usersChanges ? $this->saveSubset('users') : null;
121
+	}
122
+
123
+	protected function saveSubset($subset)
124
+	{
125
+		$json = json_encode($this->$subset);
126
+		$subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
127
+		file_put_contents($subsetStoragePath, $json);
128
+		$changes = $subset . 'Changes';
129
+		$this->$changes = false;
130
+	}
131
+
132
+	protected function loadSubset($subset)
133
+	{
134
+		$subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
135
+		$json = file_get_contents($subsetStoragePath);
136
+		$json = json_decode($json);
137
+		$this->$subset = $json;
138
+		return $json;
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             if (in_array($name, $this->fileBasedSubsets)) {
93 93
                 return $this->loadSubset($name);
94 94
             } else {
95
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
95
+                throw new \Exception('Trying to get undefined property from Repository: '.$name);
96 96
             }
97 97
         }
98 98
     }
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
     {
102 102
         if (in_array($name, $this->fileBasedSubsets)) {
103 103
             $this->$name = $value;
104
-            $changes = $name . 'Changes';
104
+            $changes = $name.'Changes';
105 105
             $this->$changes = true;
106 106
         } else {
107
-            throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
107
+            throw new \Exception('Trying to persist unknown subset in repository: '.$name.' <br /><pre>'.print_r($value, true).'</pre>');
108 108
         }
109 109
     }
110 110
 
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
     protected function saveSubset($subset)
124 124
     {
125 125
         $json = json_encode($this->$subset);
126
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
126
+        $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json';
127 127
         file_put_contents($subsetStoragePath, $json);
128
-        $changes = $subset . 'Changes';
128
+        $changes = $subset.'Changes';
129 129
         $this->$changes = false;
130 130
     }
131 131
 
132 132
     protected function loadSubset($subset)
133 133
     {
134
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
134
+        $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json';
135 135
         $json = file_get_contents($subsetStoragePath);
136 136
         $json = json_decode($json);
137 137
         $this->$subset = $json;
Please login to merge, or discard this patch.