@@ -68,15 +68,15 @@ |
||
68 | 68 | public function getAnswerCount() |
69 | 69 | { |
70 | 70 | // check if count is cached |
71 | - if (MainApp::$Memory->get('commentpost.answer.count.' . $this->id) !== null) { |
|
72 | - return MainApp::$Memory->get('commentpost.answer.count.' . $this->id); |
|
71 | + if (MainApp::$Memory->get('commentpost.answer.count.'.$this->id) !== null) { |
|
72 | + return MainApp::$Memory->get('commentpost.answer.count.'.$this->id); |
|
73 | 73 | } |
74 | 74 | // get count from db |
75 | 75 | $count = CommentAnswer::where('comment_id', $this->id) |
76 | 76 | ->where('moderate', 0) |
77 | 77 | ->count(); |
78 | 78 | // save in cache |
79 | - MainApp::$Memory->set('commentpost.answer.count.' . $this->id, $count); |
|
79 | + MainApp::$Memory->set('commentpost.answer.count.'.$this->id, $count); |
|
80 | 80 | return $count; |
81 | 81 | } |
82 | 82 | } |
@@ -46,10 +46,10 @@ |
||
46 | 46 | */ |
47 | 47 | public static function check($user1, $user2): bool |
48 | 48 | { |
49 | - $query = self::where(function ($query) use ($user1, $user2) { |
|
49 | + $query = self::where(function($query) use ($user1, $user2) { |
|
50 | 50 | $query->where('user_id', $user1) |
51 | 51 | ->where('target_id', $user2); |
52 | - })->orWhere(function ($query) use ($user1, $user2) { |
|
52 | + })->orWhere(function($query) use ($user1, $user2) { |
|
53 | 53 | $query->where('user_id', $user2) |
54 | 54 | ->where('target_id', $user1); |
55 | 55 | }); |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | // check if id is looks like integer |
53 | - if (!Any::isInt($id) || (int)$id < 1) { |
|
53 | + if (!Any::isInt($id) || (int) $id < 1) { |
|
54 | 54 | return null; |
55 | 55 | } |
56 | 56 | |
57 | 57 | // check in memory cache object |
58 | - if (MainApp::$Memory->get('user.object.cache.' . $id)) { |
|
59 | - return MainApp::$Memory->get('user.object.cache.' . $id); |
|
58 | + if (MainApp::$Memory->get('user.object.cache.'.$id)) { |
|
59 | + return MainApp::$Memory->get('user.object.cache.'.$id); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // not founded in memory? lets make query |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | ->find($id); |
65 | 65 | |
66 | 66 | // store cache and return object |
67 | - MainApp::$Memory->set('user.object.cache.' . $user->id, $user); |
|
67 | + MainApp::$Memory->set('user.object.cache.'.$user->id, $user); |
|
68 | 68 | return $user; |
69 | 69 | } |
70 | 70 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getId(): ?int |
76 | 76 | { |
77 | - return (int)$this->id; |
|
77 | + return (int) $this->id; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public static function isAuth(): bool |
96 | 96 | { |
97 | 97 | // get data from session |
98 | - $sessionUserId = (int)MainApp::$Session->get('ff_user_id', 0); |
|
98 | + $sessionUserId = (int) MainApp::$Session->get('ff_user_id', 0); |
|
99 | 99 | |
100 | 100 | // check if session contains user id data |
101 | 101 | if ($sessionUserId < 1) { |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | - $find = MainApp::$Memory->get('user.counter.cache.' . $id); |
|
131 | + $find = MainApp::$Memory->get('user.counter.cache.'.$id); |
|
132 | 132 | if (!$find) { |
133 | 133 | $find = self::where('id', $id)->count(); |
134 | - MainApp::$Memory->set('user.counter.cache.' . $id, $find); |
|
134 | + MainApp::$Memory->set('user.counter.cache.'.$id, $find); |
|
135 | 135 | } |
136 | 136 | |
137 | - return (int)$find === 1; |
|
137 | + return (int) $find === 1; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function inBlacklist(?string $target = null): bool |
233 | 233 | { |
234 | - if (!$target || (int)$target < 1) { |
|
234 | + if (!$target || (int) $target < 1) { |
|
235 | 235 | return false; |
236 | 236 | } |
237 | 237 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function all($columns = ['*']) |
40 | 40 | { |
41 | - $cacheName = 'activerecord.contentcategory.all.' . implode('.', $columns); |
|
41 | + $cacheName = 'activerecord.contentcategory.all.'.implode('.', $columns); |
|
42 | 42 | $records = MemoryObject::instance()->get($cacheName); |
43 | 43 | if (!$records) { |
44 | 44 | $records = parent::all($columns); |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public static function getByPath($path = '') |
56 | 56 | { |
57 | - if (MainApp::$Memory->get('cache.content.category.path.' . $path) !== null) { |
|
58 | - return MainApp::$Memory->get('cache.content.category.path.' . $path); |
|
57 | + if (MainApp::$Memory->get('cache.content.category.path.'.$path) !== null) { |
|
58 | + return MainApp::$Memory->get('cache.content.category.path.'.$path); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | $record = self::where('path', $path)->first(); |
62 | - MainApp::$Memory->set('cache.content.category.path.' . $path, $record); |
|
62 | + MainApp::$Memory->set('cache.content.category.path.'.$path, $record); |
|
63 | 63 | return $record; |
64 | 64 | } |
65 | 65 | |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public static function getById($id) |
72 | 72 | { |
73 | - if (MainApp::$Memory->get('cache.content.category.id.' . $id) !== null) { |
|
74 | - return MainApp::$Memory->get('cache.content.category.id.' . $id); |
|
73 | + if (MainApp::$Memory->get('cache.content.category.id.'.$id) !== null) { |
|
74 | + return MainApp::$Memory->get('cache.content.category.id.'.$id); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $record = self::find($id); |
78 | - MainApp::$Memory->set('cache.content.category.id.' . $id, $record); |
|
78 | + MainApp::$Memory->set('cache.content.category.id.'.$id, $record); |
|
79 | 79 | return $record; |
80 | 80 | } |
81 | 81 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | } else { |
95 | 95 | // set level marker based on slashes count in pathway |
96 | 96 | $slashCount = Str::entryCount($path, '/'); |
97 | - for ($i=-1; $i <= $slashCount; $i++) { |
|
97 | + for ($i = -1; $i <= $slashCount; $i++) { |
|
98 | 98 | $title .= '--'; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | // add canonical title from db |
102 | - $title .= ' ' . $data->getLocaled('title'); |
|
102 | + $title .= ' '.$data->getLocaled('title'); |
|
103 | 103 | // set response as array [id => title, ... ] |
104 | 104 | $response[$data->id] = $title; |
105 | 105 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function all($columns = ['*']) |
35 | 35 | { |
36 | - $cacheName = 'activerecords.role.all.' . implode('.', $columns); |
|
36 | + $cacheName = 'activerecords.role.all.'.implode('.', $columns); |
|
37 | 37 | $records = MemoryObject::instance()->get($cacheName); |
38 | 38 | if ($records === null) { |
39 | 39 | $records = parent::all($columns); |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public static function get($roleId) |
52 | 52 | { |
53 | - $role = MainApp::$Memory->get('user.role.cache.' . $roleId); |
|
53 | + $role = MainApp::$Memory->get('user.role.cache.'.$roleId); |
|
54 | 54 | |
55 | 55 | // not founded in cache |
56 | 56 | if ($role === null) { |
57 | 57 | $role = self::find($roleId); |
58 | - MainApp::$Memory->set('user.role.cache.' . $roleId, $role); |
|
58 | + MainApp::$Memory->set('user.role.cache.'.$roleId, $role); |
|
59 | 59 | } |
60 | 60 | return $role; |
61 | 61 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | public function __construct($record, $calcAnswers = true) |
31 | 31 | { |
32 | 32 | $this->_record = $record; |
33 | - $this->_calcAnswers = (bool)$calcAnswers; |
|
33 | + $this->_calcAnswers = (bool) $calcAnswers; |
|
34 | 34 | if ($this->_record instanceof CommentPost) { |
35 | 35 | $this->_type = 'post'; |
36 | 36 | } elseif ($this->_record instanceof CommentAnswer) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | // build user data |
55 | 55 | $userName = __('Unknown'); |
56 | - $userAvatar = App::$Alias->scriptUrl . '/upload/user/avatar/small/default.jpg'; |
|
56 | + $userAvatar = App::$Alias->scriptUrl.'/upload/user/avatar/small/default.jpg'; |
|
57 | 57 | $userColor = 0; |
58 | 58 | if ($this->_record->user && $this->_record->user->id > 0) { |
59 | 59 | $userName = $this->_record->user->profile->getNickname(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | 'date' => Date::convertToDatetime($this->_record->created_at, Date::FORMAT_TO_HOUR), |
74 | 74 | 'app_name' => $this->_record->app_name, |
75 | 75 | 'app_id' => $this->_record->app_relation_id, |
76 | - 'moderate' => (int)$this->_record->moderate, |
|
76 | + 'moderate' => (int) $this->_record->moderate, |
|
77 | 77 | 'user' => [ |
78 | 78 | 'id' => $this->_record->user_id, |
79 | 79 | 'name' => $userName, |
@@ -32,7 +32,7 @@ |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | // build full path |
35 | - $path = '/content/read/' . $content->getPath() . '#comments-list'; |
|
35 | + $path = '/content/read/'.$content->getPath().'#comments-list'; |
|
36 | 36 | |
37 | 37 | // redirect to comment. todo: load all comments and scroll to target by id |
38 | 38 | $this->response->redirect($path); |
@@ -25,13 +25,13 @@ |
||
25 | 25 | */ |
26 | 26 | public function display(string $id): void |
27 | 27 | { |
28 | - $status = (bool)$this->request->query->get('status', 0); |
|
28 | + $status = (bool) $this->request->query->get('status', 0); |
|
29 | 29 | $content = \Apps\ActiveRecord\Content::find($id); |
30 | 30 | if (!$content) { |
31 | 31 | throw new NotFoundException(__('Content {%id%} are not exist', ['id' => $id])); |
32 | 32 | } |
33 | 33 | // make update query if status is different than required |
34 | - if ((bool)$content->display !== $status) { |
|
34 | + if ((bool) $content->display !== $status) { |
|
35 | 35 | $content->display = $status; |
36 | 36 | $content->save(); |
37 | 37 | } |
@@ -24,13 +24,13 @@ |
||
24 | 24 | */ |
25 | 25 | public function important(string $id): void |
26 | 26 | { |
27 | - $status = (bool)$this->request->query->get('status', 0); |
|
27 | + $status = (bool) $this->request->query->get('status', 0); |
|
28 | 28 | $content = \Apps\ActiveRecord\Content::find($id); |
29 | 29 | if (!$content) { |
30 | 30 | throw new NotFoundException(__('Content {%id%} are not exist', ['id' => $id])); |
31 | 31 | } |
32 | 32 | |
33 | - if ((bool)$content->important !== $status) { |
|
33 | + if ((bool) $content->important !== $status) { |
|
34 | 34 | $content->important = $status; |
35 | 35 | $content->save(); |
36 | 36 | } |