Skip to content

Commit

Permalink
Adapt to Swiftmailer 5 and Swiftmailer 6 version of class Swift_Confi…
Browse files Browse the repository at this point in the history
…gurableSpool
  • Loading branch information
thirsch committed Feb 7, 2023
1 parent 2c5a4d6 commit 2e2bd83
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @version SVN: $Id$
*/
class Swift_DoctrineSpool extends Swift_ConfigurableSpool
class Swift_DoctrineSpool extends Swift_DoctrineSpoolAdapter
{
protected
$model = null,
Expand Down Expand Up @@ -71,9 +71,9 @@ public function stop()
/**
* Stores a message in the queue.
*
* @param Swift_Mime_Message $message The message to store
* @param $message The message to store
*/
public function queueMessage(Swift_Mime_Message $message)
public function internalQueueMessage($message)
{
$object = new $this->model;

Expand All @@ -84,7 +84,7 @@ public function queueMessage(Swift_Mime_Message $message)

$object->{$this->column} = serialize($message);
$object->save();

$object->free(true);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

// Defining a base class for Swift_DoctrineSpool to handle both, Swiftmailer 5 and Swiftmailer 6,
// as we are implementing a base class from the package, we can't simply remove the type hint.
if(class_exists('Swift') && version_compare(Swift::VERSION, '6.0.0') >= 0) {
abstract class Swift_DoctrineSpoolAdapter extends Swift_DoctrineSpoolBase
{
public function queueMessage(Swift_Mime_SimpleMessage $message)
{
$this->internalQueueMessage($message);
}
}
} else {
abstract class Swift_DoctrineSpoolAdapter extends Swift_DoctrineSpoolBase
{
public function queueMessage(Swift_Mime_Message $message)
{
$this->internalQueueMessage($message);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

abstract class Swift_DoctrineSpoolBase extends Swift_ConfigurableSpool
{
protected abstract function internalQueueMessage($message);
}

0 comments on commit 2e2bd83

Please sign in to comment.