first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<?php
namespace KupShop\MessengerBundle\Message;
use KupShop\OrderingBundle\Exception\MethodNotImplementedException;
class AsyncMessage
{
/**
* @throws MethodNotImplementedException
*/
public function handle()
{
throw new MethodNotImplementedException(sprintf('You have not implemented method %s::%s()!', get_class($this), 'handle'));
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace KupShop\MessengerBundle\Message;
use KupShop\KupShopBundle\Email\BaseEmail;
class EmailMessage
{
private $message;
private $prioritized;
private $service;
private string $id;
/**
* EmailMessage constructor.
*
* @param $service BaseEmail
*/
public function __construct(array $message, BaseEmail $service, bool $prioritized = false)
{
$this->id = uniqid();
$message['id'] = $this->id;
$this->message = $message;
$this->prioritized = $prioritized;
$this->service = $service;
}
public function getMessage()
{
return $this->message;
}
public function getEmailService(): BaseEmail
{
return $this->service;
}
public function isPrioritized()
{
return (bool) $this->prioritized;
}
public function getId(): string
{
return $this->id ?? 'not yet';
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace KupShop\MessengerBundle\Message\Envelope;
abstract class AbstractEnvelope implements EnvelopeInterface
{
private $serializedMessage;
private $callback;
private $retryCount = 5;
private int $retryCountOriginal;
private $unixTimeStamp;
private string $id;
protected string $web;
public function __construct(string $serializedMessage, ?string $callback = null)
{
$this->serializedMessage = $serializedMessage;
$this->callback = $callback ? $callback : path('kupshop_messenger_callback_messagecallback', [], 0);
$this->web = getShopName();
$this->retryCountOriginal = $this->getRetryCount();
}
public function getSerializedMessage(): string
{
return $this->serializedMessage;
}
public function getUnixTimeStamp(): ?int
{
return $this->unixTimeStamp;
}
public function setUnixTimeStamp(int $unixTimeStamp): void
{
$this->unixTimeStamp = $unixTimeStamp;
}
public function getRetryCount(): int
{
return $this->retryCount;
}
public function getRetryIndex(): int
{
return ($this->retryCountOriginal ?? $this->retryCount) - $this->retryCount;
}
public function decreaseRetryCount(): void
{
$this->retryCount--;
}
public function getCallback(): string
{
return $this->callback;
}
public function getWeb(): string
{
return $this->web;
}
public function getId(): string
{
return $this->id ?? 'not yet';
}
public function setId(string $id): AbstractEnvelope
{
$this->id = $id;
return $this;
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace KupShop\MessengerBundle\Message\Envelope;
class AsyncEnvelope extends AbstractEnvelope
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace KupShop\MessengerBundle\Message\Envelope;
class EmailEnvelope extends AbstractEnvelope
{
}

View File

@@ -0,0 +1,24 @@
<?php
namespace KupShop\MessengerBundle\Message\Envelope;
interface EnvelopeInterface
{
public function getSerializedMessage(): string;
public function getUnixTimeStamp(): ?int;
public function setUnixTimeStamp(int $unixTimeStamp): void;
public function getRetryCount(): int;
public function getRetryIndex(): int;
public function decreaseRetryCount(): void;
public function getCallback(): string;
public function getWeb(): string;
public function getId(): string;
}

View File

@@ -0,0 +1,7 @@
<?php
namespace KupShop\MessengerBundle\Message\Envelope;
class PriorityEmailEnvelope extends AbstractEnvelope
{
}