diff --git a/composer.json b/composer.json index d4fcb3c..78d27c0 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,9 @@ ], "minimum-stability": "stable", "require": { - "nette/mail": "^2.3", - "kdyby/doctrine": "^3.0", - "nette/di": "^2.3", + "php": "^7.1", + "nette/mail": "~3.0", + "nette/di": "^2.3 || ~3.0", "tracy/tracy": "^2.3", "adt/background-queue": "^3.12" }, diff --git a/src/Console/ProcessCommand.php b/src/Console/ProcessCommand.php index c8aa5c7..8452a3d 100644 --- a/src/Console/ProcessCommand.php +++ b/src/Console/ProcessCommand.php @@ -10,6 +10,9 @@ class ProcessCommand extends Command { + + protected static $defaultName = 'mail-queue:process'; + /** * {@inheritdoc} */ diff --git a/src/Entity/AbstractMailQueueEntry.php b/src/Entity/AbstractMailQueueEntry.php index 2fef39c..1628476 100644 --- a/src/Entity/AbstractMailQueueEntry.php +++ b/src/Entity/AbstractMailQueueEntry.php @@ -14,7 +14,6 @@ * @property \Nette\Mail\Message|NULL $message */ abstract class AbstractMailQueueEntry { - use \Kdyby\Doctrine\Entities\MagicAccessors; /** * @ORM\Column(type="datetime") @@ -58,7 +57,7 @@ public function getMessage() { * @param \Nette\Mail\Message|NULL $message * @return $this */ - public function setMessage(\Nette\Mail\Message $message = NULL) { + public function setMessage(\Nette\Mail\Message $message = NULL): self { if ($message === NULL) { $this->message = NULL; } else { @@ -71,4 +70,70 @@ public function setMessage(\Nette\Mail\Message $message = NULL) { * @return mixed|NULL */ abstract public function getId(); + + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + * @return AbstractMailQueueEntry + */ + public function setCreatedAt(\DateTime $createdAt): self { + $this->createdAt = $createdAt; + return $this; + } + + /** + * @return \DateTime|NULL + */ + public function getSentAt(): ?\DateTime { + return $this->sentAt; + } + + /** + * @param \DateTime|NULL $sentAt + * @return AbstractMailQueueEntry + */ + public function setSentAt(?\DateTime $sentAt): self { + $this->sentAt = $sentAt; + return $this; + } + + /** + * @return string + */ + public function getFrom(): string { + return $this->from; + } + + /** + * @param string $from + * @return AbstractMailQueueEntry + */ + public function setFrom(string $from): self { + $this->from = $from; + return $this; + } + + /** + * @return string + */ + public function getSubject(): string { + return $this->subject; + } + + /** + * @param string $subject + * @return AbstractMailQueueEntry + */ + public function setSubject(string $subject): self { + $this->subject = $subject; + return $this; + } + } diff --git a/src/Entity/MailQueueEntry.php b/src/Entity/MailQueueEntry.php index 1ca0a3b..0a9efb3 100644 --- a/src/Entity/MailQueueEntry.php +++ b/src/Entity/MailQueueEntry.php @@ -9,5 +9,5 @@ * @ORM\Entity */ class MailQueueEntry extends AbstractMailQueueEntry { - use \Kdyby\Doctrine\Entities\Attributes\Identifier; -} \ No newline at end of file + use \ADT\MailQueue\Traits\Identifier; +} diff --git a/src/Service/QueueMailer.php b/src/Service/QueueMailer.php index d621a7a..0bd9b8a 100644 --- a/src/Service/QueueMailer.php +++ b/src/Service/QueueMailer.php @@ -11,7 +11,7 @@ public function __construct(QueueService $queueService) { $this->queueService = $queueService; } - public function send(\Nette\Mail\Message $mail) { + public function send(\Nette\Mail\Message $mail): void { $this->queueService->enqueue($mail); } diff --git a/src/Service/QueueService.php b/src/Service/QueueService.php index c730079..5d52e76 100644 --- a/src/Service/QueueService.php +++ b/src/Service/QueueService.php @@ -3,6 +3,7 @@ namespace ADT\MailQueue\Service; use ADT\MailQueue\Entity; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -10,7 +11,7 @@ * @method onQueueDrained(OutputInterface|NULL $output) */ class QueueService { - + use \Nette\SmartObject; const MUTEX_TIME_FORMAT = DATE_W3C; @@ -56,11 +57,11 @@ class QueueService { /** @var string */ protected $backgroundQueueCallbackName; - public function __construct($config, \Kdyby\Doctrine\EntityManager $em) { + public function __construct($config, EntityManagerInterface $em) { if (! is_dir($config['tempDir'])) { - mkdir($config['tempDir']); + mkdir($config['tempDir']); } - + $this->mutexFile = 'nette.safe://' . $config['tempDir'] . '/adt-mail-queue.lock'; $this->mutexTimeFile = 'nette.safe://' . $config['tempDir'] . '/adt-mail-queue.lock.timestamp'; diff --git a/src/Traits/Identifier.php b/src/Traits/Identifier.php new file mode 100644 index 0000000..654bce4 --- /dev/null +++ b/src/Traits/Identifier.php @@ -0,0 +1,28 @@ +id; + } + + public function __clone() + { + $this->id = NULL; + } +}