Completed
Push — master ( 0ecc0f...b91b8b )
by Aleksandar
20:25
created
packages/Category/src/Service/CategoryService.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     /**
158 158
      * Return categories with posts/articles
159 159
      *
160
-     * @param null $inHomepage
160
+     * @param boolean $inHomepage
161 161
      * @param null $inCategoryList
162 162
      * @return mixed
163 163
      */
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     /**
178 178
      * Return categories posts/articles
179 179
      *
180
-     * @param null $inCategoryList
180
+     * @param boolean $inCategoryList
181 181
      * @return null|\Zend\Db\ResultSet\ResultSetInterface
182 182
      */
183 183
     public function getCategories($inCategoryList = null)
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Category\Service;
5 5
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function getCategoryBySlug($urlSlug)
78 78
     {
79
-        return $this->categoryMapper->select(['slug' => $urlSlug])->current();
79
+        return $this->categoryMapper->select([ 'slug' => $urlSlug ])->current();
80 80
     }
81 81
 
82 82
     /**
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
     {
90 90
         $filter = $this->categoryFilter->getInputFilter()->setData($data);
91 91
 
92
-        if(!$filter->isValid()) {
92
+        if (!$filter->isValid()) {
93 93
             throw new FilterException($filter->getMessages());
94 94
         }
95 95
 
96 96
         $values                   = $filter->getValues();
97
-        $values['category_id']    = Uuid::uuid1()->toString();
98
-        $values['category_uuid']  = (new MysqlUuid($values['category_id']))->toFormat(new Binary);
99
-        $values['main_img']       = $this->upload->uploadImage($data, 'main_img');
97
+        $values[ 'category_id' ]    = Uuid::uuid1()->toString();
98
+        $values[ 'category_uuid' ]  = (new MysqlUuid($values[ 'category_id' ]))->toFormat(new Binary);
99
+        $values[ 'main_img' ]       = $this->upload->uploadImage($data, 'main_img');
100 100
 
101 101
         $this->categoryMapper->insert($values);
102 102
     }
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function updateCategory($data, $categoryId)
113 113
     {
114
-        if(!$this->getCategory($categoryId)) {
114
+        if (!$this->getCategory($categoryId)) {
115 115
             throw new \Exception('CategoryId dos not exist.');
116 116
         }
117 117
 
118 118
         $filter = $this->categoryFilter->getInputFilter()->setData($data);
119 119
 
120
-        if(!$filter->isValid()) {
120
+        if (!$filter->isValid()) {
121 121
             throw new FilterException($filter->getMessages());
122 122
         }
123 123
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
             ];
127 127
 
128 128
         // We don't want to force user to re-upload image on edit
129
-        if(!$values['main_img']) {
130
-            unset($values['main_img']);
129
+        if (!$values[ 'main_img' ]) {
130
+            unset($values[ 'main_img' ]);
131 131
         }
132 132
 
133
-        $this->categoryMapper->update($values, ['category_id' => $categoryId]);
133
+        $this->categoryMapper->update($values, [ 'category_id' => $categoryId ]);
134 134
     }
135 135
 
136 136
     /**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function delete($categoryId)
143 143
     {
144
-        return (bool)$this->categoryMapper->delete(['category_id' => $categoryId]);
144
+        return (bool) $this->categoryMapper->delete([ 'category_id' => $categoryId ]);
145 145
     }
146 146
 
147 147
     /**
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
     {
166 166
         $categories = $this->categoryMapper->getWeb(7, null, $inHomepage, $inCategoryList)->toArray();
167 167
 
168
-        foreach($categories as $ctn => $category) {
169
-            $select                    = $this->categoryMapper->getCategoryPostsSelect($category['category_id'], 4);
168
+        foreach ($categories as $ctn => $category) {
169
+            $select                    = $this->categoryMapper->getCategoryPostsSelect($category[ 'category_id' ], 4);
170 170
             $posts                     = $this->categoryMapper->selectWith($select)->toArray();
171
-            $categories[$ctn]['posts'] = $posts;
171
+            $categories[ $ctn ][ 'posts' ] = $posts;
172 172
         }
173 173
 
174 174
         return $categories;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function getCategories($inCategoryList = null)
184 184
     {
185
-        return $this->categoryMapper->getWeb(null, ['name' => 'asc'], null, $inCategoryList);
185
+        return $this->categoryMapper->getWeb(null, [ 'name' => 'asc' ], null, $inCategoryList);
186 186
     }
187 187
 
188 188
     /**
Please login to merge, or discard this patch.
data/phinx/migrations/20161003183350_category.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@
 block discarded – undo
9 9
 
10 10
     public function up()
11 11
     {
12
-        $this->table('category', ['id' => false, 'primary_key' => 'category_uuid'])
13
-            ->addColumn('category_uuid', 'binary', ['limit' => 16])
12
+        $this->table('category', [ 'id' => false, 'primary_key' => 'category_uuid' ])
13
+            ->addColumn('category_uuid', 'binary', [ 'limit' => 16 ])
14 14
             ->addColumn('category_id', 'text')
15 15
             ->addColumn('name', 'text')
16 16
             ->addColumn('slug', 'text')
17
-            ->addColumn('title', 'text', ['null' => true])
18
-            ->addColumn('description', 'text', ['null' => true])
19
-            ->addColumn('main_img', 'text', ['null' => true])
20
-            ->addColumn('is_in_homepage', 'boolean', ['default' => false])
21
-            ->addColumn('is_in_category_list', 'boolean', ['default' => true])
17
+            ->addColumn('title', 'text', [ 'null' => true ])
18
+            ->addColumn('description', 'text', [ 'null' => true ])
19
+            ->addColumn('main_img', 'text', [ 'null' => true ])
20
+            ->addColumn('is_in_homepage', 'boolean', [ 'default' => false ])
21
+            ->addColumn('is_in_category_list', 'boolean', [ 'default' => true ])
22 22
             ->create();
23 23
     }
24 24
 
Please login to merge, or discard this patch.
packages/Web/Action/CategoryAction.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Web\Action;
6 6
 
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
     public function __invoke(Request $request, Response $response, callable $next = null)
52 52
     {
53 53
         $params     = $request->getQueryParams();
54
-        $page       = isset($params['page']) ? $params['page'] : 1;
54
+        $page       = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
55 55
         $urlSlug    = $request->getAttribute('category');
56 56
         $categories = $this->categoryService->getCategories(true);
57 57
         $category   = $this->categoryService->getCategoryBySlug($urlSlug);
58 58
 
59
-        if(!$category) {
60
-            if($urlSlug !== 'all') {
59
+        if (!$category) {
60
+            if ($urlSlug !== 'all') {
61 61
                 return $next($request, $response);
62 62
             }
63 63
 
64
-            $category = (object)[
64
+            $category = (object) [
65 65
                 'name'        => 'Svi članci',
66 66
                 'slug'        => 'all',
67 67
                 'title'       => 'Svi članci',
Please login to merge, or discard this patch.
packages/Web/Action/EventsAction.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Web\Action;
6 6
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     public function __invoke(Request $request, Response $response, callable $next = null)
54 54
     {
55 55
         $params       = $request->getQueryParams();
56
-        $page         = isset($params['page']) ? $params['page'] : 1;
56
+        $page         = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
57 57
         $futureEvents = $this->eventService->fetchFutureEvents();
58 58
         $pastEvents   = $this->eventService->fetchPastEventsPagination($page, 10);
59 59
         $category     = $this->categoryService->getCategoryBySlug('events');
Please login to merge, or discard this patch.
packages/Web/Action/VideosAction.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Web\Action;
6 6
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function __invoke(Request $request, Response $response, callable $next = null)
52 52
     {
53 53
         $params   = $request->getQueryParams();
54
-        $page     = isset($params['page']) ? $params['page'] : 1;
54
+        $page     = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
55 55
         $videos   = $this->videoService->fetchWebArticles($page, 5);
56 56
         $category = $this->categoryService->getCategoryBySlug('videos');
57 57
 
Please login to merge, or discard this patch.
packages/Category/src/Mapper/CategoryMapper.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Category\Mapper;
6 6
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function get($id)
36 36
     {
37
-        return $this->select(['category_id' => $id])->current();
37
+        return $this->select([ 'category_id' => $id ])->current();
38 38
     }
39 39
 
40 40
     public function getPaginationSelect()
41 41
     {
42
-        $select = $this->getSql()->select()->order(['name' => 'asc']);
42
+        $select = $this->getSql()->select()->order([ 'name' => 'asc' ]);
43 43
 
44 44
         return $select;
45 45
     }
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
     public function getCategoryPostsSelect($categoryId = null, $limit = null)
48 48
     {
49 49
         $select = $this->getSql()->select()
50
-            ->columns(['category_name' => 'name', 'category_slug' => 'slug'])
51
-            ->join('articles', 'articles.category_uuid = category.category_uuid', ['article_id', 'slug', 'admin_user_uuid', 'published_at'])
52
-            ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', ['*'], 'right')
53
-            ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', ['admin_user_id', 'first_name', 'last_name', 'face_img'])
54
-            ->where(['articles.status' => 1])
55
-            ->order(['published_at' => 'desc']);
56
-
57
-        if($categoryId) {
58
-            $select->where(['category_id' => $categoryId]);
50
+            ->columns([ 'category_name' => 'name', 'category_slug' => 'slug' ])
51
+            ->join('articles', 'articles.category_uuid = category.category_uuid', [ 'article_id', 'slug', 'admin_user_uuid', 'published_at' ])
52
+            ->join('article_posts', 'article_posts.article_uuid = articles.article_uuid', [ '*' ], 'right')
53
+            ->join('admin_users', 'admin_users.admin_user_uuid = articles.admin_user_uuid', [ 'admin_user_id', 'first_name', 'last_name', 'face_img' ])
54
+            ->where([ 'articles.status' => 1 ])
55
+            ->order([ 'published_at' => 'desc' ]);
56
+
57
+        if ($categoryId) {
58
+            $select->where([ 'category_id' => $categoryId ]);
59 59
         }
60 60
 
61
-        if($limit) {
61
+        if ($limit) {
62 62
             $select->limit($limit);
63 63
         }
64 64
 
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
         $select->where->notEqualTo('slug', 'videos');
87 87
         $select->where->notEqualTo('slug', 'events');
88 88
 
89
-        if($inHomepage !== null){
90
-            $select->where(['is_in_homepage' => $inHomepage]);
89
+        if ($inHomepage !== null) {
90
+            $select->where([ 'is_in_homepage' => $inHomepage ]);
91 91
         }
92 92
 
93
-        if($inCategoryList !== null){
94
-            $select->where(['is_in_category_list' => $inCategoryList]);
93
+        if ($inCategoryList !== null) {
94
+            $select->where([ 'is_in_category_list' => $inCategoryList ]);
95 95
         }
96 96
 
97
-        if($limit) {
97
+        if ($limit) {
98 98
             $select->limit($limit);
99 99
         }
100 100
 
101
-        if($order) {
101
+        if ($order) {
102 102
             $select->order($order);
103 103
         } else {
104 104
             $select->order(new Expression('rand()'));
Please login to merge, or discard this patch.
packages/Category/src/Controller/IndexController.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
     public function index() : \Psr\Http\Message\ResponseInterface
49 49
     {
50 50
         $params = $this->request->getQueryParams();
51
-        $page   = isset($params['page']) ? $params['page'] : 1;
52
-        $limit  = isset($params['limit']) ? $params['limit'] : 15;
51
+        $page   = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
52
+        $limit  = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15;
53 53
 
54 54
         $categories = $this->categoryService->getPagination($page, $limit);
55 55
 
56
-        return new HtmlResponse($this->template->render('category::index/index', ['list' => $categories, 'layout' => 'layout/admin']));
56
+        return new HtmlResponse($this->template->render('category::index/index', [ 'list' => $categories, 'layout' => 'layout/admin' ]));
57 57
     }
58 58
 
59 59
     /**
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @return \Psr\Http\Message\ResponseInterface
63 63
      */
