Passed
Branch develop (96efe9)
by Jens
02:38
created
src/storage/factories/UserFactory.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -13,37 +13,37 @@
 block discarded – undo
13 13
 
14 14
 class UserFactory
15 15
 {
16
-	/**
17
-	 * Create user from POST values
18
-	 *
19
-	 * @param $postValues
20
-	 *
21
-	 * @return \stdClass
22
-	 * @throws \Exception
23
-	 */
24
-	public static function createUserFromPostValues($postValues)
25
-	{
26
-		if (isset($postValues['username'])) {
27
-			$user = new \stdClass();
28
-			$user->username = $postValues['username'];
29
-			$user->slug = StringUtil::slugify($postValues['username']);
30
-			$user->rights = array();
31
-			if (isset($postValues['rights'])) {
32
-				$user->rights = $postValues['rights'];
33
-			}
16
+    /**
17
+     * Create user from POST values
18
+     *
19
+     * @param $postValues
20
+     *
21
+     * @return \stdClass
22
+     * @throws \Exception
23
+     */
24
+    public static function createUserFromPostValues($postValues)
25
+    {
26
+        if (isset($postValues['username'])) {
27
+            $user = new \stdClass();
28
+            $user->username = $postValues['username'];
29
+            $user->slug = StringUtil::slugify($postValues['username']);
30
+            $user->rights = array();
31
+            if (isset($postValues['rights'])) {
32
+                $user->rights = $postValues['rights'];
33
+            }
34 34
 
35
-			if (isset($postValues['password']) && empty($postValues['password']) === false) {
36
-				$crypt = new Crypt();
37
-				$user->password = $crypt->encrypt($postValues['password'], 16);
38
-				$user->salt = $crypt->getLastSalt();
39
-			} else {
40
-				$user->password = $postValues['passHash'];
41
-				$user->salt = $postValues['salt'];
42
-			}
35
+            if (isset($postValues['password']) && empty($postValues['password']) === false) {
36
+                $crypt = new Crypt();
37
+                $user->password = $crypt->encrypt($postValues['password'], 16);
38
+                $user->salt = $crypt->getLastSalt();
39
+            } else {
40
+                $user->password = $postValues['passHash'];
41
+                $user->salt = $postValues['salt'];
42
+            }
43 43
 
44
-			return $user;
45
-		} else {
46
-			throw new \Exception('Trying to create user with invalid data.');
47
-		}
48
-	}
44
+            return $user;
45
+        } else {
46
+            throw new \Exception('Trying to create user with invalid data.');
47
+        }
48
+    }
49 49
 }
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/factories/ImageFactory.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -8,21 +8,21 @@
 block discarded – undo
8 8
 
9 9
 class ImageFactory
10 10
 {
11
-	/**
12
-	 * @param $postValues
13
-	 * @param $filename
14
-	 * @param $fileNames
15
-	 *
16
-	 * @return \stdClass
17
-	 */
18
-	public static function createImageFromPostValues($postValues, $filename, $fileNames)
19
-	{
20
-		$imageObject = new \stdClass();
21
-		$imageObject->file = $filename;
22
-		$imageObject->type = $postValues['type'];
23
-		$imageObject->size = $postValues['size'];
24
-		$imageObject->set = $fileNames;
11
+    /**
12
+     * @param $postValues
13
+     * @param $filename
14
+     * @param $fileNames
15
+     *
16
+     * @return \stdClass
17
+     */
18
+    public static function createImageFromPostValues($postValues, $filename, $fileNames)
19
+    {
20
+        $imageObject = new \stdClass();
21
+        $imageObject->file = $filename;
22
+        $imageObject->type = $postValues['type'];
23
+        $imageObject->size = $postValues['size'];
24
+        $imageObject->set = $fileNames;
25 25
 
26
-		return $imageObject;
27
-	}
26
+        return $imageObject;
27
+    }
28 28
 }
29 29
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/factories/ImageSetFactory.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -12,28 +12,28 @@
 block discarded – undo
12 12
 
13 13
 class ImageSetFactory
