1 | <?php |
||||
2 | namespace Mezon\Application; |
||||
3 | |||||
4 | /** |
||||
5 | * Interface PresenterInterface |
||||
6 | * |
||||
7 | * @package Application |
||||
8 | * @subpackage PresenterInterface |
||||
9 | * @author Dodonov A.A. |
||||
10 | * @version v.1.0 (2020/06/23) |
||||
11 | * @copyright Copyright (c) 2020, aeon.org |
||||
12 | */ |
||||
13 | |||||
14 | // TODO move all methods of the Presenter method after the Controller class will be removed |
||||
15 | |||||
16 | /** |
||||
17 | * Base class for all presenters |
||||
18 | */ |
||||
19 | abstract class AbstractPresenter implements PresenterInterface |
||||
20 | { |
||||
21 | |||||
22 | /** |
||||
23 | * Presenter's name |
||||
24 | * |
||||
25 | * @var string |
||||
26 | */ |
||||
27 | private $presenterName = ''; |
||||
28 | |||||
29 | /** |
||||
30 | * View object |
||||
31 | * |
||||
32 | * @var ViewInterface |
||||
33 | */ |
||||
34 | private $view = null; |
||||
35 | |||||
36 | /** |
||||
37 | * Error code |
||||
38 | * |
||||
39 | * @var integer |
||||
40 | * @deprecated Must be removed after the Controller class will be removed. |
||||
41 | */ |
||||
42 | private $errorCode = 0; |
||||
43 | |||||
44 | /** |
||||
45 | * Error message |
||||
46 | * |
||||
47 | * @var string |
||||
48 | * @deprecated Must be removed after the Controller class will be removed. |
||||
49 | */ |
||||
50 | private $errorMessage = ''; |
||||
51 | |||||
52 | /** |
||||
53 | * Constructor |
||||
54 | * |
||||
55 | * @param ViewInterface $view |
||||
56 | * view object |
||||
57 | */ |
||||
58 | public function __construct(ViewInterface $view) |
||||
59 | { |
||||
60 | $this->view = $view; |
||||
61 | } |
||||
62 | |||||
63 | /** |
||||
64 | * Method returns presenter's name |
||||
65 | * |
||||
66 | * @return string presenter's name |
||||
67 | */ |
||||
68 | public function getPresenterName(): string |
||||
69 | { |
||||
70 | return $this->presenterName; |
||||
71 | } |
||||
72 | |||||
73 | /** |
||||
74 | * Method returns presenter's name |
||||
75 | * |
||||
76 | * @return string presenter's name |
||||
77 | */ |
||||
78 | public function setPresenterName(string $presenterName): void |
||||
79 | { |
||||
80 | $this->presenterName = $presenterName; |
||||
81 | } |
||||
82 | |||||
83 | /** |
||||
84 | * Method returns code of the last error |
||||
85 | * |
||||
86 | * @return int code of the last error |
||||
87 | * @codeCoverageIgnore |
||||
88 | */ |
||||
89 | public function getErrorCode(): int |
||||
90 | { |
||||
91 | return $this->view === null ? $this->errorCode : $this->view->getErrorCode(); |
||||
0 ignored issues
–
show
|
|||||
92 | } |
||||
93 | |||||
94 | /** |
||||
95 | * Method sets code of the last error |
||||
96 | * |
||||
97 | * @param int $code |
||||
98 | * code of the last error |
||||
99 | * @codeCoverageIgnore |
||||
100 | */ |
||||
101 | public function setErrorCode(int $errorCode): void |
||||
102 | { |
||||
103 | if ($this->view === null) { |
||||
104 | $this->errorCode = $errorCode; |
||||
0 ignored issues
–
show
The property
Mezon\Application\AbstractPresenter::$errorCode has been deprecated: Must be removed after the Controller class will be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||||
105 | } else { |
||||
106 | $this->view->setErrorCode($errorCode); |
||||
107 | } |
||||
108 | } |
||||
109 | |||||
110 | /** |
||||
111 | * Method return last error description |
||||
112 | * |
||||
113 | * @return string last error description |
||||
114 | * @codeCoverageIgnore |
||||
115 | */ |
||||
116 | public function getErrorMessage(): string |
||||
117 | { |
||||
118 | return $this->view === null ? $this->errorMessage : $this->view->getErrorMessage(); |
||||
0 ignored issues
–
show
The property
Mezon\Application\AbstractPresenter::$errorMessage has been deprecated: Must be removed after the Controller class will be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||||
119 | } |
||||
120 | |||||
121 | /** |
||||
122 | * Method sets last error description |
||||
123 | * |
||||
124 | * @param |
||||
125 | * string last error description |
||||
126 | * @codeCoverageIgnore |
||||
127 | */ |
||||
128 | public function setErrorMessage(string $errorMessage): void |
||||
129 | { |
||||
130 | if ($this->view === null) { |
||||
131 | $this->errorMessage = $errorMessage; |
||||
0 ignored issues
–
show
The property
Mezon\Application\AbstractPresenter::$errorMessage has been deprecated: Must be removed after the Controller class will be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||||
132 | } else { |
||||
133 | $this->view->setErrorMessage($errorMessage); |
||||
134 | } |
||||
135 | } |
||||
136 | } |
||||
137 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.