1 | <?php |
||
19 | class UserProvider extends \yii\db\ActiveRecord |
||
20 | { |
||
21 | const TYPE_TWITTER = 1; |
||
22 | const TYPE_FACEBOOK = 2; |
||
23 | const TYPE_VKONTAKTE = 3; |
||
24 | |||
25 | /** |
||
26 | * @inheritdoc |
||
27 | */ |
||
28 | 33 | public static function tableName() |
|
32 | |||
33 | /** |
||
34 | * @inheritdoc |
||
35 | */ |
||
36 | public function rules() |
||
37 | { |
||
38 | return [ |
||
39 | [ |
||
40 | ['type', 'profile_id', 'profile_url', 'access_token', 'access_token_secret'], 'safe' |
||
41 | ], |
||
42 | ]; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return \yii\db\ActiveQuery |
||
47 | */ |
||
48 | public function getUser() |
||
49 | { |
||
50 | return $this->hasOne(User::className(), ['id' => 'user_id']); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get types |
||
55 | * |
||
56 | * @return array |
||
57 | */ |
||
58 | 11 | public static function getTypes() |
|
66 | |||
67 | /** |
||
68 | * Get type by id |
||
69 | * |
||
70 | * @return string $name |
||
71 | * @return int |
||
72 | */ |
||
73 | 9 | public static function getTypeByName($name) |
|
78 | |||
79 | /** |
||
80 | * Get type name |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | 1 | public function getTypeName() |
|
89 | |||
90 | /** |
||
91 | * Finds by type of provider |
||
92 | * |
||
93 | * @param int $type |
||
94 | * @param int $profileId |
||
95 | * @return app\models\UserProvider|null |
||
96 | */ |
||
97 | 8 | public static function findByProvider($type, $profileId) |
|
101 | } |
||
102 |