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