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,7 @@
<?php
namespace Mautic\EmailBundle\Stat\Exception;
class StatNotFoundException extends \Exception
{
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Mautic\EmailBundle\Stat;
use Mautic\EmailBundle\Entity\Stat;
class Reference
{
private ?int $emailId;
/**
* @var int
*/
private $leadId = 0;
private ?string $statId;
public function __construct(Stat $stat)
{
$this->statId = $stat->getId();
$this->emailId = $stat->getEmail()->getId();
if ($lead = $stat->getLead()) {
$this->leadId = $lead->getId();
}
}
/**
* @return int
*/
public function getEmailId()
{
return $this->emailId;
}
/**
* @return int
*/
public function getLeadId()
{
return $this->leadId;
}
public function getStatId(): ?string
{
return $this->statId;
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Mautic\EmailBundle\Stat;
use Mautic\EmailBundle\Entity\Stat;
use Mautic\EmailBundle\Model\EmailStatModel;
use Mautic\EmailBundle\Stat\Exception\StatNotFoundException;
class StatHelper
{
/**
* Just store email ID and lead ID to avoid doctrine RAM issues with entities.
*
* @var Reference[]
*/
private array $stats = [];
private array $deleteUs = [];
public function __construct(
private EmailStatModel $emailStatModel,
) {
}
public function storeStat(Stat $stat, $emailAddress): void
{
$this->emailStatModel->saveEntity($stat);
// to avoid Doctrine RAM issues, we're just going to hold onto ID references
$this->stats[$emailAddress] = new Reference($stat);
// clear stat from doctrine memory
$this->emailStatModel->getRepository()->detachEntity($stat);
}
public function deletePending(): void
{
if (count($this->deleteUs)) {
$this->emailStatModel->getRepository()->deleteStats($this->deleteUs);
}
}
public function markForDeletion(Reference $stat): void
{
$this->deleteUs[] = $stat->getStatId();
}
/**
* @return Reference
*
* @throws StatNotFoundException
*/
public function getStat($emailAddress)
{
if (!isset($this->stats[$emailAddress])) {
throw new StatNotFoundException();
}
return $this->stats[$emailAddress];
}
public function reset(): void
{
$this->deleteUs = [];
$this->stats = [];
}
}