BBCodeBehavior.php
public function beforeSave($event)
    {
        $content = $this->owner->{$this->attribute};
       
        if ($this->enableHtmlPurifierBefore) {
            $content = HtmlPurifier::process($content, $this->configHtmlPurifierBefore);
        }
        
        $content = $this->process($content);
        
        if ($this->enableHtmlPurifierAfter) {
            $content = HtmlPurifier::process($content, $this->configHtmlPurifierAfter);
        }
        
        $this->owner->{$this->saveAttribute} = $content;
    }
public function beforeSave($event)
    {
        $content = $this->owner->{$this->attribute};
       
        if ($this->enableHtmlPurifierBefore) {
            $content = HtmlPurifier::process($content, $this->configHtmlPurifierBefore);
        }
        
        $content = $this->process($content);
        
        if ($this->enableHtmlPurifierAfter) {
            $content = HtmlPurifier::process($content, $this->configHtmlPurifierAfter);
        }
        
        $this->owner->{$this->saveAttribute} = $content;
    }
Parsing BB-codes before save of model.

@param \yii\base\Event $event