Proyectos de Subversion LeadersLinked - Services

Rev

Rev 234 | Rev 242 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
declare(strict_types=1);
3
 
4
namespace LeadersLinked\Controller;
5
 
6
use Laminas\Db\Adapter\AdapterInterface;
7
 
8
use Laminas\Mvc\Controller\AbstractActionController;
9
use Laminas\Log\LoggerInterface;
10
use Laminas\View\Model\JsonModel;
11
use Laminas\View\Model\ViewModel;
12
 
13
use LeadersLinked\Library\Functions;
14
use LeadersLinked\Model\Post;
15
use LeadersLinked\Mapper\PostMapper;
16
use LeadersLinked\Mapper\UserMapper;
17
use LeadersLinked\Mapper\CommentMapper;
18
use LeadersLinked\Model\ContentReaction;
19
use LeadersLinked\Model\Comment;
20
use LeadersLinked\Form\Post\CommentForm;
21
use LeadersLinked\Mapper\ContentReactionMapper;
22
 
23
 
24
 
25
class PostController extends AbstractActionController
26
{
27
    /**
28
     *
29
     * @var \Laminas\Db\Adapter\AdapterInterface
30
     */
31
    private $adapter;
32
 
33
    /**
34
     *
35
     * @var \LeadersLinked\Cache\CacheInterface
36
     */
37
    private $cache;
38
 
39
 
40
    /**
41
     *
42
     * @var \Laminas\Log\LoggerInterface
43
     */
44
    private $logger;
45
 
46
    /**
47
     *
48
     * @var array
49
     */
50
    private $config;
51
 
52
 
53
    /**
54
     *
55
     * @var \Laminas\Mvc\I18n\Translator
56
     */
57
    private $translator;
58
 
59
 
60
    /**
61
     *
62
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
63
     * @param \LeadersLinked\Cache\CacheInterface $cache
64
     * @param \Laminas\Log\LoggerInterface LoggerInterface $logger
65
     * @param array $config
66
     * @param \Laminas\Mvc\I18n\Translator $translator
67
     */
68
    public function __construct($adapter, $cache, $logger, $config, $translator)
69
    {
70
        $this->adapter      = $adapter;
71
        $this->cache        = $cache;
72
        $this->logger       = $logger;
73
        $this->config       = $config;
74
        $this->translator   = $translator;
75
    }
76
 
77
    /**
78
     *
79
     * Generación del listado de perfiles
80
     * {@inheritDoc}
81
     * @see \Laminas\Mvc\Controller\AbstractActionController::indexAction()
82
     */
83
    public function indexAction()
84
    {
85
 
86
        return new JsonModel([
87
            'success' => false,
88
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
89
        ]);
90
    }
91
 
92
    public function viewAction()
93
    {
94
        $request = $this->getRequest();
95
        if ($request->isGet()) {
96
            $currentUserPlugin = $this->plugin('currentUserPlugin');
97
            $currentUser = $currentUserPlugin->getUser();
98
 
99
 
100
            $id = $this->params()->fromRoute('id');
101
 
102
            $postMapper = PostMapper::getInstance($this->adapter);
103
            $post = $postMapper->fetchOneByUuid($id);
104
 
105
 
106
                if (!$post || $post->status != Post::STATUS_ACTIVE) {
107
                    return new JsonModel([
108
                        'success' => false,
109
                        'data' => 'ERROR_POST_NOT_AVAILABLE'
110
                    ]);
111
                }
112
 
113
 
114
            $timestamp = time();
115
 
116
            list($usec, $sec) = explode(' ', microtime());
117
            $seed = intval($sec + ((float) $usec * 100000));
118
            mt_srand($seed, MT_RAND_MT19937);
119
            $rand =  mt_rand();
120
 
121
 
122
 
123
            $password  = md5('user-' . $currentUser->uuid . '-post-' . $post->uuid . '-timestamp-' . $timestamp . '-rand-' . $rand . '-share-key-' . $currentUser->share_key);
124
 
125
 
126
            $share_params = [
127
                'type' => 'post',
128
                'code' => $post->uuid,
129
                'user' => $currentUser->uuid,
130
                'timestamp' => $timestamp,
131
                'rand' => $rand,
132
                'password' => $password,
133
            ];
134
            $share_increment_external_counter_url = $this->url()->fromRoute('share/increment-external-counter', $share_params, ['force_canonical' => true]);
135
 
136
 
137
            $share_external_url = $this->url()->fromRoute('shorter/generate', ['code' => $post->uuid, 'type' => 'post'], ['force_canonical' => true]);
138
 
139
            //$contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
140
            //$contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
141
 
142
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
143
            $reactions = $contentReactionMapper->fetchCountByPostId($post->id);
144
            $reaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
234 efrain 145
 
240 efrain 146
 
147
 
148
 
234 efrain 149
            $type = '';
240 efrain 150
 
234 efrain 151
            if($post->file) {
240 efrain 152
                $filename = trim(strtolower(basename($post->file)));
153
                $parts = explode('.', $filename);
154
 
155
 
156
                $max = is_array($parts) ? count($parts) : 0;
157
 
158
 
159
                if($max > 1) {
160
                    $extension = $parts[ $max -1 ];
234 efrain 161
                    if(in_array($extension, ['mov', 'webm','mp4','mpeg'] )) {
162
                        $type = 'video';
163
                    } else if(in_array($extension, ['jpg','jpeg','png'] )) {
164
                        $type = 'image';
165
                    } else if(in_array($extension, ['wav', 'mp3', 'pdf'] )) {
166
                        $type = 'audio';
167
                    }
168
                }
1 efrain 169
 
234 efrain 170
            }
171
 
240 efrain 172
 
173
 
174
 
1 efrain 175
 
234 efrain 176
 
177
 
178
 
1 efrain 179
                return new JsonModel([
180
                    'success' => true,
181
                    'data' => [
182
                        'post' => $post,
183
                        'id' => $post->id,
184
                        'uuid' => $post->uuid,
185
                        'title' => $post->title,
186
                        'description' => $post->description,
187
                        'url' => $post->url,
188
                        'date' => $post->date,
234 efrain 189
                        'type' => $post->type,
1 efrain 190
                        'status' => $post->status,
140 efrain 191
                        'image' =>   $this->url()->fromRoute('storage',['type' => 'post', 'code' => $post->uuid, 'filename' => $post->image], ['force_canonical' => true]),
192
                        'file' => $post->file ? $this->url()->fromRoute('storage',['type' => 'post', 'code' => $post->uuid, 'filename' => $post->file], ['force_canonical' => true]) : '',
234 efrain 193
                        'type' => $type,
1 efrain 194
                        'added_on' => $post->added_on,
195
                        'share_external_url' =>  $share_external_url,
196
                        'total_share_external' => $post->total_external_shared,
197
                        'share_increment_external_counter_url' => $share_increment_external_counter_url,
198
                        'comments_url' => $this->url()->fromRoute('post/comments', ['id' => $post->uuid]),
199
                        'comments_add_url' => $this->url()->fromRoute('post/comments/add', ['id' => $post->uuid]),
200
                        'save_reaction_url' => $this->url()->fromRoute('post/save-reaction', ['id' => $post->uuid]),
201
                        'delete_reaction_url' =>  $this->url()->fromRoute('post/delete-reaction', ['id' => $post->uuid]),
202
                        'my_reaction' => $reaction ? $reaction->reaction : '',
203
                        'reactions' =>  $reactions,
204
                        //'is_liked' => $contentReaction ? 1 : 0,
205
                        //'like_url' => $this->url()->fromRoute('post/like', ['id' => $post->uuid]),
206
                        //'unlike_url' => $this->url()->fromRoute('post/unlike', ['id' => $post->uuid]),
207
 
208
                    ]
209
                ]);
210
        } else {
211
            $response = [
212
                'success' => false,
213
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
214
            ];
215
            return new JsonModel($response);
216
        }
217
    }
218
 
219
    public function commentsAddAction()
220
    {
221
        $id = $this->params()->fromRoute('id');
222
 
223
        $request = $this->getRequest();
224
        if ($request->isPost()) {
225
 
226
 
227
 
228
            $postMapper = PostMapper::getInstance($this->adapter);
229
            $now = $postMapper->getDatebaseNow();
230
 
231
            $post = $postMapper->fetchOneByUuid($id);
232
            if (!$post) {
233
                $response = [
234
                    'success' => false,
235
                    'data' => 'ERROR_POST_NOT_FOUND'
236
                ];
237
                return new JsonModel($response);
238
            }
239
 
240
            $dataPost = $request->getPost()->toArray();
241
            $form = new CommentForm();
242
            $form->setData($dataPost);
243
 
244
            if ($form->isValid()) {
245
 
246
 
247
                $currentUserPlugin = $this->plugin('currentUserPlugin');
248
                $currentUser = $currentUserPlugin->getUser();
249
 
250
                $dataPost = (array) $form->getData();
251
 
252
 
253
 
254
                $comment = new Comment();
255
                $comment->network_id = $currentUser->network_id;
256
                $comment->comment = $dataPost['comment'];
257
                $comment->user_id = $currentUser->id;
258
                $comment->post_id = $post->id;
259
                $comment->relational = Comment::RELATIONAL_POST;
260
 
261
                $commentMapper = CommentMapper::getInstance($this->adapter);
262
                if ($commentMapper->insert($comment)) {
263
 
264
                    $total_comments = $commentMapper->fetchCountCommentByPostId($comment->post_id);
265
 
266
                    $post->total_comments = $total_comments;
267
                    $postMapper->update($post);
268
 
269
                    $response = [
270
                        'success'   => true,
271
                        'data'   => $this->renderComment($comment->id, $now),
272
                        'total_comments' => $total_comments
273
                    ];
274
 
275
                    return new JsonModel($response);
276
                } else {
277
 
278
                    $response = [
279
                        'success'   => false,
280
                        'data'   => $commentMapper->getError()
281
                    ];
282
 
283
                    return new JsonModel($response);
284
                }
285
            } else {
286
                $message = '';;
287
                $form_messages = (array) $form->getMessages();
288
                foreach ($form_messages  as $fieldname => $field_messages) {
289
                    foreach ($field_messages as $key => $value) {
290
                        $message = $value;
291
                    }
292
                }
293
 
294
                $response = [
295
                    'success'   => false,
296
                    'data'   => $message
297
                ];
298
 
299
                return new JsonModel($response);
300
            }
301
        } else {
302
            $response = [
303
                'success' => false,
304
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
305
            ];
306
 
307
            return new JsonModel($response);
308
        }
309
    }
310
 
311
 
312
 
313
    public function commentsDeleteAction()
314
    {
315
        $request = $this->getRequest();
316
        if ($request->isPost()) {
317
            $currentUserPlugin = $this->plugin('currentUserPlugin');
318
            $currentUser = $currentUserPlugin->getUser();
319
 
320
            $post_id = $this->params()->fromRoute('id');
321
            $comment = $this->params()->fromRoute('comment');
322
 
323
            $postMapper = PostMapper::getInstance($this->adapter);
324
            $post = $postMapper->fetchOneByUuidAndNetworkId($post_id, $currentUser->network_id);
325
 
326
            if ($post) {
327
 
328
                $commentMapper = CommentMapper::getInstance($this->adapter);
329
                $comment = $commentMapper->fetchOneByUuid($comment);
330
 
331
                if ($comment && $comment->post_id == $post->id && $comment->user_id == $currentUser->id) {
332
 
333
                    $comment->status = Comment::STATUS_DELETED;
334
 
335
                    if ($commentMapper->update($comment)) {
336
 
337
                        $total_comments = $commentMapper->fetchCountCommentByPostId($comment->post_id);
338
 
339
 
340
                        $postMapper = PostMapper::getInstance($this->adapter);
341
                        $post = $postMapper->fetchOne($comment->post_id);
342
                        $post->total_comments = $total_comments;
343
                        $postMapper->update($post);
344
 
345
 
346
 
347
 
348
 
349
                        $response = [
350
                            'success' => true,
351
                            'data' => 'LABEL_COMMENT_WAS_DELETED',
352
                            'total_comments' => $total_comments
353
                        ];
354
                    } else {
355
                        $response = [
356
                            'success' => false,
357
                            'data' => $commentMapper->getError()
358
                        ];
359
                    }
360
                } else {
361
                    $response = [
362
                        'success' => false,
363
                        'data' => 'ERROR_COMMENT_NOT_FOUND'
364
                    ];
365
                }
366
            } else {
367
                $response = [
368
                    'success' => false,
369
                    'data' => 'ERROR_COMMENT_NOT_FOUND'
370
                ];
371
            }
372
        } else {
373
            $response = [
374
                'success' => false,
375
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
376
            ];
377
        }
378
 
379
        return new JsonModel($response);
380
    }
381
 
382
    /*
383
    public function likeAction()
384
    {
385
        $id = $this->params()->fromRoute('id');
386
 
387
        $request = $this->getRequest();
388
        if ($request->isPost()) {
389
            $currentUserPlugin = $this->plugin('currentUserPlugin');
390
            $currentUser = $currentUserPlugin->getUser();
391
 
392
 
393
            $postMapper = PostMapper::getInstance($this->adapter);
394
            $post = $postMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
395
            if (!$post) {
396
                $response = [
397
                    'success' => false,
398
                    'data' => 'ERROR_POST_NOT_FOUND'
399
                ];
400
                return new JsonModel($response);
401
            }
402
 
403
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
404
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
405
 
406
            if ($contentReaction) {
407
                $response = [
408
                    'success' => false,
409
                    'data' => 'ERROR_DUPLICATE_ACTION'
410
                ];
411
                return new JsonModel($response);
412
            }
413
 
414
            $contentReaction = new Like();
415
            $contentReaction->user_id = $currentUser->id;
416
            $contentReaction->post_id = $post->id;
417
            $contentReaction->relational = Like::RELATIONAL_POST;
418
 
419
            if ($contentReactionMapper->insert($contentReaction)) {
420
 
421
                $contentReactions = $contentReactionMapper->fetchCountLikeByPostId($post->id);
422
                $response = [
423
                    'success' => true,
424
                    'data' => [
425
                        'likes' => $contentReactions
426
                    ]
427
                ];
428
            } else {
429
                $response = [
430
                    'success' => false,
431
                    'data' => $contentReactionMapper->getError()
432
                ];
433
            }
434
            return new JsonModel($response);
435
        }
436
 
437
        $response = [
438
            'success' => false,
439
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
440
        ];
441
        return new JsonModel($response);
442
    }
443
 
444
    public function unlikeAction()
445
    {
446
        $id = $this->params()->fromRoute('id');
447
 
448
        $request = $this->getRequest();
449
        if ($request->isPost()) {
450
            $currentUserPlugin = $this->plugin('currentUserPlugin');
451
            $currentUser = $currentUserPlugin->getUser();
452
 
453
            $postMapper = PostMapper::getInstance($this->adapter);
454
            $post = $postMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
455
            if (!$post) {
456
                $response = [
457
                    'success' => false,
458
                    'data' => 'ERROR_POST_NOT_FOUND'
459
                ];
460
                return new JsonModel($response);
461
            }
462
 
463
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
464
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
465
 
466
            if (!$contentReaction) {
467
                $response = [
468
                    'success' => false,
469
                    'data' => 'ERROR_DUPLICATE_ACTION'
470
                ];
471
                return new JsonModel($response);
472
            }
473
 
474
            if ($contentReactionMapper->deleteByPostIdAndUserId($post->id, $currentUser->id)) {
475
                $contentReactions = $contentReactionMapper->fetchCountLikeByPostId($post->id);
476
 
477
 
478
                $response = [
479
                    'success' => true,
480
                    'data' => [
481
                        'likes' => $contentReactions
482
                    ]
483
                ];
484
            } else {
485
                $response = [
486
                    'success' => false,
487
                    'data' => $contentReactionMapper->getError()
488
                ];
489
            }
490
            return new JsonModel($response);
491
        }
492
 
493
        $response = [
494
            'success' => false,
495
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
496
        ];
497
        return new JsonModel($response);
498
    }*/
499
 
500
    public function saveReactionAction()
501
    {
502
        $id = $this->params()->fromRoute('id');
503
        $reaction  = $this->params()->fromPost('reaction');
504
 
505
        $request = $this->getRequest();
506
        if ($request->isPost()) {
507
            $currentUserPlugin = $this->plugin('currentUserPlugin');
508
            $currentUser = $currentUserPlugin->getUser();
509
 
510
 
511
            $postMapper = PostMapper::getInstance($this->adapter);
512
            $post = $postMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
513
            if (!$post) {
514
                $response = [
515
                    'success' => false,
516
                    'data' => 'ERROR_POST_NOT_FOUND'
517
                ];
518
                return new JsonModel($response);
519
            }
520
 
521
            $reactions = [
522
                ContentReaction::REACTION_RECOMMENDED,
523
                ContentReaction::REACTION_SUPPORT,
524
                ContentReaction::REACTION_LOVE,
525
                ContentReaction::REACTION_INTEREST,
526
                ContentReaction::REACTION_FUN
527
 
528
            ];
529
            if(!in_array($reaction, $reactions)) {
530
                $response = [
531
                    'success' => false,
532
                    'data' => 'ERROR_REACTION_NOT_FOUND'
533
                ];
534
                return new JsonModel($response);
535
            }
536
 
537
 
538
 
539
 
540
 
541
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
542
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
543
 
544
            if ($contentReaction) {
545
                $contentReaction->reaction = $reaction;
546
 
547
                $result = $contentReactionMapper->update($contentReaction);
548
            } else {
549
                $contentReaction = new ContentReaction();
550
                $contentReaction->user_id = $currentUser->id;
551
                $contentReaction->post_id = $post->id;
552
                $contentReaction->relational = ContentReaction::RELATIONAL_POST;
553
                $contentReaction->reaction = $reaction;
554
 
555
                $result = $contentReactionMapper->insert($contentReaction);
556
            }
557
 
558
 
559
 
560
            if ($result) {
561
 
562
                $reactions = $contentReactionMapper->fetchCountByPostId($post->id);
563
                $response = [
564
                    'success' => true,
565
                    'data' => [
566
                        'reactions' => $reactions
567
                    ]
568
                ];
569
            } else {
570
                $response = [
571
                    'success' => false,
572
                    'data' => $contentReactionMapper->getError()
573
                ];
574
            }
575
            return new JsonModel($response);
576
        }
577
 
578
        $response = [
579
            'success' => false,
580
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
581
        ];
582
        return new JsonModel($response);
583
    }
584
 
585
    public function deleteReactionAction()
586
    {
587
        $id = $this->params()->fromRoute('id');
588
 
589
        $request = $this->getRequest();
590
        if ($request->isPost()) {
591
            $currentUserPlugin = $this->plugin('currentUserPlugin');
592
            $currentUser = $currentUserPlugin->getUser();
593
 
594
            $postMapper = PostMapper::getInstance($this->adapter);
595
            $post = $postMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
596
            if (!$post) {
597
                $response = [
598
                    'success' => false,
599
                    'data' => 'ERROR_POST_NOT_FOUND'
600
                ];
601
                return new JsonModel($response);
602
            }
603
 
604
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
605
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
606
 
607
            if (!$contentReaction) {
608
                $response = [
609
                    'success' => false,
610
                    'data' => 'ERROR_DUPLICATE_ACTION'
611
                ];
612
                return new JsonModel($response);
613
            }
614
 
615
            if ($contentReactionMapper->deleteByPostIdAndUserId($post->id, $currentUser->id)) {
616
                $reactions = $contentReactionMapper->fetchCountByPostId($post->id);
617
 
618
 
619
                $response = [
620
                    'success' => true,
621
                    'data' => [
622
                        'reactions' => $reactions
623
                    ]
624
                ];
625
            } else {
626
                $response = [
627
                    'success' => false,
628
                    'data' => $contentReactionMapper->getError()
629
                ];
630
            }
631
            return new JsonModel($response);
632
        }
633
 
634
        $response = [
635
            'success' => false,
636
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
637
        ];
638
        return new JsonModel($response);
639
    }
640
 
641
    public function commentsAction()
642
    {
643
        $id = $this->params()->fromRoute('id');
644
 
645
        $request = $this->getRequest();
646
        if ($request->isGet()) {
647
 
648
 
649
 
650
            $currentUserPlugin = $this->plugin('currentUserPlugin');
651
            $currentUser = $currentUserPlugin->getUser();
652
 
653
            $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
654
            $currentNetwork = $currentNetworkPlugin->getNetwork();
655
 
656
 
657
            $id = $this->params()->fromRoute('id');
658
            $postMapper = PostMapper::getInstance($this->adapter);
659
            $now = $postMapper->getDatebaseNow();
660
 
661
            $post = $postMapper->fetchOneByUuidAndNetworkId($id,  $currentNetwork->id);
662
            if (!$post) {
663
                $data = [
664
                    'success' => false,
665
                    'data' => 'ERROR_UNAUTHORIZED',
666
                ];
667
 
668
                return new JsonModel($data);
669
            }
670
 
671
            $commentMapper = CommentMapper::getInstance($this->adapter);
672
            $records = $commentMapper->fetchAllPublishedByPostId($post->id);
673
 
674
            $comments = [];
675
            foreach ($records as $record) {
676
                $comment = $this->renderComment($record->id, $now);
677
                array_push($comments, $comment);
678
            }
679
 
680
            $response = [
681
                'success' => true,
682
                'data' => $comments
683
            ];
684
 
685
            return new JsonModel($response);
686
        } else {
687
 
688
 
689
 
690
            $response = [
691
                'success' => false,
692
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
693
            ];
694
 
695
 
696
            return new JsonModel($response);
697
        }
698
    }
699
 
700
 
701
 
702
    /**
703
     *
704
     * @param int $comment_id
705
     * @return array
706
     */
707
    private function renderComment($comment_id, $now)
708
    {
709
        $item = [];
710
 
711
        $commentMapper = CommentMapper::getInstance($this->adapter);
712
        $record = $commentMapper->fetchOne($comment_id);
713
 
714
        $postMapper = PostMapper::getInstance($this->adapter);
715
        $post = $postMapper->fetchOne($record->post_id);
716
 
717
        if ($record) {
718
            $userMapper = UserMapper::getInstance($this->adapter);
719
 
720
            $user = $userMapper->fetchOne($record->user_id);
721
 
722
            $item['unique'] = uniqid();
60 efrain 723
            $item['user_image'] = $this->url()->fromRoute('storage', ['type' => 'user',  'code' => $user->uuid, 'filename' =>  $user->image],['force_canonical' => true]);
1 efrain 724
            $item['user_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid]);
725
            $item['user_name'] = $user->first_name . ' ' . $user->last_name;
726
            $item['time_elapsed'] = Functions::timeAgo($record->added_on, $now);
727
            $item['comment'] = $record->comment;
728
            $item['link_delete'] = $this->url()->fromRoute('post/comments/delete', ['id' => $post->uuid, 'comment' => $record->uuid]);
729
        }
730
        return $item;
731
    }
732
}