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,86 @@
<?php
declare(strict_types=1);
namespace Mautic\LeadBundle\Field\Dispatcher;
use Mautic\LeadBundle\Entity\LeadField;
use Mautic\LeadBundle\Exception\NoListenerException;
use Mautic\LeadBundle\Field\Event\AddColumnBackgroundEvent;
use Mautic\LeadBundle\Field\Event\DeleteColumnBackgroundEvent;
use Mautic\LeadBundle\Field\Event\UpdateColumnBackgroundEvent;
use Mautic\LeadBundle\Field\Exception\AbortColumnCreateException;
use Mautic\LeadBundle\Field\Exception\AbortColumnUpdateException;
use Mautic\LeadBundle\LeadEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class FieldColumnBackgroundJobDispatcher
{
public function __construct(
private EventDispatcherInterface $dispatcher,
) {
}
/**
* @throws AbortColumnCreateException
* @throws NoListenerException
*/
public function dispatchPreAddColumnEvent(LeadField $leadField): void
{
$action = LeadEvents::LEAD_FIELD_PRE_ADD_COLUMN_BACKGROUND_JOB;
if (!$this->dispatcher->hasListeners($action)) {
throw new NoListenerException('There is no Listener for this event');
}
$event = new AddColumnBackgroundEvent($leadField);
$this->dispatcher->dispatch($event, $action);
if ($event->isPropagationStopped()) {
throw new AbortColumnCreateException('Column cannot be created now');
}
}
/**
* @throws AbortColumnUpdateException
* @throws NoListenerException
*/
public function dispatchPreUpdateColumnEvent(LeadField $leadField): void
{
$action = LeadEvents::LEAD_FIELD_PRE_UPDATE_COLUMN_BACKGROUND_JOB;
if (!$this->dispatcher->hasListeners($action)) {
throw new NoListenerException('There is no Listener for this event');
}
$event = new UpdateColumnBackgroundEvent($leadField);
$this->dispatcher->dispatch($event, $action);
if ($event->isPropagationStopped()) {
throw new AbortColumnUpdateException('Column cannot be updated now');
}
}
/**
* @throws AbortColumnUpdateException
* @throws NoListenerException
*/
public function dispatchPreDeleteColumnEvent(LeadField $leadField): void
{
$action = LeadEvents::LEAD_FIELD_PRE_DELETE_COLUMN_BACKGROUND_JOB;
if (!$this->dispatcher->hasListeners($action)) {
throw new NoListenerException('There is no Listener for this event');
}
$event = new DeleteColumnBackgroundEvent($leadField);
$this->dispatcher->dispatch($event, $action);
if ($event->isPropagationStopped()) {
throw new AbortColumnUpdateException('Column cannot be deleted now');
}
}
}

View File

@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
namespace Mautic\LeadBundle\Field\Dispatcher;
use Mautic\LeadBundle\Entity\LeadField;
use Mautic\LeadBundle\Exception\NoListenerException;
use Mautic\LeadBundle\Field\Event\AddColumnEvent;
use Mautic\LeadBundle\Field\Event\DeleteColumnEvent;
use Mautic\LeadBundle\Field\Event\UpdateColumnEvent;
use Mautic\LeadBundle\Field\Exception\AbortColumnCreateException;
use Mautic\LeadBundle\Field\Exception\AbortColumnUpdateException;
use Mautic\LeadBundle\Field\Settings\BackgroundSettings;
use Mautic\LeadBundle\LeadEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class FieldColumnDispatcher
{
public function __construct(
private EventDispatcherInterface $dispatcher,
private BackgroundSettings $backgroundSettings,
) {
}
/**
* @throws AbortColumnCreateException
*/
public function dispatchPreAddColumnEvent(LeadField $leadField): void
{
$shouldProcessInBackground = $this->backgroundSettings->shouldProcessColumnChangeInBackground();
$event = new AddColumnEvent($leadField, $shouldProcessInBackground);
$this->dispatcher->dispatch($event, LeadEvents::LEAD_FIELD_PRE_ADD_COLUMN);
if ($shouldProcessInBackground) {
throw new AbortColumnCreateException('Column change will be processed in background job');
}
}
/**
* @throws AbortColumnUpdateException
* @throws NoListenerException
*/
public function dispatchPreUpdateColumnEvent(LeadField $leadField): void
{
$action = LeadEvents::LEAD_FIELD_PRE_UPDATE_COLUMN;
if (!$this->dispatcher->hasListeners($action)) {
throw new NoListenerException('There is no Listener for this event');
}
$shouldProcessInBackground = $this->backgroundSettings->shouldProcessColumnChangeInBackground();
$event = new UpdateColumnEvent($leadField, $shouldProcessInBackground);
$this->dispatcher->dispatch($event, $action);
if ($event->shouldProcessInBackground()) {
throw new AbortColumnUpdateException('Column change will be processed in background job');
}
}
/**
* @throws AbortColumnUpdateException
* @throws NoListenerException
*/
public function dispatchPreDeleteColumnEvent(LeadField $leadField): void
{
$action = LeadEvents::LEAD_FIELD_PRE_DELETE_COLUMN;
if (!$this->dispatcher->hasListeners($action)) {
throw new NoListenerException('There is no Listener for this event');
}
$shouldProcessInBackground = $this->backgroundSettings->shouldProcessColumnChangeInBackground();
$event = new DeleteColumnEvent($leadField, $shouldProcessInBackground);
$this->dispatcher->dispatch($event, $action);
if ($event->shouldProcessInBackground()) {
throw new AbortColumnUpdateException('Column delete will be processed in background job');
}
}
}

