|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
|
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
|
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
|
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
|
8
|
|
|
* @link http://vistart.name/ |
|
9
|
|
|
* @copyright Copyright (c) 2016 vistart |
|
10
|
|
|
* @license http://vistart.name/license/ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace vistart\Models\models; |
|
14
|
|
|
|
|
15
|
|
|
use vistart\Models\traits\AdditionalAccountTrait; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* This abstract class helps you build additional account class. |
|
19
|
|
|
* |
|
20
|
|
|
* Default settings: |
|
21
|
|
|
* - enable GUID. |
|
22
|
|
|
* - enable ID, random string, with 8 characters. |
|
23
|
|
|
* - enable IP, accept all IP address. |
|
24
|
|
|
* - enable createdAtAttribute. |
|
25
|
|
|
* - enable content, and its rule is integer. |
|
26
|
|
|
* - enable confirmation, but confirm code. |
|
27
|
|
|
* - enable description. |
|
28
|
|
|
* the content attribute is used for recording the login-type of account, e.g. ID |
|
29
|
|
|
* , email or any other format. |
|
30
|
|
|
* the content type attribute is used for recording the account source, e.g. register |
|
31
|
|
|
* from self, or any other account provider. |
|
32
|
|
|
* @version 2.0 |
|
33
|
|
|
* @author vistart <[email protected]> |
|
34
|
|
|
*/ |
|
35
|
|
|
abstract class BaseAdditionalAccountModel extends BaseBlameableModel |
|
36
|
|
|
{ |
|
37
|
|
|
use AdditionalAccountTrait; |
|
38
|
|
|
|
|
39
|
|
|
public $idAttributeLength = 8; |
|
40
|
|
|
public $updatedByAttribute = false; |
|
41
|
|
|
public $contentAttribute = 'content'; // Account type, types defined by yourself. |
|
42
|
|
|
public $contentAttributeRule = ['integer', 'min' => 0]; |
|
43
|
|
|
public $contentTypeAttribute = 'source'; // Where did this account origin from, defined by yourself. |
|
44
|
|
|
public $contentTypes = [ |
|
45
|
|
|
0 => 'self', |
|
46
|
|
|
1 => 'third-party', |
|
47
|
|
|
]; |
|
48
|
|
|
public $confirmationAttribute = 'confirmed'; |
|
49
|
|
|
public $confirmCodeAttribute = false; |
|
50
|
|
|
public $descriptionAttribute = 'description'; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @inheritdoc |
|
54
|
|
|
*/ |
|
55
|
6 |
|
public function init() |
|
56
|
|
|
{ |
|
57
|
6 |
|
if (!is_string($this->queryClass)) { |
|
58
|
6 |
|
$this->queryClass = \vistart\Models\queries\BaseBlameableQuery::className(); |
|
59
|
6 |
|
} |
|
60
|
6 |
|
if ($this->skipInit) { |
|
61
|
6 |
|
return; |
|
62
|
|
|
} |
|
63
|
6 |
|
parent::init(); |
|
64
|
6 |
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @inheritdoc |
|
68
|
|
|
*/ |
|
69
|
6 |
|
public function rules() |
|
70
|
|
|
{ |
|
71
|
6 |
|
return array_merge($this->getAdditionalAccountRules(), parent::rules()); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|