Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions config/services/managers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,78 @@ services:
autoconfigure: true
public: false

PhpList\Core\Domain\Subscription\Service\Manager\SubscriberManager:
PhpList\Core\Domain\Identity\Service\SessionManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Identity\Service\SessionManager:
PhpList\Core\Domain\Identity\Service\AdministratorManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\Manager\SubscriberListManager:
PhpList\Core\Domain\Identity\Service\AdminAttributeDefinitionManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\Manager\SubscriptionManager:
PhpList\Core\Domain\Identity\Service\AdminAttributeManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\MessageManager:
PhpList\Core\Domain\Identity\Service\PasswordManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\TemplateManager:
PhpList\Core\Domain\Subscription\Service\Manager\SubscriberManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\TemplateImageManager:
PhpList\Core\Domain\Subscription\Service\Manager\SubscriberListManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Identity\Service\AdministratorManager:
PhpList\Core\Domain\Subscription\Service\Manager\SubscriptionManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Identity\Service\AdminAttributeDefinitionManager:
PhpList\Core\Domain\Subscription\Service\Manager\AttributeDefinitionManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Identity\Service\AdminAttributeManager:
PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\Manager\AttributeDefinitionManager:
PhpList\Core\Domain\Subscription\Service\Manager\SubscriberAttributeManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager:
PhpList\Core\Domain\Subscription\Service\Manager\SubscriberBlacklistManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\Manager\SubscriberAttributeManager:
PhpList\Core\Domain\Subscription\Service\Manager\SubscribePageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Configuration\Service\Manager\ConfigManager:
PhpList\Core\Domain\Messaging\Service\Manager\MessageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Identity\Service\PasswordManager:
PhpList\Core\Domain\Messaging\Service\Manager\TemplateManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\Manager\ListMessageManager:
PhpList\Core\Domain\Messaging\Service\Manager\TemplateImageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\Manager\SubscriberBlacklistManager:
PhpList\Core\Domain\Messaging\Service\Manager\BounceRegexManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\Manager\SubscribePageManager:
PhpList\Core\Domain\Messaging\Service\Manager\ListMessageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Configuration\Service\Manager\ConfigManager:
autowire: true
autoconfigure: true
5 changes: 5 additions & 0 deletions config/services/repositories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,8 @@ services:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Subscription\Model\SubscribePageData

PhpList\Core\Domain\Messaging\Repository\BounceRegexRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Messaging\Model\BounceRegex
16 changes: 8 additions & 8 deletions src/Domain/Messaging/Model/BounceRegex.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class BounceRegex implements DomainModel, Identity
#[ORM\Column(name: 'listorder', type: 'integer', nullable: true, options: ['default' => 0])]
private ?int $listOrder = 0;

#[ORM\Column(type: 'integer', nullable: true)]
private ?int $admin;
#[ORM\Column(name: 'admin', type: 'integer', nullable: true)]
private ?int $adminId;