View File

@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
namespace Mautic\LeadBundle\Field\Dispatcher;
use Doctrine\ORM\EntityManager;
use Mautic\LeadBundle\Entity\LeadField;
use Mautic\LeadBundle\Event\LeadFieldEvent;
use Mautic\LeadBundle\Exception\NoListenerException;
use Mautic\LeadBundle\Field\Exception\AbortColumnUpdateException;
use Mautic\LeadBundle\Field\Settings\BackgroundSettings;
use Mautic\LeadBundle\LeadEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class FieldDeleteDispatcher
{
public function __construct(
private EventDispatcherInterface $dispatcher,
private EntityManager $entityManager,
private BackgroundSettings $backgroundSettings,
) {
}
/**
* @throws NoListenerException
* @throws AbortColumnUpdateException
*/
public function dispatchPreDeleteEvent(LeadField $entity): LeadFieldEvent
{
if ($this->backgroundSettings->shouldProcessColumnChangeInBackground()) {
throw new AbortColumnUpdateException('Column change will be processed in background job');
}
return $this->dispatchEvent(LeadEvents::FIELD_PRE_DELETE, $entity);
}
/**
* @throws NoListenerException
*/
public function dispatchPostDeleteEvent(LeadField $entity): LeadFieldEvent
{
return $this->dispatchEvent(LeadEvents::FIELD_POST_DELETE, $entity);
}
/**
* @param string $action - Use constant from LeadEvents class (e.g. LeadEvents::FIELD_PRE_SAVE)
*
* @throws NoListenerException
*/
private function dispatchEvent($action, LeadField $entity, ?LeadFieldEvent $event = null): LeadFieldEvent
{
if (!$this->dispatcher->hasListeners($action)) {
throw new NoListenerException('There is no Listener for this event');
}
if (null === $event) {
$event = new LeadFieldEvent($entity);
$event->setEntityManager($this->entityManager);
}
$this->dispatcher->dispatch($event, $action);
return $event;
}
}

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace Mautic\LeadBundle\Field\Dispatcher;
use Doctrine\ORM\EntityManager;
use Mautic\LeadBundle\Entity\LeadField;
use Mautic\LeadBundle\Event\LeadFieldEvent;
use Mautic\LeadBundle\Exception\NoListenerException;
use Mautic\LeadBundle\LeadEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class FieldSaveDispatcher
{
public function __construct(
private EventDispatcherInterface $dispatcher,
private EntityManager $entityManager,
) {
}
/**
* @throws NoListenerException
*/
public function dispatchPreSaveEvent(LeadField $entity, bool $isNew): LeadFieldEvent
{
return $this->dispatchEvent(LeadEvents::FIELD_PRE_SAVE, $entity, $isNew);
}
/**
* @throws NoListenerException
*/
public function dispatchPostSaveEvent(LeadField $entity, bool $isNew): LeadFieldEvent
{
return $this->dispatchEvent(LeadEvents::FIELD_POST_SAVE, $entity, $isNew);
}
/**
* @throws NoListenerException
*/
public function dispatchEvent(string $action, LeadField $entity, bool $isNew, ?LeadFieldEvent $event = null): LeadFieldEvent
{
if (!$this->dispatcher->hasListeners($action)) {
throw new NoListenerException('There is no Listener for '.$action.' event');
}
if (null === $event) {
$event = new LeadFieldEvent($entity, $isNew);
$event->setEntityManager($this->entityManager);
}
$this->dispatcher->dispatch($event, $action);
return $event;
}
}