|
- <?php
-
- namespace common\services;
-
- use common\models\User;
-
- class UserService
- {
- public function createInstance()
- {
- $user = new User();
-
- return $user;
- }
-
- public function initPassword($user, $password)
- {
- $user->setPassword($this->password);
- $user->generateAuthKey();
- }
-
- public function initProducer($user, $producer)
- {
- $user->id_producer = $producer->id;
- $user->status = User::STATUS_PRODUCER;
- }
-
- public function sendEmailSignup($user, $producer)
- {
- Yii::$app->mailer->compose(
- [
- 'html' => 'signup-html',
- 'text' => 'signup-text'
- ],
- [
- 'user' => $user,
- 'producer' => $producer
- ])
- ->setTo($user->email)
- ->setFrom([Yii::$app->params['adminEmail'] => 'distrib'])
- ->setSubject('[Opendistrib] Inscription')
- ->send();
- }
- }
|