/** * Processing object before save data * * @return $this */ public function beforeSave() { $this->validate(); return parent::beforeSave(); }
/** * Validate email template code * * @throws \Magento\Framework\Exception\MailException * @return $this */ public function beforeSave() { $code = $this->getTemplateCode(); if (empty($code)) { throw new \Magento\Framework\Exception\MailException(__('The template Name must not be empty.')); } if ($this->_getResource()->checkCodeUsage($this)) { throw new \Magento\Framework\Exception\MailException(__('Duplicate Of Template Name')); } return parent::beforeSave(); }