@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Web\Factory\Action; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Web\Factory\Action; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Web\Action; |
| 6 | 6 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $urlSlug1 = $request->getAttribute('segment_1'); |
| 49 | 49 | $urlSlug2 = $request->getAttribute('segment_2'); |
| 50 | 50 | |
| 51 | - if($urlSlug2) { |
|
| 51 | + if ($urlSlug2) { |
|
| 52 | 52 | $categorySlug = $urlSlug1; |
| 53 | 53 | $postSlug = $urlSlug2; |
| 54 | 54 | } else { |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $post = $this->postService->fetchSingleArticleBySlug($postSlug); |
| 60 | 60 | |
| 61 | - if(!$post) { |
|
| 61 | + if (!$post) { |
|
| 62 | 62 | return $next($request, $response); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | list($previousPost, $nextPost) = $this->postService->fetchNearestArticle($post->published_at); |
| 66 | 66 | |
| 67 | - if(!$post) { |
|
| 67 | + if (!$post) { |
|
| 68 | 68 | $response = $response->withStatus(404); |
| 69 | 69 | |
| 70 | 70 | return $next($request, $response, new \Exception("Post by URL does not exist!", 404)); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Web\Action; |
| 6 | 6 | |
@@ -64,21 +64,21 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $eventSlug = $request->getAttribute('event_slug'); |
| 66 | 66 | $event = $this->eventService->fetchEventBySlug($eventSlug); |
| 67 | - $attendees = []; |
|
| 67 | + $attendees = [ ]; |
|
| 68 | 68 | |
| 69 | - if(!$event) { |
|
| 69 | + if (!$event) { |
|
| 70 | 70 | return $next($request, $response); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Fetch going ppl |
| 74 | 74 | try { |
| 75 | - if(strpos($event->event_url, 'meetup.com') !== false) { |
|
| 75 | + if (strpos($event->event_url, 'meetup.com') !== false) { |
|
| 76 | 76 | $parts = explode('/', $event->event_url); |
| 77 | - $attendees = $this->meetupService->getMeetupAttendees($parts[count($parts) - 2]); |
|
| 77 | + $attendees = $this->meetupService->getMeetupAttendees($parts[ count($parts) - 2 ]); |
|
| 78 | 78 | shuffle($attendees); |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | - catch(\Exception $e) { |
|
| 81 | + catch (\Exception $e) { |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | return new HtmlResponse($this->template->render('web::event', [ |
@@ -73,8 +73,7 @@ |
||
| 73 | 73 | $attendees = $this->meetupService->getMeetupAttendees($parts[count($parts) - 2]); |
| 74 | 74 | shuffle($attendees); |
| 75 | 75 | } |
| 76 | - } |
|
| 77 | - catch(\Exception $e) { |
|
| 76 | + } catch(\Exception $e) { |
|
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | return new HtmlResponse($this->template->render('web::event', [ |
@@ -1,6 +1,6 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Web\Action; |
| 6 | 6 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $videoSlug = $request->getAttribute('video_slug'); |
| 56 | 56 | $video = $this->videoService->fetchVideoBySlug($videoSlug); |
| 57 | 57 | |
| 58 | - if(!$video) { |
|
| 58 | + if (!$video) { |
|
| 59 | 59 | return $next($request, $response); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -1,6 +1,6 @@ discard block |
||
| 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 |
||
| 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->allWeb(); |
| 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 | ]; |
@@ -1,6 +1,6 @@ discard block |
||
| 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 |
||
| 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 | |
| 57 | 57 | return new HtmlResponse($this->template->render('web::videos', [ |
@@ -28,26 +28,26 @@ discard block |
||
| 28 | 28 | private function unflattenArray(array $flatArray) |
| 29 | 29 | { |
| 30 | 30 | $flatArray = array_reverse($flatArray); |
| 31 | - $refs = []; |
|
| 32 | - $result = []; |
|
| 31 | + $refs = [ ]; |
|
| 32 | + $result = [ ]; |
|
| 33 | 33 | |
| 34 | - while(count($flatArray) > 0) { |
|
| 35 | - for($i = count($flatArray) - 1; $i >= 0; $i--) { |
|
| 36 | - if(!isset($flatArray[$i]['children'])) { |
|
| 37 | - $flatArray[$i]['children'] = []; |
|
| 34 | + while (count($flatArray) > 0) { |
|
| 35 | + for ($i = count($flatArray) - 1; $i >= 0; $i--) { |
|
| 36 | + if (!isset($flatArray[ $i ][ 'children' ])) { |
|
| 37 | + $flatArray[ $i ][ 'children' ] = [ ]; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if(!$flatArray[$i]["parent_id"]) { |
|
| 41 | - $result[$flatArray[$i]["menu_id"]] = $flatArray[$i]; |
|
| 42 | - $refs[$flatArray[$i]["menu_id"]] = &$result[$flatArray[$i]["menu_id"]]; |
|
| 43 | - unset($flatArray[$i]); |
|
| 40 | + if (!$flatArray[ $i ][ "parent_id" ]) { |
|
| 41 | + $result[ $flatArray[ $i ][ "menu_id" ] ] = $flatArray[ $i ]; |
|
| 42 | + $refs[ $flatArray[ $i ][ "menu_id" ] ] = &$result[ $flatArray[ $i ][ "menu_id" ] ]; |
|
| 43 | + unset($flatArray[ $i ]); |
|
| 44 | 44 | $flatArray = array_values($flatArray); |
| 45 | - } else if($flatArray[$i]["parent_id"] != 0) { |
|
| 46 | - if(array_key_exists($flatArray[$i]["parent_id"], $refs)) { |
|
| 47 | - $o = $flatArray[$i]; |
|
| 48 | - $refs[$flatArray[$i]["menu_id"]] = $o; |
|
| 49 | - $refs[$flatArray[$i]["parent_id"]]["children"][] = &$refs[$flatArray[$i]["menu_id"]]; |
|
| 50 | - unset($flatArray[$i]); |
|
| 45 | + } else if ($flatArray[ $i ][ "parent_id" ] != 0) { |
|
| 46 | + if (array_key_exists($flatArray[ $i ][ "parent_id" ], $refs)) { |
|
| 47 | + $o = $flatArray[ $i ]; |
|
| 48 | + $refs[ $flatArray[ $i ][ "menu_id" ] ] = $o; |
|
| 49 | + $refs[ $flatArray[ $i ][ "parent_id" ] ][ "children" ][ ] = &$refs[ $flatArray[ $i ][ "menu_id" ] ]; |
|
| 50 | + unset($flatArray[ $i ]); |
|
| 51 | 51 | $flatArray = array_values($flatArray); |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->postService = $postService; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function getNestedAll($isActive = null, $filter = []) |
|
| 68 | + public function getNestedAll($isActive = null, $filter = [ ]) |
|
| 69 | 69 | { |
| 70 | 70 | $items = $this->menuMapper->selectAll($isActive, $filter)->toArray(); |
| 71 | 71 | |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $data = $this->filterMenuItem($data); |
| 83 | 83 | |
| 84 | - $data['menu_id'] = Uuid::uuid1()->toString(); |
|
| 85 | - $data['menu_uuid'] = (new MysqlUuid($data['menu_id']))->toFormat(new Binary); |
|
| 84 | + $data[ 'menu_id' ] = Uuid::uuid1()->toString(); |
|
| 85 | + $data[ 'menu_uuid' ] = (new MysqlUuid($data[ 'menu_id' ]))->toFormat(new Binary); |
|
| 86 | 86 | |
| 87 | 87 | return $this->menuMapper->insertMenuItem($data); |
| 88 | 88 | } |
@@ -96,13 +96,13 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | public function delete($id) |
| 98 | 98 | { |
| 99 | - $children = $this->menuMapper->select(['parent_id' => $id]); |
|
| 99 | + $children = $this->menuMapper->select([ 'parent_id' => $id ]); |
|
| 100 | 100 | |
| 101 | - if($children->count()) { |
|
| 101 | + if ($children->count()) { |
|
| 102 | 102 | throw new \Exception('This Menu Item has child items', 400); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - return $this->menuMapper->delete(['menu_id' => $id]); |
|
| 105 | + return $this->menuMapper->delete([ 'menu_id' => $id ]); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public function getForSelect() |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public function updateMenuOrder($menuOrder) |
| 114 | 114 | { |
| 115 | - if(!$menuOrder) { |
|
| 115 | + if (!$menuOrder) { |
|
| 116 | 116 | return true; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $this->updateLevel(null, $menuOrder, $orderNo); |
| 123 | 123 | $this->menuMapper->getAdapter()->getDriver()->getConnection()->commit(); |
| 124 | 124 | } |
| 125 | - catch(\Exception $e) { |
|
| 125 | + catch (\Exception $e) { |
|
| 126 | 126 | $this->menuMapper->getAdapter()->getDriver()->getConnection()->rollback(); |
| 127 | 127 | |
| 128 | 128 | throw $e; |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | private function updateLevel($parentId = null, $children, &$orderNo) |
| 135 | 135 | { |
| 136 | - foreach($children as $v) { |
|
| 137 | - if(isset($v->children)) { |
|
| 138 | - $this->menuMapper->update(['order_no' => $orderNo++, 'parent_id' => $parentId], ['menu_id' => $v->id]); |
|
| 136 | + foreach ($children as $v) { |
|
| 137 | + if (isset($v->children)) { |
|
| 138 | + $this->menuMapper->update([ 'order_no' => $orderNo++, 'parent_id' => $parentId ], [ 'menu_id' => $v->id ]); |
|
| 139 | 139 | $this->updateLevel($v->id, $v->children, $orderNo); |
| 140 | 140 | } else { |
| 141 | - $this->menuMapper->update(['order_no' => $orderNo++, 'parent_id' => $parentId], ['menu_id' => $v->id]); |
|
| 141 | + $this->menuMapper->update([ 'order_no' => $orderNo++, 'parent_id' => $parentId ], [ 'menu_id' => $v->id ]); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -147,30 +147,30 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | $filter = $this->menuFilter->getInputFilter()->setData($data); |
| 149 | 149 | |
| 150 | - if(!$filter->isValid()) { |
|
| 150 | + if (!$filter->isValid()) { |
|
| 151 | 151 | throw new FilterException($filter->getMessages()); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if(count(array_filter([$data['article_id'], $data['category_id'], $data['href']])) > 1) { |
|
| 154 | + if (count(array_filter([ $data[ 'article_id' ], $data[ 'category_id' ], $data[ 'href' ] ])) > 1) { |
|
| 155 | 155 | throw new \Exception('You need to set only one link. Post, Category or Href.'); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | $data = $filter->getValues(); |
| 159 | 159 | |
| 160 | - if($data['article_id']) { |
|
| 161 | - $article = $this->postService->fetchSingleArticle($data['article_id']); |
|
| 162 | - $data['article_uuid'] = $article->article_uuid; |
|
| 163 | - $data['category_uuid'] = null; |
|
| 164 | - } elseif($data['category_id']) { |
|
| 165 | - $category = $this->categoryService->getCategory($data['category_id']); |
|
| 166 | - $data['category_uuid'] = $category->category_uuid; |
|
| 167 | - $data['article_uuid'] = null; |
|
| 160 | + if ($data[ 'article_id' ]) { |
|
| 161 | + $article = $this->postService->fetchSingleArticle($data[ 'article_id' ]); |
|
| 162 | + $data[ 'article_uuid' ] = $article->article_uuid; |
|
| 163 | + $data[ 'category_uuid' ] = null; |
|
| 164 | + } elseif ($data[ 'category_id' ]) { |
|
| 165 | + $category = $this->categoryService->getCategory($data[ 'category_id' ]); |
|
| 166 | + $data[ 'category_uuid' ] = $category->category_uuid; |
|
| 167 | + $data[ 'article_uuid' ] = null; |
|
| 168 | 168 | } else { |
| 169 | - $data['article_uuid'] = null; |
|
| 170 | - $data['category_uuid'] = null; |
|
| 169 | + $data[ 'article_uuid' ] = null; |
|
| 170 | + $data[ 'category_uuid' ] = null; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - unset($data['article_id'], $data['category_id']); |
|
| 173 | + unset($data[ 'article_id' ], $data[ 'category_id' ]); |
|
| 174 | 174 | |
| 175 | 175 | return $data; |
| 176 | 176 | } |
@@ -121,8 +121,7 @@ |
||
| 121 | 121 | $orderNo = 1; |
| 122 | 122 | $this->updateLevel(null, $menuOrder, $orderNo); |
| 123 | 123 | $this->menuMapper->getAdapter()->getDriver()->getConnection()->commit(); |
| 124 | - } |
|
| 125 | - catch(\Exception $e) { |
|
| 124 | + } catch(\Exception $e) { |
|
| 126 | 125 | $this->menuMapper->getAdapter()->getDriver()->getConnection()->rollback(); |
| 127 | 126 | |
| 128 | 127 | throw $e; |