Initial commit: CloudOps infrastructure platform

This commit is contained in:
root
2026-04-09 19:58:57 +02:00
commit 1166a52f26
7762 changed files with 839452 additions and 0 deletions

View File

@@ -0,0 +1,190 @@
<?php
namespace Mautic\ChannelBundle\Event;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Contracts\EventDispatcher\Event;
class ChannelBroadcastEvent extends Event
{
/**
* Number of contacts successfully processed and/or failed per channel.
*
* @var array
*/
protected $results = [];
/**
* Min contact ID filter can be used for process parallelization.
*
* @var int
*/
private $minContactIdFilter;
/**
* Max contact ID filter can be used for process parallelization.
*
* @var int
*/
private $maxContactIdFilter;
/**
* How many contacts to load from the database.
*/
private int $limit = 100;
/**
* How big batches to use to actually send.
*/
private int $batch = 50;
private ?int $maxThreads = null;
private ?int $threadId = null;
public function __construct(
/**
* Specific channel.
*/
protected ?string $channel,
/**
* Specific ID of a specific channel.
*/
protected string|int|null $id,
protected OutputInterface $output,
) {
}
/**
* @return mixed
*/
public function getChannel()
{
return $this->channel;
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param string $channelLabel
* @param int $successCount
* @param int $failedCount
*/
public function setResults($channelLabel, $successCount, $failedCount = 0, array $failedRecipientsByList = []): void
{
$this->results[$channelLabel] = [
'success' => (int) $successCount,
'failed' => (int) $failedCount,
'failedRecipientsByList' => $failedRecipientsByList,
];
}
/**
* @return array
*/
public function getResults()
{
return $this->results;
}
public function checkContext($channel): bool
{
if ($this->channel && $this->channel !== $channel) {
return false;
}
return true;
}
/**
* @return OutputInterface
*/
public function getOutput()
{
return $this->output;
}
/**
* @param int $minContactIdFilter
*/
public function setMinContactIdFilter($minContactIdFilter): void
{
$this->minContactIdFilter = $minContactIdFilter;
}
/**
* @return int|null
*/
public function getMinContactIdFilter()
{
return $this->minContactIdFilter;
}
/**
* @param int $maxContactIdFilter
*/
public function setMaxContactIdFilter($maxContactIdFilter): void
{
$this->maxContactIdFilter = $maxContactIdFilter;
}
/**
* @return int|null
*/
public function getMaxContactIdFilter()
{
return $this->maxContactIdFilter;
}
/**
* @param int $limit
*/
public function setLimit($limit): void
{
$this->limit = $limit;
}
public function getLimit(): int
{
return $this->limit;
}
/**
* @param int $batch
*/
public function setBatch($batch): void
{
$this->batch = $batch;
}
public function getBatch(): int
{
return $this->batch;
}
public function getMaxThreads(): ?int
{
return $this->maxThreads;
}
public function setMaxThreads(?int $maxThreads): void
{
$this->maxThreads = $maxThreads;
}
public function getThreadId(): ?int
{
return $this->threadId;
}
public function setThreadId(?int $threadId): void
{
$this->threadId = $threadId;
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace Mautic\ChannelBundle\Event;
use Mautic\ChannelBundle\Model\MessageModel;
use Mautic\CoreBundle\Event\CommonEvent;
class ChannelEvent extends CommonEvent
{
/**
* @var array
*/
protected $channels = [];
/**
* @var array
*/
protected $featureChannels = [];
/**
* Adds a submit action to the list of available actions.
*
* @param string $channel a unique identifier; it is recommended that it be namespaced if there are multiple entities in a channel i.e. something.something
* @param array $config Should be keyed by the feature it supports that contains an array of feature configuration options. i.e.
* $config = [
* MessageModel::CHANNEL_FEATURE => [
* 'lookupFormType' => (optional) Form type class/alias for the channel lookup list,
* 'propertiesFormType' => (optional) Form type class/alias for the channel properties if a lookup list is not used,
*
* 'channelTemplate' => (optional) template to inject UI/DOM into the bottom of the channel's tab
* 'formTheme' => (optional) theme directory for custom form types
*
* ]
* ]
*
* @return $this
*/
public function addChannel($channel, array $config = [])
{
$this->channels[$channel] = $config;
foreach ($config as $feature => $featureConfig) {
$this->featureChannels[$feature][$channel] = $featureConfig;
}
return $this;
}
/**
* Returns registered channels with their configs.
*
* @return array
*/
public function getChannelConfigs()
{
return $this->channels;
}
/**
* Returns repository name for the provided channel. Defaults to classic naming convention.
*
* @param string $channel
*
* @return string
*/
public function getRepositoryName($channel)
{
if (isset($this->channels[$channel][MessageModel::CHANNEL_FEATURE]['repository'])) {
return $this->channels[$channel][MessageModel::CHANNEL_FEATURE]['repository'];
}
// if not defined, try the classic naming convention
$channel = ucfirst($channel);
$class = "\Mautic\\{$channel}Bundle\Entity\\{$channel}";
\assert(class_exists($class));
return $class;
}
/**
* Returns the name of the column holding the channel name for the provided channel. Defaults to 'name'.
*
* @param string $channel
*
* @return string
*/
public function getNameColumn($channel)
{
return $this->channels[$channel][MessageModel::CHANNEL_FEATURE]['nameColumn'] ?? 'name';
}
/**
* @return array
*/
public function getFeatureChannels()
{
return $this->featureChannels;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Mautic\ChannelBundle\Event;
use Mautic\ChannelBundle\Entity\Message;
use Mautic\CoreBundle\Event\CommonEvent;
class MessageEvent extends CommonEvent
{
/**
* @param bool $isNew
*/
public function __construct(Message $message, $isNew = false)
{
$this->entity = $message;
$this->isNew = $isNew;
}
/**
* @return Message
*/
public function getMessage()
{
return $this->entity;
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Mautic\ChannelBundle\Event;
use Mautic\ChannelBundle\Entity\MessageQueue;
use Symfony\Contracts\EventDispatcher\Event;
class MessageQueueBatchProcessEvent extends Event
{
/**
* @param MessageQueue[] $messages
*/
public function __construct(
private array $messages,
private $channel,
private $channelId,
) {
}
public function checkContext($channel): bool
{
return $channel === $this->channel;
}
/**
* @return array
*/
public function getMessages()
{
return $this->messages;
}
/**
* @return mixed
*/
public function getChannel()
{
return $this->channel;
}
/**
* @return mixed
*/
public function getChannelId()
{
return $this->channelId;
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Mautic\ChannelBundle\Event;
use Mautic\ChannelBundle\Entity\MessageQueue;
use Mautic\CoreBundle\Event\CommonEvent;
class MessageQueueEvent extends CommonEvent
{
/**
* @param bool $isNew
*/
public function __construct(MessageQueue $entity, $isNew = false)
{
$this->entity = $entity;
$this->isNew = $isNew;
}
/**
* @return MessageQueue
*/
public function getMessageQueue()
{
return $this->entity;
}
/**
* @param MessageQueue $entity
*/
public function setMessageQueue($entity): void
{
$this->entity = $entity;
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Mautic\ChannelBundle\Event;
use Mautic\ChannelBundle\Entity\MessageQueue;
use Mautic\CoreBundle\Event\CommonEvent;
class MessageQueueProcessEvent extends CommonEvent
{
public function __construct(MessageQueue $entity)
{
$this->entity = $entity;
}
/**
* @return MessageQueue
*/
public function getMessageQueue()
{
return $this->entity;
}
public function checkContext($channel): bool
{
return $channel === $this->entity->getChannel();
}
}