1 | <?php |
||
37 | class Profile extends ActiveRecord |
||
38 | { |
||
39 | use ModuleAwareTrait; |
||
40 | use ContainerAwareTrait; |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | 3 | public function beforeSave($insert) |
|
46 | { |
||
47 | 3 | if ($this->isAttributeChanged('gravatar_email')) { |
|
48 | $this->setAttribute( |
||
49 | 'gravatar_id', |
||
50 | $this->make(GravatarHelper::class)->buildId(trim($this->getAttribute('gravatar_email'))) |
||
51 | ); |
||
52 | } |
||
53 | |||
54 | 3 | return parent::beforeSave($insert); |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 4 | public static function tableName() |
|
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | public function rules() |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | public function attributeLabels() |
||
106 | |||
107 | /** |
||
108 | * Get the User's timezone. |
||
109 | * |
||
110 | * @return DateTimeZone |
||
111 | */ |
||
112 | public function getTimeZone() |
||
120 | |||
121 | /** |
||
122 | * Set the User's timezone. |
||
123 | * |
||
124 | * @param DateTimeZone $timezone |
||
125 | */ |
||
126 | public function setTimeZone(DateTimeZone $timezone) |
||
130 | |||
131 | /** |
||
132 | * Get User's local time. |
||
133 | * |
||
134 | * @param DateTime|null $dateTime |
||
135 | * |
||
136 | * @return DateTime |
||
137 | */ |
||
138 | public function getLocalTimeZone(DateTime $dateTime = null) |
||
142 | |||
143 | /** |
||
144 | * @return \yii\db\ActiveQuery |
||
145 | */ |
||
146 | 3 | public function getUser() |
|
147 | { |
||
148 | 3 | return $this->hasOne($this->getClassMap()->get(User::class), ['id' => 'user_id']); |
|
149 | } |
||
150 | |||
151 | /** |
||
152 | * @param int $size |
||
153 | * |
||
154 | * @return mixed |
||
155 | */ |
||
156 | public function getAvatarUrl($size = 200) |
||
157 | { |
||
158 | return $this->make(GravatarHelper::class)->getUrl($this->gravatar_id, $size); |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * @return ProfileQuery |
||
163 | */ |
||
164 | 3 | public static function find() |
|
168 | } |
||
169 |