<?php
namespace common\logic\Producer\Producer\Event;

use common\logic\Producer\Producer\Module\ProducerModule;
use common\logic\User\User\Event\UserCreateEvent;
use justcoded\yii2\eventlistener\observers\Observer;

class UserObserver extends Observer
{
    public function events()
    {
        return [
            UserCreateEvent::NAME => 'onUserCreate'
        ];
    }

    public function onUserCreate(UserCreateEvent $event)
    {
        ProducerModule::getInstance()->getBuilder()
            ->addUser($event->user, $event->producer, true, $event->newsletter);
    }
}