@@ -52,46 +52,35 @@ public function redirectConfig(?string $name = null, ?array $config = null): mix
52
52
*/
53
53
protected function _refererRedirectUrl (array |string |null $ default = null ): array |string
54
54
{
55
- $ controller = $ this ->_controller ();
56
-
57
- return $ this ->_redirectUrl ($ controller ->referer ($ default , true ));
55
+ return $ this ->_redirectUrl ($ this ->_controller ()->referer ($ default , true ));
58
56
}
59
57
60
58
/**
61
59
* Returns the _redirect_url for this request.
62
60
*
63
- * @param array|string|null $default Default URL to use if _redirect_url if not found in request or data.
61
+ * @param array|string $default Default URL to use if _redirect_url if not found in request or data.
64
62
* @return array|string
65
63
*/
66
- protected function _redirectUrl (array |string | null $ default = null ): array |string
64
+ protected function _redirectUrl (array |string $ default ): array |string
67
65
{
68
66
$ request = $ this ->_request ();
69
67
70
- if (!empty ($ request ->getData ('_redirect_url ' ))) {
71
- return $ request ->getData ('_redirect_url ' );
72
- }
73
- if (!empty ($ request ->getQuery ('_redirect_url ' ))) {
74
- return $ request ->getQuery ('_redirect_url ' );
75
- }
76
- if (!empty ($ request ->getData ('redirect_url ' ))) {
77
- return $ request ->getData ('redirect_url ' );
78
- }
79
- if (!empty ($ request ->getQuery ('redirect_url ' ))) {
80
- return $ request ->getQuery ('redirect_url ' );
81
- }
82
-
83
- return $ default ;
68
+ return $ request ->getData ('_redirect_url ' )
69
+ ?? $ request ->getQuery ('_redirect_url ' )
70
+ ?? $ request ->getData ('redirect_url ' )
71
+ ?? $ request ->getQuery ('redirect_url ' )
72
+ ?? $ default ;
84
73
}
85
74
86
75
/**
87
76
* Called for all redirects inside CRUD
88
77
*
89
78
* @param \Crud\Event\Subject $subject Event subject
90
- * @param array|string|null $url URL
79
+ * @param array|string $url URL
91
80
* @param int $status Status code
92
81
* @return \Cake\Http\Response|null
93
82
*/
94
- protected function _redirect (Subject $ subject , string |array | null $ url = null , int $ status = 302 ): ?Response
83
+ protected function _redirect (Subject $ subject , string |array $ url , int $ status = 302 ): ?Response
95
84
{
96
85
$ url = $ this ->_redirectUrl ($ url );
97
86
0 commit comments