Passed
Push — develop ( a5e1bf...c22bc5 )
by Jens
02:34
created
src/storage/factories/ValuelistFactory.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,34 +12,34 @@
 block discarded – undo
12 12
 
13 13
 class ValuelistFactory
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 createValuelistFromPostValues($postValues)
24
-    {
25
-        if (isset($postValues['title'])) {
26
-            $valuelistObject = new \stdClass();
27
-            $valuelistObject->title = $postValues['title'];
28
-            $valuelistObject->slug = StringUtil::slugify($postValues['title']);
29
-            $valuelistObject->pairs = new \stdClass();
30
-            if (isset($postValues['keys'], $postValues['values'])) {
31
-                foreach ($postValues['keys'] as $key => $value) {
32
-                    $valuelistObject->pairs->$value = $postValues['values'][$key];
33
-                }
34
-            }
35
-            $object_vars = get_object_vars($valuelistObject->pairs);
36
-            ksort($object_vars);
37
-            $valuelistObject->pairs = (object) $object_vars;
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 createValuelistFromPostValues($postValues)
24
+	{
25
+		if (isset($postValues['title'])) {
26
+			$valuelistObject = new \stdClass();
27
+			$valuelistObject->title = $postValues['title'];
28
+			$valuelistObject->slug = StringUtil::slugify($postValues['title']);
29
+			$valuelistObject->pairs = new \stdClass();
30
+			if (isset($postValues['keys'], $postValues['values'])) {
31
+				foreach ($postValues['keys'] as $key => $value) {
32
+					$valuelistObject->pairs->$value = $postValues['values'][$key];
33
+				}
34
+			}
35
+			$object_vars = get_object_vars($valuelistObject->pairs);
36
+			ksort($object_vars);
37
+			$valuelistObject->pairs = (object) $object_vars;
38 38
 
39
-            return $valuelistObject;
40
-        } else {
41
-            throw new \Exception('Trying to create valuelist with invalid data.');
42
-        }
43
-    }
39
+			return $valuelistObject;
40
+		} else {
41
+			throw new \Exception('Trying to create valuelist with invalid data.');
42
+		}
43
+	}
44 44
 
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/storage/RedirectsStorage.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -10,91 +10,91 @@
 block discarded – undo
10 10
 
11 11
 class RedirectsStorage extends AbstractStorage
