Skip to content

Commit

Permalink
Merge branch '4' into 5
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 7, 2022
2 parents 721b3cb + 906cd0e commit 83a09da
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
38 changes: 38 additions & 0 deletions src/Control/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use SilverStripe\Core\Convert;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
Expand Down Expand Up @@ -256,10 +257,13 @@ public function __construct(
}

/**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @return Swift_Message
*/
public function getSwiftMessage()
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
if (!$this->swiftMessage) {
$message = new Swift_Message(null, null, 'text/html', 'utf-8');
// Set priority to fix PHP 8.1 SimpleMessage::getPriority() sscanf() null parameter
Expand All @@ -271,12 +275,15 @@ public function getSwiftMessage()
}

/**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @param Swift_Message $swiftMessage
*
* @return $this
*/
public function setSwiftMessage($swiftMessage)
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
$dateTime = new DateTime();
$dateTime->setTimestamp(DBDatetime::now()->getTimestamp());
$swiftMessage->setDate($dateTime);
Expand Down Expand Up @@ -706,30 +713,39 @@ public function setBody($body)
}

/**
* @deprecated 4.12.0 Will be replaced with html()
*
* @return $this
*/
public function invalidateBody()
{
Deprecation::notice('4.12.0', 'Will be replaced with html()');
$this->setBody(null);

return $this;
}

/**
* @deprecated 4.12.0 Will be replaced with getData()
*
* @return string The base URL for the email
*/
public function BaseURL()
{
Deprecation::notice('4.12.0', 'Will be replaced with getData()');
return Director::absoluteBaseURL();
}

/**
* @deprecated Will be removed without equivalent functionality to replace it
*
* Debugging help
*
* @return string Debug info
*/
public function debug()
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
$this->render();

$class = static::class;
Expand Down Expand Up @@ -794,31 +810,40 @@ public function setPlainTemplate($template)
}

/**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @param array $recipients
* @return $this
*/
public function setFailedRecipients($recipients)
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
$this->failedRecipients = $recipients;

return $this;
}

/**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @return array
*/
public function getFailedRecipients()
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
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
*
* @return bool
*/
public function IsEmail()
{
Deprecation::notice('4.12.0', 'Will be replaced with getData()');
return true;
}

Expand Down Expand Up @@ -850,12 +875,16 @@ public function sendPlain()
}

/**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* Render the email
* @param bool $plainOnly Only render the message as plain text
* @return $this
*/
public function render($plainOnly = false)
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');

if ($existingPlainPart = $this->findPlainPart()) {
$this->getSwiftMessage()->detach($existingPlainPart);
}
Expand Down Expand Up @@ -920,10 +949,13 @@ public function render($plainOnly = false)
}

/**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @return Swift_MimePart|false
*/
public function findPlainPart()
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
foreach ($this->getSwiftMessage()->getChildren() as $child) {
if ($child instanceof Swift_MimePart && $child->getContentType() == 'text/plain') {
return $child;
Expand All @@ -933,23 +965,29 @@ public function findPlainPart()
}

/**
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* @return bool
*/
public function hasPlainPart()
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
if ($this->getSwiftMessage()->getContentType() === 'text/plain') {
return true;
}
return (bool) $this->findPlainPart();
}

/**
* @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
*
* @return $this
*/
public function generatePlainPartFromBody()
{
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
$plainPart = $this->findPlainPart();
if ($plainPart) {
$this->getSwiftMessage()->detach($plainPart);
Expand Down
3 changes: 3 additions & 0 deletions src/Control/Email/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace SilverStripe\Control\Email;

/**
* @deprecated 4.12.0 Will be replaced with symfony/mailer
*/
interface Mailer
{

Expand Down
2 changes: 2 additions & 0 deletions src/Control/Email/SwiftMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Swift_Message;

/**
* @deprecated 4.12.0 Will be replaced with symfony/mailer
*
* Mailer objects are responsible for actually sending emails.
* The default Mailer class will use PHP's mail() function.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Control/Email/SwiftPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace SilverStripe\Control\Email;

/**
* @deprecated 4.12.0 Will be replaced with symfony/mailer
*/
class SwiftPlugin implements \Swift_Events_SendListener
{
/**
Expand Down
14 changes: 7 additions & 7 deletions tests/behat/src/CmsUiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected function getCmsTabsElement()
{
$this->getSession()->wait(
5000,
"window.jQuery && window.jQuery('.cms-content-header-tabs').size() > 0"
"window.jQuery && window.jQuery('.cms-content-header-tabs').length > 0"
);

$page = $this->getSession()->getPage();
Expand All @@ -155,8 +155,8 @@ protected function getCmsContentToolbarElement()
{
$this->getSession()->wait(
5000,
"window.jQuery && window.jQuery('.cms-content-toolbar').size() > 0 "
. "&& window.jQuery('.cms-content-toolbar').children().size() > 0"
"window.jQuery && window.jQuery('.cms-content-toolbar').length > 0 "
. "&& window.jQuery('.cms-content-toolbar').children().length > 0"
);

$page = $this->getSession()->getPage();
Expand All @@ -170,7 +170,7 @@ protected function getCmsTreeElement()
{
$this->getSession()->wait(
5000,
"window.jQuery && window.jQuery('.cms-tree').size() > 0"
"window.jQuery && window.jQuery('.cms-tree').length > 0"
);

$page = $this->getSession()->getPage();
Expand Down Expand Up @@ -281,7 +281,7 @@ public function stepIClickOnElementInTheContextMenu($method, $link)
// Wait until context menu has appeared
$this->getSession()->wait(
1000,
"window.jQuery && window.jQuery('.jstree-apple-context').size() > 0"
"window.jQuery && window.jQuery('.jstree-apple-context').length > 0"
);
$regionObj = $context->getRegionObj('.jstree-apple-context');
Assert::assertNotNull($regionObj, "Context menu could not be found");
Expand Down Expand Up @@ -448,7 +448,7 @@ public function iShouldSeeACmsTab($negate, $tab)
{
$this->getSession()->wait(
5000,
"window.jQuery && window.jQuery('.ui-tabs-nav').size() > 0"
"window.jQuery && window.jQuery('.ui-tabs-nav').length > 0"
);

$page = $this->getSession()->getPage();
Expand Down Expand Up @@ -477,7 +477,7 @@ public function iClickTheCmsTab($tab)
{
$this->getSession()->wait(
5000,
"window.jQuery && window.jQuery('.ui-tabs-nav').size() > 0"
"window.jQuery && window.jQuery('.ui-tabs-nav').length > 0"
);

$page = $this->getSession()->getPage();
Expand Down

0 comments on commit 83a09da

Please sign in to comment.