<?php

namespace domain\Producer\Producer\Event;

use domain\Producer\Producer\ProducerModule;
use justcoded\yii2\eventlistener\observers\ActiveRecordObserver;

class ProducerObserver extends ActiveRecordObserver
{
    public function updated(\yii\db\AfterSaveEvent $event)
    {
        $producer = $event->sender;
        if(isset($event->changedAttributes['option_testimony'])
            && !strlen($event->changedAttributes['option_testimony'])
            && strlen($producer->option_testimony)) {

            ProducerModule::getInstance()->getNotifier()->sendEmailAdminNewTestimony($producer);
        }
    }
}