12 12
 {
13
-    /**
14
-     * Get all redirects
15
-     *
16
-     * @return mixed
17
-     */
18
-    public function getRedirects()
19
-    {
20
-        $redirects = $this->repository->redirects;
21
-        usort($redirects, array($this, 'cmp'));
22
-        return $redirects;
23
-    }
13
+	/**
14
+	 * Get all redirects
15
+	 *
16
+	 * @return mixed
17
+	 */
18
+	public function getRedirects()
19
+	{
20
+		$redirects = $this->repository->redirects;
21
+		usort($redirects, array($this, 'cmp'));
22
+		return $redirects;
23
+	}
24 24
 
25
-    /**
26
-     * Add a new redirect
27
-     * @param $postValues
28
-     */
29
-    public function addRedirect($postValues) {
30
-        $redirectObject = RedirectsFactory::createRedirectFromPostValues($postValues);
31
-        $redirects = $this->repository->redirects;
32
-        $redirects[] = $redirectObject;
33
-        $this->repository->redirects = $redirects;
34
-        $this->save();
35
-    }
25
+	/**
26
+	 * Add a new redirect
27
+	 * @param $postValues
28
+	 */
29
+	public function addRedirect($postValues) {
30
+		$redirectObject = RedirectsFactory::createRedirectFromPostValues($postValues);
31
+		$redirects = $this->repository->redirects;
32
+		$redirects[] = $redirectObject;
33
+		$this->repository->redirects = $redirects;
34
+		$this->save();
35
+	}
36 36
 
37
-    /**
38
-     * Get a redirect by it's slug
39
-     *
40
-     * @param $slug
41
-     * @return \stdClass|null
42
-     */
43
-    public function getRedirectBySlug($slug)
44
-    {
45
-        $redirects = $this->repository->redirects;
46
-        foreach ($redirects as $redirect) {
47
-            if ($redirect->slug == $slug) {
48
-                return $redirect;
49
-            }
50
-        }
37
+	/**
38
+	 * Get a redirect by it's slug
39
+	 *
40
+	 * @param $slug
41
+	 * @return \stdClass|null
42
+	 */
43
+	public function getRedirectBySlug($slug)
44
+	{
45
+		$redirects = $this->repository->redirects;
46
+		foreach ($redirects as $redirect) {
47
+			if ($redirect->slug == $slug) {
48
+				return $redirect;
49
+			}
50
+		}
51 51
 
52
-        return null;
53
-    }
52
+		return null;
53
+	}
54 54
 
55
-    /**
56
-     * Save a redirect by it's slug
57
-     * @param $slug
58
-     * @param $postValues
59
-     */
60
-    public function saveRedirect($slug, $postValues)
61
-    {
62
-        $redirectObject = RedirectsFactory::createRedirectFromPostValues($postValues);
55
+	/**
56
+	 * Save a redirect by it's slug
57
+	 * @param $slug
58
+	 * @param $postValues
59
+	 */
60
+	public function saveRedirect($slug, $postValues)
61
+	{
62
+		$redirectObject = RedirectsFactory::createRedirectFromPostValues($postValues);
63 63
 
64
-        $redirects = $this->repository->redirects;
65
-        foreach ($redirects as $key => $redirect) {
66
-            if ($redirect->slug == $slug) {
67
-                $redirects[$key] = $redirectObject;
68
-            }
69
-        }
70
-        $this->repository->redirects = $redirects;
71
-        $this->save();
72
-    }
64
+		$redirects = $this->repository->redirects;
65
+		foreach ($redirects as $key => $redirect) {
66
+			if ($redirect->slug == $slug) {
67
+				$redirects[$key] = $redirectObject;
68
+			}
69
+		}
70
+		$this->repository->redirects = $redirects;
71
+		$this->save();
72
+	}
73 73
 
74
-    /**
75
-     * Delete a redirect by it's slug
76
-     * @param $slug
77
-     */
78
-    public function deleteRedirectBySlug($slug)
79
-    {
80
-        $redirects = $this->repository->redirects;
81
-        foreach ($redirects as $key => $redirect) {
82
-            if ($redirect->slug == $slug) {
83
-                unset($redirects[$key]);
84
-            }
85
-        }
86
-        $redirects = array_values($redirects);
87
-        $this->repository->redirects = $redirects;
88
-        $this->save();
89
-    }
74
+	/**
75
+	 * Delete a redirect by it's slug
76
+	 * @param $slug
77
+	 */
78
+	public function deleteRedirectBySlug($slug)
79
+	{
80
+		$redirects = $this->repository->redirects;
81
+		foreach ($redirects as $key => $redirect) {
82
+			if ($redirect->slug == $slug) {
83
+				unset($redirects[$key]);
84
+			}
85
+		}
86
+		$redirects = array_values($redirects);
87
+		$this->repository->redirects = $redirects;
88
+		$this->save();
89
+	}
90 90
 
91
-    /**
92
-     * Compare a redirect by it's title
93
-     * @param $a
94
-     * @param $b
95
-     * @return int
96
-     */
97
-    public static function cmp($a, $b) {
98
-        return strcmp($a->title, $b->title);
99
-    }
91
+	/**
92
+	 * Compare a redirect by it's title
93
+	 * @param $a
94
+	 * @param $b
95
+	 * @return int
96
+	 */
97
+	public static function cmp($a, $b) {
98
+		return strcmp($a->title, $b->title);
99
+	}
100 100
 }
101 101
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/storage/ImagesStorage.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -11,124 +11,124 @@
 block discarded – undo
11 11
 
12 12
 class ImagesStorage extends AbstractStorage
