|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Gitamin. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (C) 2015-2016 The Gitamin Team |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Gitamin\Presenters; |
|
13
|
|
|
|
|
14
|
|
|
use Gitamin\Facades\Setting; |
|
15
|
|
|
use Gitamin\Presenters\Traits\TimestampsTrait; |
|
16
|
|
|
use GrahamCampbell\Markdown\Facades\Markdown; |
|
17
|
|
|
|
|
18
|
|
|
class CommentPresenter extends AbstractPresenter |
|
19
|
|
|
{ |
|
20
|
|
|
use TimestampsTrait; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Renders the message from Markdown into HTML. |
|
24
|
|
|
* |
|
25
|
|
|
* @return string |
|
26
|
|
|
*/ |
|
27
|
|
|
public function formattedMessage() |
|
28
|
|
|
{ |
|
29
|
|
|
return Markdown::convertToHtml($this->wrappedObject->message); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Formats the created_at time ready to be used by bootstrap-datetimepicker. |
|
34
|
|
|
* |
|
35
|
|
|
* @return string |
|
36
|
|
|
*/ |
|
37
|
|
|
public function created_at_datetimepicker() |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->wrappedObject->created_at->setTimezone($this->setting->get('app_timezone'))->format('d/m/Y H:i'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Returns a formatted timestamp for use within the timeline. |
|
44
|
|
|
* |
|
45
|
|
|
* @return string |
|
46
|
|
|
*/ |
|
47
|
|
|
public function timestamp_formatted() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->created_at_formatted; |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Return the iso timestamp for use within the timeline. |
|
54
|
|
|
* |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
|
|
public function timestamp_iso() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->created_at_iso; |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Convert the presenter instance to an array. |
|
64
|
|
|
* |
|
65
|
|
|
* @return string[] |
|
66
|
|
|
*/ |
|
67
|
|
|
public function toArray() |
|
68
|
|
|
{ |
|
69
|
|
|
return array_merge($this->wrappedObject->toArray(), [ |
|
70
|
|
|
'created_at' => $this->created_at(), |
|
71
|
|
|
'updated_at' => $this->updated_at(), |
|
72
|
|
|
]); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.