1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ZfcUser\Options; |
4
|
|
|
|
5
|
|
|
use Zend\Stdlib\AbstractOptions; |
6
|
|
|
|
7
|
|
|
class ModuleOptions extends AbstractOptions implements |
8
|
|
|
UserControllerOptionsInterface, |
9
|
|
|
UserServiceOptionsInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Turn off strict options mode |
13
|
|
|
*/ |
14
|
|
|
protected $__strictMode__ = false; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var bool |
18
|
|
|
*/ |
19
|
|
|
protected $useRedirectParameterIfPresent = true; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $loginRedirectRoute = 'zfcuser'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $logoutRedirectRoute = 'zfcuser/login'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var int |
33
|
|
|
*/ |
34
|
|
|
protected $loginFormTimeout = 300; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var int |
38
|
|
|
*/ |
39
|
|
|
protected $userFormTimeout = 300; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var bool |
43
|
|
|
*/ |
44
|
|
|
protected $loginAfterRegistration = true; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var int |
48
|
|
|
*/ |
49
|
|
|
protected $enableUserState = false; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var int |
53
|
|
|
*/ |
54
|
|
|
protected $defaultUserState = 1; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var Array |
58
|
|
|
*/ |
59
|
|
|
protected $allowedLoginStates = array( null, 1 ); |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var array |
63
|
|
|
*/ |
64
|
|
|
protected $authAdapters = array( 100 => 'ZfcUser\Authentication\Adapter\Db' ); |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var array |
68
|
|
|
*/ |
69
|
|
|
protected $authIdentityFields = array( 'email' ); |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var string |
73
|
|
|
*/ |
74
|
|
|
protected $userEntityClass = 'ZfcUser\Entity\User'; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var string |
78
|
|
|
*/ |
79
|
|
|
protected $userLoginWidgetViewTemplate = 'zfc-user/user/login.phtml'; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var bool |
83
|
|
|
*/ |
84
|
|
|
protected $enableRegistration = true; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var bool |
88
|
|
|
*/ |
89
|
|
|
protected $enableUsername = false; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var bool |
93
|
|
|
*/ |
94
|
|
|
protected $enableDisplayName = false; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @var bool |
98
|
|
|
*/ |
99
|
|
|
protected $useRegistrationFormCaptcha = false; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @var bool |
103
|
|
|
*/ |
104
|
|
|
protected $useLoginFormCaptcha = false; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @var int |
108
|
|
|
*/ |
109
|
|
|
protected $passwordCost = 14; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @var string |
113
|
|
|
*/ |
114
|
|
|
|
115
|
|
|
protected $tableName = 'user'; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @var array |
119
|
|
|
*/ |
120
|
|
|
protected $formCaptchaOptions = array( |
121
|
|
|
'class' => 'figlet', |
122
|
|
|
'options' => array( |
123
|
|
|
'wordLen' => 5, |
124
|
|
|
'expiration' => 300, |
125
|
|
|
'timeout' => 300, |
126
|
|
|
), |
127
|
|
|
); |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* set login redirect route |
131
|
|
|
* |
132
|
|
|
* @param string $loginRedirectRoute |
133
|
|
|
* @return ModuleOptions |
134
|
|
|
*/ |
135
|
|
|
public function setLoginRedirectRoute($loginRedirectRoute) |
136
|
|
|
{ |
137
|
|
|
$this->loginRedirectRoute = $loginRedirectRoute; |
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* get login redirect route |
143
|
|
|
* |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
public function getLoginRedirectRoute() |
147
|
|
|
{ |
148
|
|
|
return $this->loginRedirectRoute; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* set logout redirect route |
153
|
|
|
* |
154
|
|
|
* @param string $logoutRedirectRoute |
155
|
|
|
* @return ModuleOptions |
156
|
|
|
*/ |
157
|
|
|
public function setLogoutRedirectRoute($logoutRedirectRoute) |
158
|
|
|
{ |
159
|
|
|
$this->logoutRedirectRoute = $logoutRedirectRoute; |
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* get logout redirect route |
165
|
|
|
* |
166
|
|
|
* @return string |
167
|
|
|
*/ |
168
|
|
|
public function getLogoutRedirectRoute() |
169
|
|
|
{ |
170
|
|
|
return $this->logoutRedirectRoute; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* set use redirect param if present |
175
|
|
|
* |
176
|
|
|
* @param bool $useRedirectParameterIfPresent |
177
|
|
|
* @return ModuleOptions |
178
|
|
|
*/ |
179
|
|
|
public function setUseRedirectParameterIfPresent($useRedirectParameterIfPresent) |
180
|
|
|
{ |
181
|
|
|
$this->useRedirectParameterIfPresent = $useRedirectParameterIfPresent; |
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* get use redirect param if present |
187
|
|
|
* |
188
|
|
|
* @return bool |
189
|
|
|
*/ |
190
|
|
|
public function getUseRedirectParameterIfPresent() |
191
|
|
|
{ |
192
|
|
|
return $this->useRedirectParameterIfPresent; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* set the view template for the user login widget |
197
|
|
|
* |
198
|
|
|
* @param string $userLoginWidgetViewTemplate |
199
|
|
|
* @return ModuleOptions |
200
|
|
|
*/ |
201
|
|
|
public function setUserLoginWidgetViewTemplate($userLoginWidgetViewTemplate) |
202
|
|
|
{ |
203
|
|
|
$this->userLoginWidgetViewTemplate = $userLoginWidgetViewTemplate; |
204
|
|
|
return $this; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* get the view template for the user login widget |
209
|
|
|
* |
210
|
|
|
* @return string |
211
|
|
|
*/ |
212
|
|
|
public function getUserLoginWidgetViewTemplate() |
213
|
|
|
{ |
214
|
|
|
return $this->userLoginWidgetViewTemplate; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* set enable user registration |
219
|
|
|
* |
220
|
|
|
* @param bool $enableRegistration |
221
|
|
|
* @return ModuleOptions |
222
|
|
|
*/ |
223
|
|
|
public function setEnableRegistration($enableRegistration) |
224
|
|
|
{ |
225
|
|
|
$this->enableRegistration = $enableRegistration; |
226
|
|
|
return $this; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* get enable user registration |
231
|
|
|
* |
232
|
|
|
* @return bool |
233
|
|
|
*/ |
234
|
|
|
public function getEnableRegistration() |
235
|
|
|
{ |
236
|
|
|
return $this->enableRegistration; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* set login form timeout |
241
|
|
|
* |
242
|
|
|
* @param int $loginFormTimeout |
243
|
|
|
* @return ModuleOptions |
244
|
|
|
*/ |
245
|
|
|
public function setLoginFormTimeout($loginFormTimeout) |
246
|
|
|
{ |
247
|
|
|
$this->loginFormTimeout = $loginFormTimeout; |
248
|
|
|
return $this; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* get login form timeout in seconds |
253
|
|
|
* |
254
|
|
|
* @return int |
255
|
|
|
*/ |
256
|
|
|
public function getLoginFormTimeout() |
257
|
|
|
{ |
258
|
|
|
return $this->loginFormTimeout; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* set user form timeout in seconds |
263
|
|
|
* |
264
|
|
|
* @param int $userFormTimeout |
265
|
|
|
* @return ModuleOptions |
266
|
|
|
*/ |
267
|
|
|
public function setUserFormTimeout($userFormTimeout) |
268
|
|
|
{ |
269
|
|
|
$this->userFormTimeout = $userFormTimeout; |
270
|
|
|
return $this; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* get user form timeout in seconds |
275
|
|
|
* |
276
|
|
|
* @return int |
277
|
|
|
*/ |
278
|
|
|
public function getUserFormTimeout() |
279
|
|
|
{ |
280
|
|
|
return $this->userFormTimeout; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* set login after registration |
285
|
|
|
* |
286
|
|
|
* @param bool $loginAfterRegistration |
287
|
|
|
* @return ModuleOptions |
288
|
|
|
*/ |
289
|
|
|
public function setLoginAfterRegistration($loginAfterRegistration) |
290
|
|
|
{ |
291
|
|
|
$this->loginAfterRegistration = $loginAfterRegistration; |
292
|
|
|
return $this; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* get login after registration |
297
|
|
|
* |
298
|
|
|
* @return bool |
299
|
|
|
*/ |
300
|
|
|
public function getLoginAfterRegistration() |
301
|
|
|
{ |
302
|
|
|
return $this->loginAfterRegistration; |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* get user state usage for registration/login process |
307
|
|
|
* |
308
|
|
|
* @return int |
309
|
|
|
*/ |
310
|
|
|
public function getEnableUserState() |
311
|
|
|
{ |
312
|
|
|
return $this->enableUserState; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* set user state usage for registration/login process |
317
|
|
|
* |
318
|
|
|
* @param boolean $flag |
319
|
|
|
* @return ModuleOptions |
320
|
|
|
*/ |
321
|
|
|
public function setEnableUserState($flag) |
322
|
|
|
{ |
323
|
|
|
$this->enableUserState = $flag; |
324
|
|
|
return $this; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* get default user state on registration |
329
|
|
|
* |
330
|
|
|
* @return int |
331
|
|
|
*/ |
332
|
|
|
public function getDefaultUserState() |
333
|
|
|
{ |
334
|
|
|
return $this->defaultUserState; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* set default user state on registration |
339
|
|
|
* |
340
|
|
|
* @param int $state |
341
|
|
|
* @return ModuleOptions |
342
|
|
|
*/ |
343
|
|
|
public function setDefaultUserState($state) |
344
|
|
|
{ |
345
|
|
|
$this->defaultUserState = $state; |
346
|
|
|
return $this; |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* get list of states to allow user login |
351
|
|
|
* |
352
|
|
|
* @return array |
353
|
|
|
*/ |
354
|
|
|
public function getAllowedLoginStates() |
355
|
|
|
{ |
356
|
|
|
return $this->allowedLoginStates; |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* set list of states to allow user login |
361
|
|
|
* |
362
|
|
|
* @param Array $states |
363
|
|
|
* @return ModuleOptions |
364
|
|
|
*/ |
365
|
|
|
public function setAllowedLoginStates(array $states) |
366
|
|
|
{ |
367
|
|
|
$this->allowedLoginStates = $states; |
368
|
|
|
return $this; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* set auth adapters |
373
|
|
|
* |
374
|
|
|
* @param array $authAdapterss |
375
|
|
|
* @return ModuleOptions |
376
|
|
|
*/ |
377
|
|
|
public function setAuthAdapters($authAdapters) |
378
|
|
|
{ |
379
|
|
|
$this->authAdapters = $authAdapters; |
380
|
|
|
return $this; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* get auth adapters |
385
|
|
|
* |
386
|
|
|
* @return array |
387
|
|
|
*/ |
388
|
|
|
public function getAuthAdapters() |
389
|
|
|
{ |
390
|
|
|
return $this->authAdapters; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
/** |
394
|
|
|
* set auth identity fields |
395
|
|
|
* |
396
|
|
|
* @param array $authIdentityFields |
397
|
|
|
* @return ModuleOptions |
398
|
|
|
*/ |
399
|
|
|
public function setAuthIdentityFields($authIdentityFields) |
400
|
|
|
{ |
401
|
|
|
$this->authIdentityFields = $authIdentityFields; |
402
|
|
|
return $this; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* get auth identity fields |
407
|
|
|
* |
408
|
|
|
* @return array |
409
|
|
|
*/ |
410
|
|
|
public function getAuthIdentityFields() |
411
|
|
|
{ |
412
|
|
|
return $this->authIdentityFields; |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
/** |
416
|
|
|
* set enable username |
417
|
|
|
* |
418
|
|
|
* @param bool $flag |
419
|
|
|
* @return ModuleOptions |
420
|
|
|
*/ |
421
|
|
|
public function setEnableUsername($flag) |
422
|
|
|
{ |
423
|
|
|
$this->enableUsername = (bool) $flag; |
424
|
|
|
return $this; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* get enable username |
429
|
|
|
* |
430
|
|
|
* @return bool |
431
|
|
|
*/ |
432
|
|
|
public function getEnableUsername() |
433
|
|
|
{ |
434
|
|
|
return $this->enableUsername; |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* set enable display name |
439
|
|
|
* |
440
|
|
|
* @param bool $flag |
441
|
|
|
* @return ModuleOptions |
442
|
|
|
*/ |
443
|
|
|
public function setEnableDisplayName($flag) |
444
|
|
|
{ |
445
|
|
|
$this->enableDisplayName = (bool) $flag; |
446
|
|
|
return $this; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* get enable display name |
451
|
|
|
* |
452
|
|
|
* @return bool |
453
|
|
|
*/ |
454
|
|
|
public function getEnableDisplayName() |
455
|
|
|
{ |
456
|
|
|
return $this->enableDisplayName; |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* set use a captcha in registration form |
461
|
|
|
* |
462
|
|
|
* @param bool $useRegistrationFormCaptcha |
463
|
|
|
* @return ModuleOptions |
464
|
|
|
*/ |
465
|
|
|
public function setUseRegistrationFormCaptcha($useRegistrationFormCaptcha) |
466
|
|
|
{ |
467
|
|
|
$this->useRegistrationFormCaptcha = $useRegistrationFormCaptcha; |
468
|
|
|
return $this; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* get use a captcha in registration form |
473
|
|
|
* |
474
|
|
|
* @return bool |
475
|
|
|
*/ |
476
|
|
|
public function getUseRegistrationFormCaptcha() |
477
|
|
|
{ |
478
|
|
|
return $this->useRegistrationFormCaptcha; |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* set use a captcha in login form |
483
|
|
|
* |
484
|
|
|
* @param bool $useRegistrationFormCaptcha |
|
|
|
|
485
|
|
|
* @return ModuleOptions |
486
|
|
|
*/ |
487
|
|
|
public function setUseLoginFormCaptcha($useLoginFormCaptcha) |
488
|
|
|
{ |
489
|
|
|
$this->useLoginFormCaptcha = $useLoginFormCaptcha; |
490
|
|
|
return $this; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* get use a captcha in login form |
495
|
|
|
* |
496
|
|
|
* @return bool |
497
|
|
|
*/ |
498
|
|
|
public function getUseLoginFormCaptcha() |
499
|
|
|
{ |
500
|
|
|
return $this->useLoginFormCaptcha; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* set user entity class name |
505
|
|
|
* |
506
|
|
|
* @param string $userEntityClass |
507
|
|
|
* @return ModuleOptions |
508
|
|
|
*/ |
509
|
|
|
public function setUserEntityClass($userEntityClass) |
510
|
|
|
{ |
511
|
|
|
$this->userEntityClass = $userEntityClass; |
512
|
|
|
return $this; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* get user entity class name |
517
|
|
|
* |
518
|
|
|
* @return string |
519
|
|
|
*/ |
520
|
|
|
public function getUserEntityClass() |
521
|
|
|
{ |
522
|
|
|
return $this->userEntityClass; |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* set password cost |
527
|
|
|
* |
528
|
|
|
* @param int $passwordCost |
529
|
|
|
* @return ModuleOptions |
530
|
|
|
*/ |
531
|
|
|
public function setPasswordCost($passwordCost) |
532
|
|
|
{ |
533
|
|
|
$this->passwordCost = $passwordCost; |
534
|
|
|
return $this; |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
/** |
538
|
|
|
* get password cost |
539
|
|
|
* |
540
|
|
|
* @return int |
541
|
|
|
*/ |
542
|
|
|
public function getPasswordCost() |
543
|
|
|
{ |
544
|
|
|
return $this->passwordCost; |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
/** |
548
|
|
|
* set user table name |
549
|
|
|
* |
550
|
|
|
* @param string $tableName |
551
|
|
|
*/ |
552
|
|
|
public function setTableName($tableName) |
553
|
|
|
{ |
554
|
|
|
$this->tableName=$tableName; |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
/** |
558
|
|
|
* get user table name |
559
|
|
|
* |
560
|
|
|
* @return string |
561
|
|
|
*/ |
562
|
|
|
public function getTableName() |
563
|
|
|
{ |
564
|
|
|
return $this->tableName; |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
/** |
568
|
|
|
* set form CAPTCHA options |
569
|
|
|
* |
570
|
|
|
* @param array $formCaptchaOptions |
571
|
|
|
* @return ModuleOptions |
572
|
|
|
*/ |
573
|
|
|
public function setFormCaptchaOptions($formCaptchaOptions) |
574
|
|
|
{ |
575
|
|
|
$this->formCaptchaOptions = $formCaptchaOptions; |
576
|
|
|
return $this; |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
/** |
580
|
|
|
* get form CAPTCHA options |
581
|
|
|
* |
582
|
|
|
* @return array |
583
|
|
|
*/ |
584
|
|
|
public function getFormCaptchaOptions() |
585
|
|
|
{ |
586
|
|
|
return $this->formCaptchaOptions; |
587
|
|
|
} |
588
|
|
|
} |
589
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.