13 13
 {
14
-    protected $imagesDir;
15
-
16
-    public function __construct($repository, $imagesDir)
17
-    {
18
-        parent::__construct($repository);
19
-        $this->imagesDir = $imagesDir;
20
-    }
21
-
22
-
23
-    /**
24
-     * @var ImageSetStorage
25
-     */
26
-    protected $imageSet;
27
-
28
-    /**
29
-     * Get all images
30
-     *
31
-     * @return array
32
-     */
33
-    public function getImages()
34
-    {
35
-        return $this->repository->images;
36
-    }
37
-
38
-    /**
39
-     * @param $postValues
40
-     *
41
-     * @throws \Exception
42
-     */
43
-    public function addImage($postValues)
44
-    {
45
-        $destinationPath = $this->getDestinationPath();
46
-
47
-        $filename = $this->validateFilename($postValues['name'], $destinationPath);
48
-        $destination = $destinationPath . DIRECTORY_SEPARATOR . $filename;
49
-
50
-        if ($postValues['error'] != '0') {
51
-            throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
52
-        }
53
-
54
-        if (move_uploaded_file($postValues['tmp_name'], $destination)) {
55
-            $imageResizer = new ImageResizer($this->getImageSet()->getImageSet());
56
-            $fileNames = $imageResizer->applyImageSetToImage($destination);
57
-            $fileNames['original'] = $filename;
58
-            $imageObject = ImageFactory::createImageFromPostValues($postValues, $filename, $fileNames);
59
-
60
-            $images = $this->repository->images;
61
-            $images[] = $imageObject;
62
-            $this->repository->images = $images;
63
-
64
-            $this->save();
65
-        } else {
66
-            throw new \Exception('Error moving uploaded file');
67
-        }
68
-    }
69
-
70
-    /**
71
-     * Delete image by name
72
-     * @param $filename
73
-     */
74
-    public function deleteImageByName($filename)
75
-    {
76
-        $destinationPath = $this->getDestinationPath();
77
-
78
-        $images = $this->getImages();
79
-
80
-        foreach ($images as $key => $image) {
81
-            if ($image->file == $filename) {
82
-                foreach ($image->set as $imageSetFilename) {
83
-                    $destination = $destinationPath . '/' . $imageSetFilename;
84
-                    if (file_exists($destination)) {
85
-                        unlink($destination);
86
-                    } else {
87
-                        dump($destination);
88
-                    }
89
-                }
90
-                unset($images[$key]);
91
-            }
92
-        }
93
-
94
-        $this->repository->images = $images;
95
-        $this->save();
96
-    }
97
-
98
-    /**
99
-     * @param $filename
100
-     *
101
-     * @return null
102
-     */
103
-    public function getImageByName($filename)
104
-    {
105
-        $images = $this->getImages();
106
-        foreach ($images as $image) {
107
-            if ($image->file == $filename) {
108
-                return $image;
109
-            }
110
-        }
111
-
112
-        return null;
113
-    }
114
-
115
-    /**
116
-     * @return \CloudControl\Cms\storage\storage\ImageSetStorage
117
-     */
118
-    private function getImageSet()
119
-    {
120
-        if (!$this->imageSet instanceof ImageSetStorage) {
121
-            $this->imageSet = new ImageSetStorage($this->repository);
122
-        }
123
-        return $this->imageSet;
124
-    }
125
-
126
-    /**
127
-     * @return bool|string
128
-     */
129
-    private function getDestinationPath()
130
-    {
131
-        $destinationPath = realpath($this->imagesDir . DIRECTORY_SEPARATOR);
132
-        return $destinationPath;
133
-    }
14
+	protected $imagesDir;
15
+
16
+	public function __construct($repository, $imagesDir)
17
+	{
18
+		parent::__construct($repository);
19
+		$this->imagesDir = $imagesDir;
20
+	}
21
+
22
+
23
+	/**
24
+	 * @var ImageSetStorage
25
+	 */
26
+	protected $imageSet;
27
+
28
+	/**
29
+	 * Get all images
30
+	 *
31
+	 * @return array
32
+	 */
33
+	public function getImages()
34
+	{
35
+		return $this->repository->images;
36
+	}
37
+
38
+	/**
39
+	 * @param $postValues
40
+	 *
41
+	 * @throws \Exception
42
+	 */
43
+	public function addImage($postValues)
44
+	{
45
+		$destinationPath = $this->getDestinationPath();
46
+
47
+		$filename = $this->validateFilename($postValues['name'], $destinationPath);
48
+		$destination = $destinationPath . DIRECTORY_SEPARATOR . $filename;
49
+
50
+		if ($postValues['error'] != '0') {
51
+			throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
52
+		}
53
+
54
+		if (move_uploaded_file($postValues['tmp_name'], $destination)) {
55
+			$imageResizer = new ImageResizer($this->getImageSet()->getImageSet());
56
+			$fileNames = $imageResizer->applyImageSetToImage($destination);
57
+			$fileNames['original'] = $filename;
58
+			$imageObject = ImageFactory::createImageFromPostValues($postValues, $filename, $fileNames);
59
+
60
+			$images = $this->repository->images;
61
+			$images[] = $imageObject;
62
+			$this->repository->images = $images;
63
+
64
+			$this->save();
65
+		} else {
66
+			throw new \Exception('Error moving uploaded file');
67
+		}
68
+	}
69
+
70
+	/**
71
+	 * Delete image by name
72
+	 * @param $filename
73
+	 */
74
+	public function deleteImageByName($filename)
75
+	{
76
+		$destinationPath = $this->getDestinationPath();
77
+
78
+		$images = $this->getImages();
79
+
80
+		foreach ($images as $key => $image) {
81
+			if ($image->file == $filename) {
82
+				foreach ($image->set as $imageSetFilename) {
83
+					$destination = $destinationPath . '/' . $imageSetFilename;
84
+					if (file_exists($destination)) {
85
+						unlink($destination);
86
+					} else {
87
+						dump($destination);
88
+					}
89
+				}
90
+				unset($images[$key]);
91
+			}
92
+		}
93
+
94
+		$this->repository->images = $images;
95
+		$this->save();
96
+	}
97
+
98
+	/**
99
+	 * @param $filename
100
+	 *
101
+	 * @return null
102
+	 */
103
+	public function getImageByName($filename)
104
+	{
105
+		$images = $this->getImages();
106
+		foreach ($images as $image) {
107
+			if ($image->file == $filename) {
108
+				return $image;
109
+			}
110
+		}
111
+
112
+		return null;
113
+	}
114
+
115
+	/**
116
+	 * @return \CloudControl\Cms\storage\storage\ImageSetStorage
117
+	 */
118
+	private function getImageSet()
119
+	{
120
+		if (!$this->imageSet instanceof ImageSetStorage) {
121
+			$this->imageSet = new ImageSetStorage($this->repository);
122
+		}
123
+		return $this->imageSet;
124
+	}
125
+
126
+	/**
127
+	 * @return bool|string
128
+	 */
129
+	private function getDestinationPath()
130
+	{
131
+		$destinationPath = realpath($this->imagesDir . DIRECTORY_SEPARATOR);
132
+		return $destinationPath;
133
+	}
134 134
 }