64
-    public function edit($errors = []): \Psr\Http\Message\ResponseInterface
64
+    public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface
65 65
     {
66 66
         $id       = $this->request->getAttribute('id');
67 67
         $category = $this->categoryService->getCategory($id);
68 68
 
69
-        if($this->request->getParsedBody()){
70
-            $category              = (object)($this->request->getParsedBody() + (array)$category);
69
+        if ($this->request->getParsedBody()) {
70
+            $category              = (object) ($this->request->getParsedBody() + (array) $category);
71 71
             $category->category_id = $id;
72 72
         }
73 73
 
@@ -80,37 +80,37 @@  discard block
 block discarded – undo
80 80
 
81 81
     public function save()
82 82
     {
83
-        try{
83
+        try {
84 84
             $id   = $this->request->getAttribute('id');
85 85
             $data = $this->request->getParsedBody();
86 86
             $data += (new Request())->getFiles()->toArray();
87 87
 
88
-            if($id){
88
+            if ($id) {
89 89
                 $this->categoryService->updateCategory($data, $id);
90 90
             }
91
-            else{
91
+            else {
92 92
                 $this->categoryService->createCategory($data);
93 93
             }
94 94
 
95 95
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
96 96
         }
97
-        catch(FilterException $fe){
97
+        catch (FilterException $fe) {
98 98
             return $this->edit($fe->getArrayMessages());
99 99
         }
100
-        catch(\Exception $e){
100
+        catch (\Exception $e) {
101 101
             throw $e;
102 102
         }
103 103
     }
104 104
 
105 105
     public function delete()
106 106
     {
107
-        try{
107
+        try {
108 108
             $id = $this->request->getAttribute('id');
109 109
             $this->categoryService->delete($id);
110 110
 
111 111
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
112 112
         }
113
-        catch(\Exception $e){
113
+        catch (\Exception $e) {
114 114
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
115 115
         }
116 116
     }
Please login to merge, or discard this patch.
packages/Category/src/Filter/CategoryFilter.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,59 +12,59 @@
 block discarded – undo
12 12
 
13 13
     public function getInputFilter()
14 14
     {
15
-        if(!$this->inputFilter) {
15
+        if (!$this->inputFilter) {
16 16
             $inputFilter = new InputFilter();
17 17
 
18 18
             $inputFilter->add([
19 19
                 'name'       => 'name',
20 20
                 'required'   => true,
21
-                'filters'    => [['name' => 'StringTrim']],
21
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
22 22
                 'validators' => [
23
-                    ['name' => 'NotEmpty'],
24
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 500]],
23
+                    [ 'name' => 'NotEmpty' ],
24
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 500 ] ],
25 25
                 ],
26 26
             ]);
27 27
 
28 28
             $inputFilter->add([
29 29
                 'name'       => 'slug',
30 30
                 'required'   => true,
31
-                'filters'    => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]],
31
+                'filters'    => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ],
32 32
                 'validators' => [
33
-                    ['name' => 'NotEmpty'],
34
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]],
33
+                    [ 'name' => 'NotEmpty' ],
34
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ],
35 35
                 ],
36 36
             ]);
37 37
 
38 38
             $inputFilter->add([
39 39
                 'name'       => 'title',
40 40
                 'required'   => false,
41
-                'filters'    => [['name' => 'StringTrim']],
41
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
42 42
                 'validators' => [
43
-                    ['name' => 'NotEmpty'],
44
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]],
43
+                    [ 'name' => 'NotEmpty' ],
44
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ],
45 45
                 ],
46 46
             ]);
