<?php

namespace domain\Producer\Producer\Event;

use domain\User\User\Event\UserCreateEvent;
use justcoded\yii2\eventlistener\observers\Observer;
use domain\Producer\Producer\ProducerModule;

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);
    }
}