public function send($event)
    {

        if (Yii::$app->user->isGuest) {
            $profile = Yii::$app->request->post('Profile');
            $partnerRequest = Yii::$app->request->post('PartnerRequest');
            $partnerEmail = [Yii::$app->request->post('register-form')['email']];

            $userMailVars = [
                '{name}' => $profile['name'],
                '{surname}' => $profile['surname'],
                '{patronymic}' => $profile['patronymic'],
                '{info}' => $profile['info'],
            ];
        } else {
            $profile = Profile::find()->where(['user_id' => Yii::$app->user->id])->one();
            $partnerRequest = PartnerRequest::find()->where(['sender_id' => Yii::$app->user->id])->one();
            $partnerEmail = [$profile->user->email];

            $userMailVars = [
                '{name}' => $profile->name,
                '{surname}' => $profile->surname,
                '{patronymic}' => $profile->patronymic,
                '{info}' => $profile->info,
            ];
        }

        $mailVars = [
            '{contact_person}' => $partnerRequest['contact_person'],
            '{company_name}' => $partnerRequest['company_name'],
            '{website}' => $partnerRequest['website'],
            '{message}' => $partnerRequest['message'],
            '{link}' => Html::a(\Yii::t('shop', 'Details'), Url::to('admin/shop/partners/view?id=' . $partnerRequest['id'], true))
        ];

        $mailVars = array_merge($userMailVars, $mailVars);

        $mailer = \Yii::createObject(Mailer::className());

        $mailer->sendPartnerRequestToPartner(
            $mailVars,
            [$event->sender->module->senderEmail ??
            \Yii::$app->get('shopMailer')->transport->getUsername() => \Yii::$app->name ?? parse_url(Url::base(true), PHP_URL_HOST)],
            $partnerEmail
        );
        $mailer->sendPartnerRequestToManager(
            $mailVars,
            [$event->sender->module->senderEmail ??
            \Yii::$app->get('shopMailer')->transport->getUsername() => \Yii::$app->name ?? parse_url(Url::base(true), PHP_URL_HOST)],
            $event->sender->module->partnerManagerEmail
        );
    }
public function send($event)
    {

        if (Yii::$app->user->isGuest) {
            $profile = Yii::$app->request->post('Profile');
            $partnerRequest = Yii::$app->request->post('PartnerRequest');
            $partnerEmail = [Yii::$app->request->post('register-form')['email']];

            $userMailVars = [
                '{name}' => $profile['name'],
                '{surname}' => $profile['surname'],
                '{patronymic}' => $profile['patronymic'],
                '{info}' => $profile['info'],
            ];
        } else {
            $profile = Profile::find()->where(['user_id' => Yii::$app->user->id])->one();
            $partnerRequest = PartnerRequest::find()->where(['sender_id' => Yii::$app->user->id])->one();
            $partnerEmail = [$profile->user->email];

            $userMailVars = [
                '{name}' => $profile->name,
                '{surname}' => $profile->surname,
                '{patronymic}' => $profile->patronymic,
                '{info}' => $profile->info,
            ];
        }

        $mailVars = [
            '{contact_person}' => $partnerRequest['contact_person'],
            '{company_name}' => $partnerRequest['company_name'],
            '{website}' => $partnerRequest['website'],
            '{message}' => $partnerRequest['message'],
            '{link}' => Html::a(\Yii::t('shop', 'Details'), Url::to('admin/shop/partners/view?id=' . $partnerRequest['id'], true))
        ];

        $mailVars = array_merge($userMailVars, $mailVars);

        $mailer = \Yii::createObject(Mailer::className());

        $mailer->sendPartnerRequestToPartner(
            $mailVars,
            [$event->sender->module->senderEmail ??
            \Yii::$app->get('shopMailer')->transport->getUsername() => \Yii::$app->name ?? parse_url(Url::base(true), PHP_URL_HOST)],
            $partnerEmail
        );
        $mailer->sendPartnerRequestToManager(
            $mailVars,
            [$event->sender->module->senderEmail ??
            \Yii::$app->get('shopMailer')->transport->getUsername() => \Yii::$app->name ?? parse_url(Url::base(true), PHP_URL_HOST)],
            $event->sender->module->partnerManagerEmail
        );
    }
public function send ( $ event ) { if ( Yii :: $ app -> user -> isGuest ) { $ profile = Yii :: $ app -> request -> post ( 'Profile' ) ; $ partnerRequest = Yii :: $ app -> request -> post ( 'PartnerRequest' ) ; $ partnerEmail = [ Yii :: $ app -> request -> post ( 'register-form' ) [ 'email' ] ] ; $ userMailVars = [ '{name}' => $ profile [ 'name' ] , '{surname}' => $ profile [ 'surname' ] , '{patronymic}' => $ profile [ 'patronymic' ] , '{info}' => $ profile [ 'info' ] , ] ; } else { $ profile = Profile :: find ( ) -> where ( [ 'user_id' => Yii :: $ app -> user -> id ] ) -> one ( ) ; $ partnerRequest = PartnerRequest :: find ( ) -> where ( [ 'sender_id' => Yii :: $ app -> user -> id ] ) -> one ( ) ; $ partnerEmail = [ $ profile -> user -> email ] ; $ userMailVars = [ '{name}' => $ profile -> name , '{surname}' => $ profile -> surname , '{patronymic}' => $ profile -> patronymic , '{info}' => $ profile -> info , ] ; } $ mailVars = [ '{contact_person}' => $ partnerRequest [ 'contact_person' ] , '{company_name}' => $ partnerRequest [ 'company_name' ] , '{website}' => $ partnerRequest [ 'website' ] , '{message}' => $ partnerRequest [ 'message' ] , '{link}' => Html :: a ( \ Yii :: t ( 'shop' , 'Details' ) , Url :: to ( 'admin/shop/partners/view?id=' . $ partnerRequest [ 'id' ] , true ) ) ] ; $ mailVars = array_merge ( $ userMailVars , $ mailVars ) ; $ mailer = \ Yii :: createObject ( Mailer :: className ( ) ) ; $ mailer -> sendPartnerRequestToPartner ( $ mailVars , [ $ event -> sender -> module -> senderEmail ?? \ Yii :: $ app -> get ( 'shopMailer' ) -> transport -> getUsername ( ) => \ Yii :: $ app -> name ?? parse_url ( Url :: base ( true ) , PHP_URL_HOST ) ] , $ partnerEmail ) ; $ mailer -> sendPartnerRequestToManager ( $ mailVars , [ $ event -> sender -> module -> senderEmail ?? \ Yii :: $ app -> get ( 'shopMailer' ) -> transport -> getUsername ( ) => \ Yii :: $ app -> name ?? parse_url ( Url :: base ( true ) , PHP_URL_HOST ) ] , $ event -> sender -> module -> partnerManagerEmail ) ; }
Sends emails about partner request to manager and partner
@param $event
Sends emails about partner request to manager and partner