47 47
 
48 48
             $inputFilter->add([
49 49
                 'name'       => 'description',
50 50
                 'required'   => false,
51
-                'filters'    => [['name' => 'StringTrim']],
51
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
52 52
                 'validators' => [
53
-                    ['name' => 'NotEmpty'],
54
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 1000]],
53
+                    [ 'name' => 'NotEmpty' ],
54
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 1000 ] ],
55 55
                 ],
56 56
             ]);
57 57
 
58 58
             $inputFilter->add([
59 59
                 'name'     => 'is_in_homepage',
60 60
                 'required' => false,
61
-                'filters'  => [['name' => 'Boolean']],
61
+                'filters'  => [ [ 'name' => 'Boolean' ] ],
62 62
             ]);
63 63
 
64 64
             $inputFilter->add([
65 65
                 'name'     => 'is_in_category_list',
66 66
                 'required' => false,
67
-                'filters'  => [['name' => 'Boolean']],
67
+                'filters'  => [ [ 'name' => 'Boolean' ] ],
68 68
             ]);
69 69
 
70 70
             $this->inputFilter = $inputFilter;
Please login to merge, or discard this patch.
packages/Category/src/View/Helper/CategoryHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
      */
33 33
     public function forHomepage()
34 34
     {
35
-        if(!$this->homepageCategories) {
35
+        if (!$this->homepageCategories) {
36 36
             $this->homepageCategories = $this->categoryService->getCategoriesWithPosts(true);
37 37
         }
38 38
 
Please login to merge, or discard this patch.