File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ public function showLastEmail($username)
70
70
->where (['email ' => $ username ])
71
71
->order (['created ' => 'DESC ' ]);
72
72
73
- $ emailType = $ this ->request -> getQueryParams ()[ " type " ] ?? null ;
73
+ $ emailType = $ this ->getEmailType () ;
74
74
if (!is_null ($ emailType )) {
75
75
$ emailQuery ->where (['template ' => $ emailType ]);
76
76
}
@@ -91,4 +91,22 @@ public function showLastEmail($username)
91
91
->setTemplate ($ email ->template )
92
92
->setTemplatePath ("email/ $ format " );
93
93
}
94
+
95
+ /**
96
+ * Returns a validated `has-type` filter set in the query parameters of the request if any.
97
+ * @return string|null
98
+ */
99
+ private function getEmailType () {
100
+ $ filter = $ this ->request ->getQuery ('filter ' );
101
+ if (is_null ($ filter )) {
102
+ return null ;
103
+ }
104
+
105
+ $ hasType = $ filter ['has-type ' ];
106
+ if (empty ($ hasType ) || !is_string ($ hasType )) {
107
+ return null ;
108
+ }
109
+
110
+ return $ hasType ;
111
+ }
94
112
}
You can’t perform that action at this time.
0 commit comments