Skip to content

Commit ca24154

Browse files
update
1 parent 8ea700c commit ca24154

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

src/Validator.php

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -123,43 +123,32 @@ public function validate($closure = null)
123123

124124
/**
125125
* Form save response
126-
*
126+
*
127127
* @param Closure $function
128128
* @return mixed
129129
*/
130130
public function save($closure)
131131
{
132-
// if validation already failed, send stored JsonResponse now
132+
// if validation already failed, return stored JsonResponse
133133
if ($this->jsonResponse instanceof \Symfony\Component\HttpFoundation\JsonResponse) {
134-
// Send headers/body only once and return response for frameworks/tests
135-
if (!$this->responseSent) {
136-
$this->jsonResponse->send();
137-
$this->responseSent = true;
138-
}
139134
return $this->jsonResponse;
140135
}
141136

142137
if($this->isValidated()){
143-
138+
144139
// save into a remembering variable
145140
ValidatorMethod::resolveFlash($this);
146-
141+
147142
$response = $this->callback($closure);
148143

149-
// If user returns a JsonResponse in save, send and return it
144+
// If user returns a JsonResponse in save, return it
150145
if ($response instanceof \Symfony\Component\HttpFoundation\JsonResponse) {
151-
if (!$this->responseSent) {
152-
$response->send();
153-
$this->responseSent = true;
154-
}
155-
// return $response;
156-
157-
var_dump(
158-
'sent method'
159-
);
160-
exit();
146+
// delete csrf session token
147+
CsrfToken::unsetToken();
148+
149+
return $response;
161150
}
162-
151+
163152
// delete csrf session token
164153
CsrfToken::unsetToken();
165154
}

tests/server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// return $response->json(1, $response->message);
2020

2121
var_dump(
22-
$response->message,
22+
$response,
2323
'sss'
2424
);
2525
exit();

0 commit comments

Comments
 (0)