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 IssuePresenter 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->description); |
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
|
|
|
* Present the status with an icon. |
64
|
|
|
* |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function icon() |
68
|
|
|
{ |
69
|
|
|
switch ($this->wrappedObject->state) { |
70
|
|
|
case 0: // Scheduled |
71
|
|
|
return 'fa fa-calendar'; |
72
|
|
|
case 1: // Investigating |
73
|
|
|
return 'fa fa-flag oranges'; |
74
|
|
|
case 2: // Identified |
75
|
|
|
return 'fa fa-warning yellows'; |
76
|
|
|
case 3: // Watching |
77
|
|
|
return 'fa fa-eye blues'; |
78
|
|
|
case 4: // Fixed |
79
|
|
|
return 'fa fa-wrench greens'; |
80
|
|
|
default: // Something actually broke, this shouldn't happen. |
81
|
|
|
return ''; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Convert the presenter instance to an array. |
87
|
|
|
* |
88
|
|
|
* @return string[] |
89
|
|
|
*/ |
90
|
|
|
public function toArray() |
91
|
|
|
{ |
92
|
|
|
return array_merge($this->wrappedObject->toArray(), [ |
93
|
|
|
'created_at' => $this->created_at(), |
94
|
|
|
'updated_at' => $this->updated_at(), |
95
|
|
|
]); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
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@property
annotation 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.