@@ -164,10 +164,9 @@ public function resetPassword( $params )
164
164
* @param array $options
165
165
* @param \Closure $beforeSave
166
166
* @param \Closure $afterSave
167
- * @param bool $force Forces saving invalid data. Defaults to false; when true has the same effect as calling
168
167
* @return bool
169
168
*/
170
- public function save ( array $ rules = array (), array $ customMessages = array (), array $ options = array (), \Closure $ beforeSave = null , \Closure $ afterSave = null , $ force = false )
169
+ public function save ( array $ rules = array (), array $ customMessages = array (), array $ options = array (), \Closure $ beforeSave = null , \Closure $ afterSave = null )
171
170
{
172
171
$ duplicated = false ;
173
172
@@ -178,7 +177,7 @@ public function save( array $rules = array(), array $customMessages = array(), a
178
177
179
178
if (! $ duplicated )
180
179
{
181
- return $ this ->real_save ( $ rules , $ customMessages , $ options , $ beforeSave , $ afterSave, $ force );
180
+ return $ this ->real_save ( $ rules , $ customMessages , $ options , $ beforeSave , $ afterSave );
182
181
}
183
182
else
184
183
{
@@ -196,23 +195,22 @@ public function save( array $rules = array(), array $customMessages = array(), a
196
195
* Before save the user. Generate a confirmation
197
196
* code if is a new user.
198
197
*
199
- * @param User $user
200
198
* @return bool
201
199
*/
202
- public static function beforeSave ( $ user )
200
+ public function beforeSave ()
203
201
{
204
- if ( empty ($ user ->id ) )
202
+ if ( empty ($ this ->id ) )
205
203
{
206
- $ user ->confirmation_code = md5 ( uniqid (mt_rand (), true ) );
204
+ $ this ->confirmation_code = md5 ( uniqid (mt_rand (), true ) );
207
205
}
208
206
209
207
/*
210
208
* Remove password_confirmation field before save to
211
209
* database.
212
210
*/
213
- if ( isset ($ user ->password_confirmation ) )
211
+ if ( isset ($ this ->password_confirmation ) )
214
212
{
215
- unset( $ user ->password_confirmation );
213
+ unset( $ this ->password_confirmation );
216
214
}
217
215
218
216
return true ;
@@ -223,23 +221,21 @@ public static function beforeSave( $user )
223
221
* After save, delivers the confirmation link email.
224
222
* code if is a new user.
225
223
*
226
- * @param User $user
227
- * @param string event status
228
224
* @return bool
229
225
*/
230
- public static function afterSave ( $ user , $ status = '' )
226
+ public function afterSave ()
231
227
{
232
- if (! $ user ->confirmed && ! static ::$ app ['cache ' ]->get ('confirmation_email_ ' .$ user ->id ) )
228
+ if (! $ this ->confirmed && ! static ::$ app ['cache ' ]->get ('confirmation_email_ ' .$ this ->id ) )
233
229
{
234
230
$ view = static ::$ app ['config ' ]->get ('confide::email_account_confirmation ' );
235
231
236
- $ user ->sendEmail ( 'confide::confide.email.account_confirmation.subject ' , $ view , array ('user ' => $ user ) );
232
+ $ this ->sendEmail ( 'confide::confide.email.account_confirmation.subject ' , $ view , array ('user ' => $ this ) );
237
233
238
234
// Save in cache that the email has been sent.
239
235
$ signup_cache = (int )static ::$ app ['config ' ]->get ('confide::signup_cache ' );
240
236
if ($ signup_cache !== 0 )
241
237
{
242
- static ::$ app ['cache ' ]->put ('confirmation_email_ ' .$ user ->id , true , $ signup_cache );
238
+ static ::$ app ['cache ' ]->put ('confirmation_email_ ' .$ this ->id , true , $ signup_cache );
243
239
}
244
240
}
245
241
@@ -257,15 +253,14 @@ public static function afterSave( $user, $status = '' )
257
253
* @param array $options
258
254
* @param \Closure $beforeSave
259
255
* @param \Closure $afterSave
260
- * @param bool $force Forces saving invalid data. Defaults to false; when true has the same effect as calling
261
256
* @return bool
262
257
*/
263
- protected function real_save ( array $ rules = array (), array $ customMessages = array (), array $ options = array (), \Closure $ beforeSave = null , \Closure $ afterSave = null , $ force = false )
258
+ protected function real_save ( array $ rules = array (), array $ customMessages = array (), array $ options = array (), \Closure $ beforeSave = null , \Closure $ afterSave = null )
264
259
{
265
260
if ( defined ('CONFIDE_TEST ' ) )
266
261
{
267
- self :: beforeSave ( $ this );
268
- self :: afterSave ( $ this );
262
+ $ this -> beforeSave ( );
263
+ $ this -> afterSave ( );
269
264
return true ;
270
265
}
271
266
else {
@@ -280,7 +275,7 @@ protected function real_save( array $rules = array(), array $customMessages = ar
280
275
$ rules ['password ' ] = 'required ' ;
281
276
}
282
277
283
- return parent ::save ( $ rules , $ customMessages , $ options , $ beforeSave , $ afterSave, $ force );
278
+ return parent ::save ( $ rules , $ customMessages , $ options , $ beforeSave , $ afterSave );
284
279
}
285
280
}
286
281
@@ -291,15 +286,14 @@ protected function real_save( array $rules = array(), array $customMessages = ar
291
286
* @param array $options
292
287
* @param Closure $beforeSave
293
288
* @param Closure $afterSave
294
- * @param bool $force Forces saving invalid data. Defaults to false; when true has the same effect as calling
295
289
* @return bool
296
290
*/
297
- public function amend ( array $ rules = array (), array $ customMessages = array (), array $ options = array (), \Closure $ beforeSave = null , \Closure $ afterSave = null , $ force = false )
291
+ public function amend ( array $ rules = array (), array $ customMessages = array (), array $ options = array (), \Closure $ beforeSave = null , \Closure $ afterSave = null )
298
292
{
299
293
if (empty ($ rules )) {
300
294
$ rules = $ this ->getUpdateRules ();
301
295
}
302
- return $ this ->save ( $ rules , $ customMessages , $ options , $ beforeSave , $ afterSave, $ force );
296
+ return $ this ->save ( $ rules , $ customMessages , $ options , $ beforeSave , $ afterSave );
303
297
}
304
298
305
299
/**
@@ -335,7 +329,7 @@ protected function sendEmail( $subject_translation, $view_name, $params = array(
335
329
static ::$ app ['mailer ' ]->send ($ view_name , $ params , function ($ m ) use ($ subject_translation , $ user )
336
330
{
337
331
$ m ->to ( $ user ->email )
338
- ->subject ( ConfideUser::$ app ['translator ' ]->get ($ subject_translation ) );
332
+ ->subject ( ConfideUser::$ app ['translator ' ]->get ($ subject_translation ) );
339
333
});
340
334
}
341
335
0 commit comments