Merge pull request #10517 from creative-commoners/pulls/4/deprecate-swiftmailer

API Deprecate swiftmailer
This commit is contained in:
Guy Sartorelli 2022-10-07 09:37:11 +13:00 committed by GitHub
commit 8419984b36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 0 deletions

View File

@ -11,6 +11,7 @@ use SilverStripe\Control\HTTP;
use SilverStripe\Core\Convert; use SilverStripe\Core\Convert;
use SilverStripe\Core\Environment; use SilverStripe\Core\Environment;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\FieldType\DBField; use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\ORM\FieldType\DBHTMLText;
@ -256,10 +257,13 @@ class Email extends ViewableData
} }
/** /**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @return Swift_Message * @return Swift_Message
*/ */
public function getSwiftMessage() public function getSwiftMessage()
{ {
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
if (!$this->swiftMessage) { if (!$this->swiftMessage) {
$message = new Swift_Message(null, null, 'text/html', 'utf-8'); $message = new Swift_Message(null, null, 'text/html', 'utf-8');
// Set priority to fix PHP 8.1 SimpleMessage::getPriority() sscanf() null parameter // Set priority to fix PHP 8.1 SimpleMessage::getPriority() sscanf() null parameter
@ -271,12 +275,15 @@ class Email extends ViewableData
} }
/** /**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @param Swift_Message $swiftMessage * @param Swift_Message $swiftMessage
* *
* @return $this * @return $this
*/ */
public function setSwiftMessage($swiftMessage) public function setSwiftMessage($swiftMessage)
{ {
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
$dateTime = new DateTime(); $dateTime = new DateTime();
$dateTime->setTimestamp(DBDatetime::now()->getTimestamp()); $dateTime->setTimestamp(DBDatetime::now()->getTimestamp());
$swiftMessage->setDate($dateTime); $swiftMessage->setDate($dateTime);
@ -706,30 +713,39 @@ class Email extends ViewableData
} }
/** /**
* @deprecated 4.12.0 Will be replaced with html()
*
* @return $this * @return $this
*/ */
public function invalidateBody() public function invalidateBody()
{ {
Deprecation::notice('4.12.0', 'Will be replaced with html()');
$this->setBody(null); $this->setBody(null);
return $this; return $this;
} }
/** /**
* @deprecated 4.12.0 Will be replaced with getData()
*
* @return string The base URL for the email * @return string The base URL for the email
*/ */
public function BaseURL() public function BaseURL()
{ {
Deprecation::notice('4.12.0', 'Will be replaced with getData()');
return Director::absoluteBaseURL(); return Director::absoluteBaseURL();
} }
/** /**
* @deprecated Will be removed without equivalent functionality to replace it
*
* Debugging help * Debugging help
* *
* @return string Debug info * @return string Debug info
*/ */
public function debug() public function debug()
{ {
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
$this->render(); $this->render();
$class = static::class; $class = static::class;
@ -794,31 +810,40 @@ class Email extends ViewableData
} }
/** /**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @param array $recipients * @param array $recipients
* @return $this * @return $this
*/ */
public function setFailedRecipients($recipients) public function setFailedRecipients($recipients)
{ {
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
$this->failedRecipients = $recipients; $this->failedRecipients = $recipients;
return $this; return $this;
} }
/** /**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @return array * @return array
*/ */
public function getFailedRecipients() public function getFailedRecipients()
{ {
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
return $this->failedRecipients; return $this->failedRecipients;
} }
/** /**
* @deprecated 4.12.0 Will be replaced with getData()
*
* Used by {@link SSViewer} templates to detect if we're rendering an email template rather than a page template * Used by {@link SSViewer} templates to detect if we're rendering an email template rather than a page template
* *
* @return bool * @return bool
*/ */
public function IsEmail() public function IsEmail()
{ {
Deprecation::notice('4.12.0', 'Will be replaced with getData()');
return true; return true;
} }
@ -920,10 +945,13 @@ class Email extends ViewableData
} }
/** /**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @return Swift_MimePart|false * @return Swift_MimePart|false
*/ */
public function findPlainPart() public function findPlainPart()
{ {
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
foreach ($this->getSwiftMessage()->getChildren() as $child) { foreach ($this->getSwiftMessage()->getChildren() as $child) {
if ($child instanceof Swift_MimePart && $child->getContentType() == 'text/plain') { if ($child instanceof Swift_MimePart && $child->getContentType() == 'text/plain') {
return $child; return $child;
@ -933,10 +961,13 @@ class Email extends ViewableData
} }
/** /**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @return bool * @return bool
*/ */
public function hasPlainPart() public function hasPlainPart()
{ {
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
if ($this->getSwiftMessage()->getContentType() === 'text/plain') { if ($this->getSwiftMessage()->getContentType() === 'text/plain') {
return true; return true;
} }
@ -944,12 +975,15 @@ class Email extends ViewableData
} }
/** /**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* Automatically adds a plain part to the email generated from the current Body * Automatically adds a plain part to the email generated from the current Body
* *
* @return $this * @return $this
*/ */
public function generatePlainPartFromBody() public function generatePlainPartFromBody()
{ {
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
$plainPart = $this->findPlainPart(); $plainPart = $this->findPlainPart();
if ($plainPart) { if ($plainPart) {
$this->getSwiftMessage()->detach($plainPart); $this->getSwiftMessage()->detach($plainPart);

View File

@ -2,6 +2,9 @@
namespace SilverStripe\Control\Email; namespace SilverStripe\Control\Email;
/**
* @deprecated 4.12.0 Will be replaced with symfony/mailer
*/
interface Mailer interface Mailer
{ {

View File

@ -9,6 +9,8 @@ use Swift_Mailer;
use Swift_Message; use Swift_Message;
/** /**
* @deprecated 4.12.0 Will be replaced with symfony/mailer
*
* Mailer objects are responsible for actually sending emails. * Mailer objects are responsible for actually sending emails.
* The default Mailer class will use PHP's mail() function. * The default Mailer class will use PHP's mail() function.
*/ */

View File

@ -2,6 +2,9 @@
namespace SilverStripe\Control\Email; namespace SilverStripe\Control\Email;
/**
* @deprecated 4.12.0 Will be replaced with symfony/mailer
*/
class SwiftPlugin implements \Swift_Events_SendListener class SwiftPlugin implements \Swift_Events_SendListener
{ {
/** /**