File tree Expand file tree Collapse file tree 1 file changed +56
-1
lines changed Expand file tree Collapse file tree 1 file changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ class View
12
12
public $ _outBuffer ;
13
13
public $ _layout = 'default ' ;
14
14
15
+ public $ errors = [];
16
+
15
17
public function render ($ viewName , $ data = [])
16
18
{
17
19
extract ($ data );
@@ -71,4 +73,57 @@ public function setLayout($path)
71
73
{
72
74
$ this ->_layout = $ path ;
73
75
}
74
- }
76
+
77
+ /**
78
+ * @method for setErrors
79
+ *
80
+ * @param $errors
81
+ * @return void
82
+ */
83
+ public function setErrors ($ errors )
84
+ {
85
+ $ this ->errors = $ errors ;
86
+ }
87
+
88
+ /**
89
+ * @method for getErrors
90
+ *
91
+ * @return array
92
+ */
93
+ public function errors ()
94
+ {
95
+ return $ this ->errors ;
96
+ }
97
+
98
+ /**
99
+ * @method for hasErrors
100
+ *
101
+ * @return bool
102
+ */
103
+ public function hasErrors ()
104
+ {
105
+ return !empty ($ this ->errors );
106
+ }
107
+
108
+ /**
109
+ * @method for get error by key
110
+ *
111
+ * @param $key
112
+ * @return string
113
+ */
114
+ public function error ($ key )
115
+ {
116
+ return $ this ->errors [$ key ] ?? '' ;
117
+ }
118
+
119
+ /**
120
+ * @method for check error by key
121
+ *
122
+ * @param $key
123
+ * @return bool
124
+ */
125
+ public function hasError ($ key )
126
+ {
127
+ return isset ($ this ->errors [$ key ]);
128
+ }
129
+ }
You can’t perform that action at this time.
0 commit comments