diff --git a/plugins/bc-mail/src/Service/Front/MailFrontService.php b/plugins/bc-mail/src/Service/Front/MailFrontService.php index d06f23dea6..ac888ba0a9 100644 --- a/plugins/bc-mail/src/Service/Front/MailFrontService.php +++ b/plugins/bc-mail/src/Service/Front/MailFrontService.php @@ -249,14 +249,9 @@ public function sendMail(EntityInterface $mailContent, EntityInterface $mailMess ]); } if ($mailContent->save_info) return; - foreach($mailFields as $field) { - if ($field->type !== 'file') continue; - // 削除フラグをセット - $mailMessage->{$field->field_name . '_delete'} = true; - } - // TODO ucmitz 未検証 - $mailMessagesTable = TableRegistry::getTableLocator()->get('BcMail.MailMessages'); - $mailMessagesTable->getFileUploader()->deleteFiles($mailMessage, $mailMessage); + /** @var MailMessagesService $mailMessagesService */ + $mailMessagesService = $this->getService(MailMessagesServiceInterface::class); + $mailMessagesService->delete($mailMessage->id); } catch (\Throwable $e) { throw $e; } diff --git a/plugins/bc-mail/src/Service/MailMessagesService.php b/plugins/bc-mail/src/Service/MailMessagesService.php index aaacaeeffe..e55dd7887b 100644 --- a/plugins/bc-mail/src/Service/MailMessagesService.php +++ b/plugins/bc-mail/src/Service/MailMessagesService.php @@ -143,11 +143,7 @@ public function create(EntityInterface $mailContent, $postData) $mailFieldsTable = TableRegistry::getTableLocator()->get('BcMail.MailFields'); $mailFields = $mailFieldsTable->find()->where(['MailFields.mail_content_id' => $mailContent->id, 'MailFields.use_field' => true])->all(); $this->MailMessages->convertToDb($mailFields, $entity); - if ($mailContent->save_info) { - return $this->MailMessages->saveOrFail($entity); - } else { - return $entity; - } + return $this->MailMessages->saveOrFail($entity); } throw new PersistenceFailedException($entity, __d('baser_core', '入力エラーです。内容を見直してください。')); }