14 14
 {
15
-	/**
16
-	 * Ceate image set from post values
17
-	 *
18
-	 * @param $postValues
19
-	 *
20
-	 * @return \stdClass
21
-	 * @throws \Exception
22
-	 */
23
-	public static function createImageSetFromPostValues($postValues)
24
-	{
25
-		if (isset($postValues['title'], $postValues['width'], $postValues['height'], $postValues['method'])) {
26
-			$imageSetObject = new \stdClass();
15
+    /**
16
+     * Ceate image set from post values
17
+     *
18
+     * @param $postValues
19
+     *
20
+     * @return \stdClass
21
+     * @throws \Exception
22
+     */
23
+    public static function createImageSetFromPostValues($postValues)
24
+    {
25
+        if (isset($postValues['title'], $postValues['width'], $postValues['height'], $postValues['method'])) {
26
+            $imageSetObject = new \stdClass();
27 27
 
28
-			$imageSetObject->title = $postValues['title'];
29
-			$imageSetObject->slug = StringUtil::slugify($postValues['title']);
30
-			$imageSetObject->width = $postValues['width'];
31
-			$imageSetObject->height = $postValues['height'];
32
-			$imageSetObject->method = $postValues['method'];
28
+            $imageSetObject->title = $postValues['title'];
29
+            $imageSetObject->slug = StringUtil::slugify($postValues['title']);
30
+            $imageSetObject->width = $postValues['width'];
31
+            $imageSetObject->height = $postValues['height'];
32
+            $imageSetObject->method = $postValues['method'];
33 33
 
34
-			return $imageSetObject;
35
-		} else {
36
-			throw new \Exception('Trying to create image set with invalid data.');
37
-		}
38
-	}
34
+            return $imageSetObject;
35
+        } else {
36
+            throw new \Exception('Trying to create image set with invalid data.');
37
+        }
38
+    }
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/factories/ApplicationComponentFactory.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -12,29 +12,29 @@
 block discarded – undo
12 12
 
13 13
 class ApplicationComponentFactory
14 14
 {
15
-	/**
16
-	 * @param $postValues
17
-	 *
18
-	 * @return \stdClass
19
-	 * @throws \Exception
20
-	 */
21
-	public static function createApplicationComponentFromPostValues($postValues)
22
-	{
23
-		if (isset($postValues['title'], $postValues['component'])) {
24
-			$applicationComponent = new \stdClass();
25
-			$applicationComponent->title = $postValues['title'];
26
-			$applicationComponent->slug = StringUtil::slugify($postValues['title']);
27
-			$applicationComponent->component = $postValues['component'];
28
-			$applicationComponent->parameters = new \stdClass();
29
-			if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
30
-				foreach ($postValues['parameterNames'] as $key => $value) {
31
-					$applicationComponent->parameters->$value = $postValues['parameterValues'][$key];
32
-				}
33
-			}
15
+    /**
16
+     * @param $postValues
17
+     *
18
+     * @return \stdClass
19
+     * @throws \Exception
20
+     */
21
+    public static function createApplicationComponentFromPostValues($postValues)
22
+    {
23
+        if (isset($postValues['title'], $postValues['component'])) {
24
+            $applicationComponent = new \stdClass();
25
+            $applicationComponent->title = $postValues['title'];
26
+            $applicationComponent->slug = StringUtil::slugify($postValues['title']);
27
+            $applicationComponent->component = $postValues['component'];
28
+            $applicationComponent->parameters = new \stdClass();
29
+            if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
30
+                foreach ($postValues['parameterNames'] as $key => $value) {
31
+                    $applicationComponent->parameters->$value = $postValues['parameterValues'][$key];
32
+                }
33
+            }
34 34
 
35
-			return $applicationComponent;
36
-		} else {
37
-			throw new \Exception('Trying to create application component with invalid data.');
38
-		}
39
-	}
35
+            return $applicationComponent;
36
+        } else {
37
+            throw new \Exception('Trying to create application component with invalid data.');
38
+        }
39
+    }
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/factories/DocumentTypeFactory.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -12,58 +12,58 @@
 block discarded – undo
12 12
 
13 13
 class DocumentTypeFactory extends AbstractBricksFactory