135 135
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/storage/ValuelistsStorage.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -12,83 +12,83 @@
 block discarded – undo
12 12
 
13 13
 class ValuelistsStorage extends AbstractStorage
14 14
 {
15
-    /**
16
-     * Get all valuelists
17
-     *
18
-     * @return mixed
19
-     */
20
-    public function getValuelists()
21
-    {
22
-        return $this->repository->valuelists;
23
-    }
15
+	/**
16
+	 * Get all valuelists
17
+	 *
18
+	 * @return mixed
19
+	 */
20
+	public function getValuelists()
21
+	{
22
+		return $this->repository->valuelists;
23
+	}
24 24
 
25
-    public function addValuelist($postValues)
26
-    {
27
-        $valueListObject = ValuelistFactory::createValuelistFromPostValues($postValues);
28
-        $valuelists = $this->repository->valuelists;
29
-        $valuelists[] = $valueListObject;
30
-        $this->repository->valuelists = $valuelists;
31
-        $this->save();
32
-    }
25
+	public function addValuelist($postValues)
26
+	{
27
+		$valueListObject = ValuelistFactory::createValuelistFromPostValues($postValues);
28
+		$valuelists = $this->repository->valuelists;
29
+		$valuelists[] = $valueListObject;
30
+		$this->repository->valuelists = $valuelists;
31
+		$this->save();
32
+	}
33 33
 
34
-    /**
35
-     * Save changes to a valuelist
36
-     *
37
-     * @param $slug
38
-     * @param $postValues
39
-     *
40
-     * @throws \Exception
41
-     */
42
-    public function saveValuelist($slug, $postValues)
43
-    {
44
-        $valuelistObject = ValuelistFactory::createValuelistFromPostValues($postValues);
34
+	/**
35
+	 * Save changes to a valuelist
36
+	 *
37
+	 * @param $slug
38
+	 * @param $postValues
39
+	 *
40
+	 * @throws \Exception
41
+	 */
42
+	public function saveValuelist($slug, $postValues)
43
+	{
44
+		$valuelistObject = ValuelistFactory::createValuelistFromPostValues($postValues);
45 45
 
46
-        $valuelists = $this->repository->valuelists;
47
-        foreach ($valuelists as $key => $valuelist) {
48
-            if ($valuelist->slug == $slug) {
49
-                $valuelists[$key] = $valuelistObject;
50
-            }
51
-        }
52
-        $this->repository->valuelists = $valuelists;
53
-        $this->save();
54
-    }
46
+		$valuelists = $this->repository->valuelists;
47
+		foreach ($valuelists as $key => $valuelist) {
48
+			if ($valuelist->slug == $slug) {
49
+				$valuelists[$key] = $valuelistObject;
50
+			}
51
+		}
52
+		$this->repository->valuelists = $valuelists;
53
+		$this->save();
54
+	}
55 55
 
56
-    /**
57
-     * Get a valuelist by its slug
58
-     *
59
-     * @param $slug
60
-     *
61
-     * @return mixed
62
-     */
63
-    public function getValuelistBySlug($slug)
64
-    {
65
-        $valuelists = $this->repository->valuelists;
66
-        foreach ($valuelists as $valuelist) {
67
-            if ($valuelist->slug == $slug) {
68
-                return $valuelist;
69
-            }
70
-        }
56
+	/**
57
+	 * Get a valuelist by its slug
58
+	 *
59
+	 * @param $slug
60
+	 *
61
+	 * @return mixed
62
+	 */
63
+	public function getValuelistBySlug($slug)
64
+	{
65
+		$valuelists = $this->repository->valuelists;
66
+		foreach ($valuelists as $valuelist) {
67
+			if ($valuelist->slug == $slug) {
68
+				return $valuelist;
69
+			}
70
+		}
71 71
 
72
-        return null;
73
-    }
72
+		return null;
73
+	}
74 74
 
75
-    /**
76
-     * Delete a sitemap item by its slug
77
-     *
78
-     * @param $slug
79
-     *
80
-     * @throws \Exception
81
-     */
82
-    public function deleteValuelistBySlug($slug)
83
-    {
84
-        $valuelists = $this->repository->valuelists;
85
-        foreach ($valuelists as $key => $valuelist) {
86
-            if ($valuelist->slug == $slug) {
87
-                unset($valuelists[$key]);
88
-            }
89
-        }
90
-        $valuelists = array_values($valuelists);
91
-        $this->repository->valuelists = $valuelists;
92
-        $this->save();
93
-    }
75
+	/**
76
+	 * Delete a sitemap item by its slug
77
+	 *
78
+	 * @param $slug
79
+	 *
80
+	 * @throws \Exception
81
+	 */
82
+	public function deleteValuelistBySlug($slug)
83
+	{
84
+		$valuelists = $this->repository->valuelists;
85
+		foreach ($valuelists as $key => $valuelist) {
86
+			if ($valuelist->slug == $slug) {
87
+				unset($valuelists[$key]);
88
+			}
89
+		}
90
+		$valuelists = array_values($valuelists);
91
+		$this->repository->valuelists = $valuelists;
92
+		$this->save();
93
+	}
94 94
 }
95 95
\ No newline at end of file
Please login to merge, or discard this patch.