#[ORM\Column(type: 'text', nullable: true)]
private ?string $comment;
Expand All @@ -48,7 +48,7 @@ public function __construct(
?string $regexHash = null,
?string $action = null,
?int $listOrder = 0,
?int $admin = null,
?int $adminId = null,
?string $comment = null,
?string $status = null,
?int $count = 0
Expand All @@ -57,7 +57,7 @@ public function __construct(
$this->regexHash = $regexHash;
$this->action = $action;
$this->listOrder = $listOrder;
$this->admin = $admin;
$this->adminId = $adminId;
$this->comment = $comment;
$this->status = $status;
$this->count = $count;
Expand Down Expand Up @@ -112,14 +112,14 @@ public function setListOrder(?int $listOrder): self
return $this;
}

public function getAdmin(): ?int
public function getAdminId(): ?int
{
return $this->admin;
return $this->adminId;
}

public function setAdmin(?int $admin): self
public function setAdminId(?int $adminId): self
{
$this->admin = $admin;
$this->adminId = $adminId;
return $this;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Domain/Messaging/Repository/BounceRegexRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
use PhpList\Core\Domain\Common\Repository\AbstractRepository;
use PhpList\Core\Domain\Common\Repository\CursorPaginationTrait;
use PhpList\Core\Domain\Common\Repository\Interfaces\PaginatableRepositoryInterface;
use PhpList\Core\Domain\Messaging\Model\BounceRegex;

class BounceRegexRepository extends AbstractRepository implements PaginatableRepositoryInterface
{
use CursorPaginationTrait;

public function findOneByRegexHash(string $regexHash): ?BounceRegex
{
return $this->findOneBy(['regexHash' => $regexHash]);
}
}
99 changes: 99 additions & 0 deletions src/Domain/Messaging/Service/Manager/BounceRegexManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Domain\Messaging\Service\Manager;

use Doctrine\ORM\EntityManagerInterface;
use PhpList\Core\Domain\Messaging\Model\Bounce;
use PhpList\Core\Domain\Messaging\Model\BounceRegex;
use PhpList\Core\Domain\Messaging\Model\BounceRegexBounce;
use PhpList\Core\Domain\Messaging\Repository\BounceRegexRepository;

class BounceRegexManager
{
private BounceRegexRepository $bounceRegexRepository;
private EntityManagerInterface $entityManager;

public function __construct(
BounceRegexRepository $bounceRegexRepository,
EntityManagerInterface $entityManager
) {
$this->bounceRegexRepository = $bounceRegexRepository;
$this->entityManager = $entityManager;
}

/**
* Creates or updates (if exists) a BounceRegex from a raw regex pattern.
*/
public function createOrUpdateFromPattern(
string $regex,
?string $action = null,
?int $listOrder = 0,
?int $adminId = null,
?string $comment = null,
?string $status = null
): BounceRegex {
$regexHash = md5($regex);

$existing = $this->bounceRegexRepository->findOneByRegexHash($regexHash);

if ($existing !== null) {
$existing->setRegex($regex)
->setAction($action ?? $existing->getAction())
->setListOrder($listOrder ?? $existing->getListOrder())
->setAdminId($adminId ?? $existing->getAdminId())
->setComment($comment ?? $existing->getComment())
->setStatus($status ?? $existing->getStatus());

$this->bounceRegexRepository->save($existing);

return $existing;
}

$bounceRegex = new BounceRegex(
regex: $regex,
regexHash: $regexHash,
action: $action,
listOrder: $listOrder,
adminId: $adminId,
comment: $comment,
status: $status,
count: 0
);

$this->bounceRegexRepository->save($bounceRegex);

return $bounceRegex;
}

/** @return BounceRegex[] */
public function getAll(): array
{
return $this->bounceRegexRepository->findAll();
}

public function getByHash(string $regexHash): ?BounceRegex
{
return $this->bounceRegexRepository->findOneByRegexHash($regexHash);
}

public function delete(BounceRegex $bounceRegex): void
{
$this->bounceRegexRepository->remove($bounceRegex);
}

/**
* Associates a bounce with the regex it matched and increments usage count.
*/
public function associateBounce(BounceRegex $regex, Bounce $bounce): BounceRegexBounce
{
$relation = new BounceRegexBounce($regex->getId() ?? 0, $bounce->getId() ?? 0);
$this->entityManager->persist($relation);

$regex->setCount(($regex->getCount() ?? 0) + 1);
$this->entityManager->flush();

return $relation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpList\Core\Domain\Messaging\Service;
namespace PhpList\Core\Domain\Messaging\Service\Manager;

use PhpList\Core\Domain\Identity\Model\Administrator;
use PhpList\Core\Domain\Messaging\Model\Dto\MessageContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpList\Core\Domain\Messaging\Service;
namespace PhpList\Core\Domain\Messaging\Service\Manager;

use Doctrine\ORM\EntityManagerInterface;
use DOMDocument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpList\Core\Domain\Messaging\Service;
namespace PhpList\Core\Domain\Messaging\Service\Manager;

use Doctrine\ORM\EntityManagerInterface;
use PhpList\Core\Domain\Common\Model\ValidationContext;
Expand Down
Loading
Loading