14 14
 {
15
-	public static function createDocumentTypeFromPostValues($postValues)
16
-	{
17
-		if (isset($postValues['title'])) {
18
-			$documentTypeObject = self::createInitialDocoumentTypeObject($postValues);
19
-			if (isset($postValues['fieldTitles'], $postValues['fieldTypes'], $postValues['fieldRequired'], $postValues['fieldMultiple'])) {
20
-				foreach ($postValues['fieldTitles'] as $key => $value) {
21
-					$fieldObject = self::createFieldObject($postValues, $value, $key);
15
+    public static function createDocumentTypeFromPostValues($postValues)
16
+    {
17
+        if (isset($postValues['title'])) {
18
+            $documentTypeObject = self::createInitialDocoumentTypeObject($postValues);
19
+            if (isset($postValues['fieldTitles'], $postValues['fieldTypes'], $postValues['fieldRequired'], $postValues['fieldMultiple'])) {
20
+                foreach ($postValues['fieldTitles'] as $key => $value) {
21
+                    $fieldObject = self::createFieldObject($postValues, $value, $key);
22 22
 
23
-					$documentTypeObject->fields[] = $fieldObject;
24
-				}
25
-			}
26
-			if (isset($postValues['brickTitles'], $postValues['brickBricks'])) {
27
-				foreach ($postValues['brickTitles'] as $key => $value) {
28
-					$brickObject = self::createBrickObject($postValues, $value, $key);
23
+                    $documentTypeObject->fields[] = $fieldObject;
24
+                }
25
+            }
26
+            if (isset($postValues['brickTitles'], $postValues['brickBricks'])) {
27
+                foreach ($postValues['brickTitles'] as $key => $value) {
28
+                    $brickObject = self::createBrickObject($postValues, $value, $key);
29 29
 
30
-					$documentTypeObject->bricks[] = $brickObject;
31
-				}
32
-			}
30
+                    $documentTypeObject->bricks[] = $brickObject;
31
+                }
32
+            }
33 33
 
34
-			return $documentTypeObject;
35
-		} else {
36
-			throw new \Exception('Trying to create document type with invalid data.');
37
-		}
38
-	}
34
+            return $documentTypeObject;
35
+        } else {
36
+            throw new \Exception('Trying to create document type with invalid data.');
37
+        }
38
+    }
39 39
 
40
-	/**
41
-	 * @param $postValues
42
-	 * @param $title
43
-	 * @param $slug
44
-	 *
45
-	 * @return \stdClass
46
-	 */
47
-	private static function createBrickObject($postValues, $title, $slug)
48
-	{
49
-		$brickObject = new \stdClass();
50
-		$brickObject->title = $title;
51
-		$brickObject->slug = StringUtil::slugify($title);
52
-		$brickObject->brickSlug = $postValues['brickBricks'][$slug];
53
-		$brickObject->multiple = ($postValues['brickMultiples'][$slug] === 'true');
40
+    /**
41
+     * @param $postValues
42
+     * @param $title
43
+     * @param $slug
44
+     *
45
+     * @return \stdClass
46
+     */
47
+    private static function createBrickObject($postValues, $title, $slug)
48
+    {
49
+        $brickObject = new \stdClass();
50
+        $brickObject->title = $title;
51
+        $brickObject->slug = StringUtil::slugify($title);
52
+        $brickObject->brickSlug = $postValues['brickBricks'][$slug];
53
+        $brickObject->multiple = ($postValues['brickMultiples'][$slug] === 'true');
54 54
 
55
-		return $brickObject;
56
-	}
55
+        return $brickObject;
56
+    }
57 57
 
58
-	private static function createInitialDocoumentTypeObject($postValues)
59
-	{
60
-		$documentTypeObject = new \stdClass();
61
-		$documentTypeObject->title = $postValues['title'];
62
-		$documentTypeObject->slug = StringUtil::slugify($postValues['title']);
63
-		$documentTypeObject->fields = array();
64
-		$documentTypeObject->bricks = array();
65
-		$documentTypeObject->dynamicBricks = isset($postValues['dynamicBricks']) ? $postValues['dynamicBricks'] : array();
58
+    private static function createInitialDocoumentTypeObject($postValues)
59
+    {
60
+        $documentTypeObject = new \stdClass();
61
+        $documentTypeObject->title = $postValues['title'];
62
+        $documentTypeObject->slug = StringUtil::slugify($postValues['title']);
63
+        $documentTypeObject->fields = array();
64
+        $documentTypeObject->bricks = array();
65
+        $documentTypeObject->dynamicBricks = isset($postValues['dynamicBricks']) ? $postValues['dynamicBricks'] : array();
66 66
 
67
-		return $documentTypeObject;
68
-	}
67
+        return $documentTypeObject;
68
+    }
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/factories/DocumentFactory.php 1 patch
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -13,174 +13,174 @@
 block discarded – undo
13 13
 
14 14
 class DocumentFactory
15 15
 {
16
-	/**
17
-	 * @param array                $postValues
18
-	 * @param DocumentTypesStorage $documentTypesStorage
19
-	 *
20
-	 * @return \CloudControl\Cms\storage\Document
21
-	 */
22
-	public static function createDocumentFromPostValues($postValues, DocumentTypesStorage $documentTypesStorage)
23
-	{
24
-		$postValues = utf8Convert($postValues);
25
-		$documentType = $documentTypesStorage->getDocumentTypeBySlug($postValues['documentType']);
26
-
27
-		$staticBricks = $documentType->bricks;
28
-
29
-		$documentObj = self::createInitialDocumentObject($postValues, $documentType);
30
-
31
-		$documentObj->fields = isset($postValues['fields']) ? $postValues['fields'] : array();
32
-		$documentObj->bricks = array();
33
-
34
-		$documentObj = self::createBrickArrayForDocument($postValues, $documentObj, $staticBricks);
35
-		$documentObj = self::createDynamicBrickArrayForDocument($postValues, $documentObj);
36
-
37
-		return $documentObj;
38
-	}
39
-
40
-	/**
41
-	 * @param array $postValues
42
-	 * @param \stdClass $documentType
43
-	 *
44
-	 * @return Document
45
-	 */
46
-	private static function createInitialDocumentObject($postValues, $documentType)
47
-	{
48
-		$documentObj = new Document();
49
-		$documentObj->title = $postValues['title'];
50
-		$documentObj->slug = StringUtil::slugify($postValues['title']);
51
-		$documentObj->type = 'document';
52
-		$documentObj->documentType = $documentType->title;
53
-		$documentObj->documentTypeSlug = $documentType->slug;
54
-		$documentObj->state = isset($postValues['state']) ? 'published' : 'unpublished';
55
-		$documentObj->lastModificationDate = time();
56
-		$documentObj->creationDate = isset($postValues['creationDate']) ? intval($postValues['creationDate']) : time();
57
-		$documentObj->lastModifiedBy = $_SESSION['cloudcontrol']->username;
58
-
59
-		return $documentObj;
60
-	}
61
-
62
-	/**
63
-	 * @param array $postValues
64
-	 * @param Document $documentObj
65
-	 * @param array $staticBricks
66
-	 *
67
-	 * @return Document
68
-	 */
69
-	private static function createBrickArrayForDocument($postValues, $documentObj, $staticBricks)
70
-	{
71
-		if (isset($postValues['bricks'])) {
72
-			foreach ($postValues['bricks'] as $brickSlug => $brick) {
73
-				// Find the current bricktype and check if its multiple
74
-				list($staticBrick, $multiple) = self::getStaticBrickAndSetMultiple($staticBricks, $brickSlug);
75
-
76
-				if ($multiple) {
77
-					$documentObj = self::addMultipleBricks($documentObj, $brick, $staticBrick, $brickSlug);
78
-				} else {
79
-					$documentObj = self::addSingleBrick($documentObj, $brick, $brickSlug);
80
-				}
81
-			}
82
-		}
83
-		return $documentObj;
84
-	}
85
-
86
-	/**
87
-	 * @param array $postValues
88
-	 * @param Document $documentObj
89
-	 *
90
-	 * @return Document
91
-	 */
92
-	private static function createDynamicBrickArrayForDocument($postValues, $documentObj)
93
-	{
94
-		$documentObj->dynamicBricks = array();
95
-		if (isset($postValues['dynamicBricks'])) {
96
-			foreach ($postValues['dynamicBricks'] as $brickTypeSlug => $brick) {
97
-				foreach ($brick as $brickContent) {
98
-					$brickObj = new \stdClass();
99
-					$brickObj->type = $brickTypeSlug;
100
-					$brickObj->fields = $brickContent;
101
-					$dynamicBricks = $documentObj->dynamicBricks;
102
-					$dynamicBricks[] = $brickObj;
103
-					$documentObj->dynamicBricks = $dynamicBricks;
104
-				}
105
-			}
106
-		}
107
-		return $documentObj;
108
-	}
109
-
110
-	/**
111
-	 * @param $staticBricks
112
-	 * @param $brickSlug
113
-	 *
114
-	 * @return array
115
-	 */
116
-	private static function getStaticBrickAndSetMultiple($staticBricks, $brickSlug)
117
-	{
118
-		$staticBrick = null;
119
-		$multiple = false;
120
-		foreach ($staticBricks as $staticBrick) {
121
-			if ($staticBrick->slug === $brickSlug) {
122
-				$multiple = $staticBrick->multiple;
123
-				break;
124
-			}
125
-		}
126
-
127
-		return array($staticBrick, $multiple);
128
-	}
129
-
130
-	/**
131
-	 * @param $staticBrick
132
-	 * @param $brickInstance
133
-	 *
134
-	 * @return \stdClass
135
-	 */
136
-	private static function createBrick($staticBrick, $brickInstance)
137
-	{
138
-		$brickObj = new \stdClass();
139
-		$brickObj->fields = new \stdClass();
140
-		$brickObj->type = $staticBrick->brickSlug;
141
-
142
-		foreach ($brickInstance['fields'] as $fieldName => $fieldValues) {
143
-			$brickObj->fields->$fieldName = $fieldValues;
144
-		}
145
-
146
-		return $brickObj;
147
-	}
148
-
149
-	/**
150
-	 * @param $documentObj
151
-	 * @param $brick
152
-	 * @param $staticBrick
153
-	 * @param $brickSlug
154
-	 *
155
-	 * @return mixed
156
-	 */
157
-	private static function addMultipleBricks($documentObj, $brick, $staticBrick, $brickSlug)
158
-	{
159
-		$brickArray = array();
160
-		foreach ($brick as $brickInstance) {
161
-			$brickObj = self::createBrick($staticBrick, $brickInstance);
162
-			$brickArray[] = $brickObj;
163
-		}
164
-
165
-		$bricks = $documentObj->bricks;
166
-		$bricks[$brickSlug] = $brickArray;
167
-		$documentObj->bricks = $bricks;
168
-
169
-		return $documentObj;
170
-	}
171
-
172
-	/**
173
-	 * @param $documentObj
174
-	 * @param $brick
175
-	 * @param $brickSlug
176
-	 *
177
-	 * @return mixed
178
-	 */
179
-	private static function addSingleBrick($documentObj, $brick, $brickSlug)
180
-	{
181
-		$bricks = $documentObj->bricks;
182
-		$bricks[$brickSlug] = $brick;
183
-		$documentObj->bricks = $bricks;
184
-		return $documentObj;
185
-	}
16
+    /**
17
+     * @param array                $postValues
18
+     * @param DocumentTypesStorage $documentTypesStorage
19
+     *
20
+     * @return \CloudControl\Cms\storage\Document
21
+     */
22
+    public static function createDocumentFromPostValues($postValues, DocumentTypesStorage $documentTypesStorage)
23
+    {
24
+        $postValues = utf8Convert($postValues);
25
+        $documentType = $documentTypesStorage->getDocumentTypeBySlug($postValues['documentType']);
26
+
27
+        $staticBricks = $documentType->bricks;
28
+
29
+        $documentObj = self::createInitialDocumentObject($postValues, $documentType);
30
+
31
+        $documentObj->fields = isset($postValues['fields']) ? $postValues['fields'] : array();
32
+        $documentObj->bricks = array();
33
+
34
+        $documentObj = self::createBrickArrayForDocument($postValues, $documentObj, $staticBricks);
35
+        $documentObj = self::createDynamicBrickArrayForDocument($postValues, $documentObj);
36
+
37
+        return $documentObj;
38
+    }
39
+
40
+    /**
41
+     * @param array $postValues
42
+     * @param \stdClass $documentType
43
+     *
44
+     * @return Document
45
+     */
46
+    private static function createInitialDocumentObject($postValues, $documentType)
47
+    {
48
+        $documentObj = new Document();
49
+        $documentObj->title = $postValues['title'];
50
+        $documentObj->slug = StringUtil::slugify($postValues['title']);
51
+        $documentObj->type = 'document';
52
+        $documentObj->documentType = $documentType->title;
53
+        $documentObj->documentTypeSlug = $documentType->slug;
54
+        $documentObj->state = isset($postValues['state']) ? 'published' : 'unpublished';
55
+        $documentObj->lastModificationDate = time();
56
+        $documentObj->creationDate = isset($postValues['creationDate']) ? intval($postValues['creationDate']) : time();
57
+        $documentObj->lastModifiedBy = $_SESSION['cloudcontrol']->username;
58
+
59
+        return $documentObj;
60
+    }
61
+
62
+    /**
63
+     * @param array $postValues
64
+     * @param Document $documentObj
65
+     * @param array $staticBricks
66
+     *
67
+     * @return Document
68
+     */
69
+    private static function createBrickArrayForDocument($postValues, $documentObj, $staticBricks)
70
+    {
71
+        if (isset($postValues['bricks'])) {
72
+            foreach ($postValues['bricks'] as $brickSlug => $brick) {
73
+                // Find the current bricktype and check if its multiple
74
+                list($staticBrick, $multiple) = self::getStaticBrickAndSetMultiple($staticBricks, $brickSlug);
75
+
76
+                if ($multiple) {
77
+                    $documentObj = self::addMultipleBricks($documentObj, $brick, $staticBrick, $brickSlug);
78
+                } else {
79
+                    $documentObj = self::addSingleBrick($documentObj, $brick, $brickSlug);
80
+                }
81
+            }
82
+        }
83
+        return $documentObj;
84
+    }
85
+
86
+    /**
87
+     * @param array $postValues
88
+     * @param Document $documentObj
89
+     *
90
+     * @return Document
91
+     */
92
+    private static function createDynamicBrickArrayForDocument($postValues, $documentObj)
93
+    {
94
+        $documentObj->dynamicBricks = array();
95
+        if (isset($postValues['dynamicBricks'])) {
96
+            foreach ($postValues['dynamicBricks'] as $brickTypeSlug => $brick) {
97
+                foreach ($brick as $brickContent) {
98
+                    $brickObj = new \stdClass();
99
+                    $brickObj->type = $brickTypeSlug;
100
+                    $brickObj->fields = $brickContent;
101
+                    $dynamicBricks = $documentObj->dynamicBricks;
102
+                    $dynamicBricks[] = $brickObj;
103
+                    $documentObj->dynamicBricks = $dynamicBricks;
104
+                }
105
+            }
106
+        }
107
+        return $documentObj;
108
+    }
109
+
110
+    /**
111
+     * @param $staticBricks
112
+     * @param $brickSlug
113
+     *
114
+     * @return array
115
+     */
116
+    private static function getStaticBrickAndSetMultiple($staticBricks, $brickSlug)
117
+    {
118
+        $staticBrick = null;
119
+        $multiple = false;
120
+        foreach ($staticBricks as $staticBrick) {
121
+            if ($staticBrick->slug === $brickSlug) {
122
+                $multiple = $staticBrick->multiple;
123
+                break;
124
+            }
125
+        }
126
+
127
+        return array($staticBrick, $multiple);
128
+    }
129
+
130
+    /**
131
+     * @param $staticBrick
132
+     * @param $brickInstance
133
+     *
134
+     * @return \stdClass
135
+     */
136
+    private static function createBrick($staticBrick, $brickInstance)
137
+    {
138
+        $brickObj = new \stdClass();
139
+        $brickObj->fields = new \stdClass();
140
+        $brickObj->type = $staticBrick->brickSlug;
141
+
142
+        foreach ($brickInstance['fields'] as $fieldName => $fieldValues) {
143
+            $brickObj->fields->$fieldName = $fieldValues;
144
+        }
145
+
146
+        return $brickObj;
147
+    }
148
+
149
+    /**
150
+     * @param $documentObj
151
+     * @param $brick
152
+     * @param $staticBrick
153
+     * @param $brickSlug
154
+     *
155
+     * @return mixed
156
+     */
157
+    private static function addMultipleBricks($documentObj, $brick, $staticBrick, $brickSlug)
158
+    {
159
+        $brickArray = array();
160
+        foreach ($brick as $brickInstance) {
161
+            $brickObj = self::createBrick($staticBrick, $brickInstance);
162
+            $brickArray[] = $brickObj;
163
+        }
164
+
165
+        $bricks = $documentObj->bricks;
166
+        $bricks[$brickSlug] = $brickArray;
167
+        $documentObj->bricks = $bricks;
168
+
169
+        return $documentObj;
170
+    }
171
+
172
+    /**
173
+     * @param $documentObj
174
+     * @param $brick
175
+     * @param $brickSlug
176
+     *
177
+     * @return mixed
178
+     */
179
+    private static function addSingleBrick($documentObj, $brick, $brickSlug)
180
+    {
181
+        $bricks = $documentObj->bricks;
182
+        $bricks[$brickSlug] = $brick;
183
+        $documentObj->bricks = $bricks;
184
+        return $documentObj;
185
+    }
186 186
 }
187 187
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/factories/SitemapItemFactory.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,34 +12,34 @@
 block discarded – undo
12 12
 
13 13
 class SitemapItemFactory
14 14
 {
15
-	/**
16
-	 * Create a sitemap item from post values
17
-	 *
18
-	 * @param $postValues
19
-	 *
20
-	 * @return \stdClass
21
-	 * @throws \Exception
22
-	 */
23
-	public static function createSitemapItemFromPostValues($postValues)
24
-	{
25
-		if (isset($postValues['title'], $postValues['url'], $postValues['component'], $postValues['template'])) {
26
-			$sitemapObject = new \stdClass();
27
-			$sitemapObject->title = $postValues['title'];
28
-			$sitemapObject->slug = StringUtil::slugify($postValues['title']);
29
-			$sitemapObject->url = $postValues['url'];
30
-			$sitemapObject->component = $postValues['component'];
31
-			$sitemapObject->template = $postValues['template'];
32
-			$sitemapObject->regex = isset($postValues['regex']);
33
-			$sitemapObject->parameters = new \stdClass();
34
-			if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
35
-				foreach ($postValues['parameterNames'] as $key => $value) {
36
-					$sitemapObject->parameters->$value = $postValues['parameterValues'][$key];
37
-				}
38
-			}
15
+    /**
16
+     * Create a sitemap item from post values
17
+     *
18
+     * @param $postValues
19
+     *
20
+     * @return \stdClass
21
+     * @throws \Exception
22
+     */
23
+    public static function createSitemapItemFromPostValues($postValues)
24
+    {
25
+        if (isset($postValues['title'], $postValues['url'], $postValues['component'], $postValues['template'])) {
26
+            $sitemapObject = new \stdClass();
27
+            $sitemapObject->title = $postValues['title'];
28
+            $sitemapObject->slug = StringUtil::slugify($postValues['title']);
29
+            $sitemapObject->url = $postValues['url'];
30
+            $sitemapObject->component = $postValues['component'];
31
+            $sitemapObject->template = $postValues['template'];
32
+            $sitemapObject->regex = isset($postValues['regex']);
33
+            $sitemapObject->parameters = new \stdClass();
34
+            if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
35
+                foreach ($postValues['parameterNames'] as $key => $value) {
36
+                    $sitemapObject->parameters->$value = $postValues['parameterValues'][$key];
37
+                }
38
+            }
39 39
 
40
-			return $sitemapObject;
41
-		} else {
42
-			throw new \Exception('Trying to create sitemap item with invalid data.');
43
-		}
44
-	}
40
+            return $sitemapObject;
41
+        } else {
42
+            throw new \Exception('Trying to create sitemap item with invalid data.');
43
+        }
44
+    }
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/factories/BrickFactory.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -12,32 +12,32 @@
 block discarded – undo
