Move attachment creators to mailer class

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-10-25 09:26:57 +02:00
parent 65e938c4fd
commit 6a035bd0a0
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
4 changed files with 39 additions and 38 deletions

View File

@ -26,6 +26,7 @@ use OCP\Defaults;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Mail\IAttachment;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
use OCP\ILogger;
@ -91,6 +92,27 @@ class Mailer implements IMailer {
return new Message(new \Swift_Message());
}
/**
* @param string|null $data
* @param string|null $filename
* @param string|null $contentType
* @return IAttachment
* @since 13.0.0
*/
public function createAttachment($data = null, $filename = null, $contentType = null) {
return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
}
/**
* @param string $path
* @param string|null $contentType
* @return IAttachment
* @since 13.0.0
*/
public function createAttachmentFromPath($path, $contentType = null) {
return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
}
/**
* Creates a new email template object
*

View File

@ -44,27 +44,6 @@ class Message implements IMessage {
$this->swiftMessage = $swiftMessage;
}
/**
* @param string|null $data
* @param string|null $filename
* @param string|null $contentType
* @return IAttachment
* @since 13.0.0
*/
public function createAttachment($data = null, $filename = null, $contentType = null) {
return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
}
/**
* @param string $path
* @param string|null $contentType
* @return IAttachment
* @since 13.0.0
*/
public function createAttachmentFromPath($path, $contentType = null) {
return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
}
/**
* @param IAttachment $attachment
* @return $this

View File

@ -53,6 +53,23 @@ interface IMailer {
*/
public function createMessage();
/**
* @param string|null $data
* @param string|null $filename
* @param string|null $contentType
* @return IAttachment
* @since 13.0.0
*/
public function createAttachment($data = null, $filename = null, $contentType = null);
/**
* @param string $path
* @param string|null $contentType
* @return IAttachment
* @since 13.0.0
*/
public function createAttachmentFromPath($path, $contentType = null);
/**
* Creates a new email template object
*

View File

@ -29,23 +29,6 @@ namespace OCP\Mail;
*/
interface IMessage {
/**
* @param string|null $data
* @param string|null $filename
* @param string|null $contentType
* @return IAttachment
* @since 13.0.0
*/
public function createAttachment($data = null, $filename = null, $contentType = null);
/**
* @param string $path
* @param string|null $contentType
* @return IAttachment
* @since 13.0.0
*/
public function createAttachmentFromPath($path, $contentType = null);
/**
* @param IAttachment $attachment
* @return $this