protected function EmailAttachmentEvaluator::saveAttachment in Easy Email 2.0.x
Same name and namespace in other branches
- 8 src/Service/EmailAttachmentEvaluator.php \Drupal\easy_email\Service\EmailAttachmentEvaluator::saveAttachment()
Parameters
\Drupal\easy_email\Entity\EasyEmailInterface $email:
\Drupal\file\FileInterface $file:
1 call to EmailAttachmentEvaluator::saveAttachment()
- EmailAttachmentEvaluator::evaluateAttachments in src/
Service/ EmailAttachmentEvaluator.php - @inheritDoc
File
- src/
Service/ EmailAttachmentEvaluator.php, line 110
Class
Namespace
Drupal\easy_email\ServiceCode
protected function saveAttachment(EasyEmailInterface $email, $source, $dest_directory) {
\Drupal::service('file_system')
->prepareDirectory($dest_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
$file_entity = file_save_data(file_get_contents($source), $dest_directory . '/' . $this->fileSystem
->basename($source));
$email
->addAttachment($file_entity
->id());
}