12 12
 
13 13
 class BrickFactory extends AbstractBricksFactory
14 14
 {
15
-	/**
16
-	 * Create a brick from post values
17
-	 *
18
-	 * @param $postValues
19
-	 *
20
-	 * @return \stdClass
21
-	 * @throws \Exception
22
-	 */
23
-	public static function createBrickFromPostValues($postValues)
24
-	{
25
-		if (isset($postValues['title'])) {
26
-			$brickObject = new \stdClass();
27
-			$brickObject->title = $postValues['title'];
28
-			$brickObject->slug = StringUtil::slugify($postValues['title']);
29
-			$brickObject->fields = array();
30
-			if (isset($postValues['fieldTitles'], $postValues['fieldTypes'], $postValues['fieldRequired'], $postValues['fieldMultiple'])) {
31
-				foreach ($postValues['fieldTitles'] as $key => $value) {
32
-					$fieldObject = self::createFieldObject($postValues, $value, $key);
15
+    /**
16
+     * Create a brick from post values
17
+     *
18
+     * @param $postValues
19
+     *
20
+     * @return \stdClass
21
+     * @throws \Exception
22
+     */
23
+    public static function createBrickFromPostValues($postValues)
24
+    {
25
+        if (isset($postValues['title'])) {
26
+            $brickObject = new \stdClass();
27
+            $brickObject->title = $postValues['title'];
28
+            $brickObject->slug = StringUtil::slugify($postValues['title']);
29
+            $brickObject->fields = array();
30
+            if (isset($postValues['fieldTitles'], $postValues['fieldTypes'], $postValues['fieldRequired'], $postValues['fieldMultiple'])) {
31
+                foreach ($postValues['fieldTitles'] as $key => $value) {
32
+                    $fieldObject = self::createFieldObject($postValues, $value, $key);
33 33
 
34
-					$brickObject->fields[] = $fieldObject;
35
-				}
36
-			}
34
+                    $brickObject->fields[] = $fieldObject;
35
+                }
36
+            }
37 37
 
38
-			return $brickObject;
39
-		} else {
40
-			throw new \Exception('Trying to create document type with invalid data.');
41
-		}
42
-	}
38
+            return $brickObject;
39
+        } else {
40
+            throw new \Exception('Trying to create document type with invalid data.');
41
+        }
42
+    }
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/factories/AbstractBricksFactory.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -12,22 +12,22 @@
 block discarded – undo
12 12
 
13 13
 abstract class AbstractBricksFactory
14 14
 {
15
-	/**
16
-	 * @param $postValues
17
-	 * @param $title
18
-	 * @param $fieldType
19
-	 *
20
-	 * @return \stdClass
21
-	 */
22
-	protected static function createFieldObject($postValues, $title, $fieldType)
23
-	{
24
-		$fieldObject = new \stdClass();
25
-		$fieldObject->title = $title;
26
-		$fieldObject->slug = StringUtil::slugify($title);
27
-		$fieldObject->type = $postValues['fieldTypes'][$fieldType];
28
-		$fieldObject->required = ($postValues['fieldRequired'][$fieldType] === 'true');
29
-		$fieldObject->multiple = ($postValues['fieldMultiple'][$fieldType] === 'true');
15
+    /**
16
+     * @param $postValues
17
+     * @param $title
18
+     * @param $fieldType
19
+     *
20
+     * @return \stdClass
21
+     */
22
+    protected static function createFieldObject($postValues, $title, $fieldType)
23
+    {
24
+        $fieldObject = new \stdClass();
25
+        $fieldObject->title = $title;
26
+        $fieldObject->slug = StringUtil::slugify($title);
27
+        $fieldObject->type = $postValues['fieldTypes'][$fieldType];
28
+        $fieldObject->required = ($postValues['fieldRequired'][$fieldType] === 'true');
29
+        $fieldObject->multiple = ($postValues['fieldMultiple'][$fieldType] === 'true');
30 30
 
31
-		return $fieldObject;
32
-	}
31
+        return $fieldObject;
32
+    }
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.