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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,9 @@ command to extract translation strings
```bash
php bin/console translation:extract --force en --format=xlf
```

```bash
vendor/bin/phpstan analyse -c phpstan.neon;
vendor/bin/phpmd src/ text config/PHPMD/rules.xml;
vendor/bin/phpcs --standard=config/PhpCodeSniffer/ --ignore=*/Migrations/* bin/ src/ tests/ public/;
```
4 changes: 4 additions & 0 deletions config/services/mappers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ services:
PhpList\Core\Domain\Subscription\Service\CsvToDtoImporter:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\Mapper\DefaultTemplateMapper:
autowire: true
autoconfigure: true
6 changes: 5 additions & 1 deletion config/services/messenger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ services:
resource: '../../src/Domain/Subscription/MessageHandler'
tags: [ 'messenger.message_handler' ]

PhpList\Core\Domain\Messaging\MessageHandler\CampaignProcessorMessageHandler:
PhpList\Core\Domain\Messaging\MessageHandler\CampaignProcessor\CampaignProcessorMessageHandler:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\MessageHandler\CampaignProcessor\TestCampaignProcessorMessageHandler:
autowire: true
autoconfigure: true
37 changes: 14 additions & 23 deletions config/services/resolvers.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
services:
_defaults:
autowire: true
autoconfigure: true

_instanceof:
PhpList\Core\Domain\Configuration\Service\Placeholder\PlaceholderValueResolverInterface:
tags: ['phplist.placeholder_resolver']
PhpList\Core\Domain\Configuration\Service\Placeholder\PatternValueResolverInterface:
tags: ['phplist.pattern_resolver']
PhpList\Core\Domain\Configuration\Service\Placeholder\SupportingPlaceholderResolverInterface:
tags: ['phplist.supporting_placeholder_resolver']

PhpList\Core\Domain\Subscription\Service\Resolver\AttributeValueResolver:
arguments:
$providers:
Expand All @@ -14,26 +26,5 @@ services:
arguments:
- !tagged_iterator { tag: 'phplist.bounce_action_handler' }

PhpList\Core\Domain\Configuration\Service\Placeholder\UnsubscribeUrlValueResolver:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Configuration\Service\Placeholder\ConfirmationUrlValueResolver:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Configuration\Service\Placeholder\PreferencesUrlValueResolver:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Configuration\Service\Placeholder\SubscribeUrlValueResolver:
autowire: true
autoconfigure: true

_instanceof:
PhpList\Core\Domain\Configuration\Service\Placeholder\PlaceholderValueResolverInterface:
tags: ['phplist.placeholder_resolver']
PhpList\Core\Domain\Configuration\Service\Placeholder\PatternValueResolverInterface:
tags: [ 'phplist.pattern_resolver' ]
PhpList\Core\Domain\Configuration\Service\Placeholder\SupportingPlaceholderResolverInterface:
tags: [ 'phplist.supporting_placeholder_resolver' ]
PhpList\Core\Domain\Configuration\Service\Placeholder\:
resource: '../../src/Domain/Configuration/Service/Placeholder/*'
8 changes: 4 additions & 4 deletions public/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
DirectoryIndex index.php

# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
Expand Down Expand Up @@ -46,23 +46,23 @@ DirectoryIndex app.php
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]

# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# Rewrite all other queries to the front controller.
RewriteRule ^ %{ENV:BASE}/app.php [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /app.php/
RedirectMatch 302 ^/$ /index.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
20 changes: 20 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use PhpList\Core\Core\Bootstrap;
use PhpList\Core\Core\Environment;

require dirname(__DIR__) . '/vendor/autoload.php';

$environment = $_ENV['APP_ENV'] ?? $_SERVER['APP_ENV'] ?? getenv('APP_ENV') ?: Environment::PRODUCTION;

$bootstrap = Bootstrap::getInstance();
if ($environment !== Environment::PRODUCTION) {
$bootstrap->ensureDevelopmentOrTestingEnvironment();
}

$bootstrap
->setEnvironment($environment)
->configure()
->dispatch();
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpList\Core\Bounce\Service\Manager\BounceManager;
use PhpList\Core\Bounce\Service\SubscriberBlacklistService;
use PhpList\Core\Domain\Messaging\Model\BounceAction;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager;
use Symfony\Contracts\Translation\TranslatorInterface;

Expand All @@ -30,7 +31,7 @@ public function __construct(

public function supports(string $action): bool
{
return $action === 'blacklistemailanddeletebounce';
return $action === BounceAction::BlacklistEmailAndDeleteBounce->value;
}

public function handle(array $closureData): void
Expand Down
3 changes: 2 additions & 1 deletion src/Bounce/Service/Handler/BlacklistEmailHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PhpList\Core\Bounce\Service\Handler;

use PhpList\Core\Bounce\Service\SubscriberBlacklistService;
use PhpList\Core\Domain\Messaging\Model\BounceAction;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager;
use Symfony\Contracts\Translation\TranslatorInterface;

Expand All @@ -26,7 +27,7 @@ public function __construct(

public function supports(string $action): bool
{
return $action === 'blacklistemail';
return $action === BounceAction::BlacklistEmail->value;
}

public function handle(array $closureData): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpList\Core\Bounce\Service\Manager\BounceManager;
use PhpList\Core\Bounce\Service\SubscriberBlacklistService;
use PhpList\Core\Domain\Messaging\Model\BounceAction;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager;
use Symfony\Contracts\Translation\TranslatorInterface;

Expand All @@ -30,7 +31,7 @@ public function __construct(

public function supports(string $action): bool
{
return $action === 'blacklistuseranddeletebounce';
return $action === BounceAction::BlacklistUserAndDeleteBounce->value;
}

public function handle(array $closureData): void
Expand Down
3 changes: 2 additions & 1 deletion src/Bounce/Service/Handler/BlacklistUserHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PhpList\Core\Bounce\Service\Handler;

use PhpList\Core\Bounce\Service\SubscriberBlacklistService;
use PhpList\Core\Domain\Messaging\Model\BounceAction;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager;
use Symfony\Contracts\Translation\TranslatorInterface;

Expand All @@ -26,7 +27,7 @@ public function __construct(

public function supports(string $action): bool
{
return $action === 'blacklistuser';
return $action === BounceAction::BlacklistUser->value;
}

public function handle(array $closureData): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PhpList\Core\Bounce\Service\Handler;

use PhpList\Core\Bounce\Service\Manager\BounceManager;
use PhpList\Core\Domain\Messaging\Model\BounceAction;
use PhpList\Core\Domain\Subscription\Repository\SubscriberRepository;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -30,7 +31,7 @@ public function __construct(

public function supports(string $action): bool
{
return $action === 'decreasecountconfirmuseranddeletebounce';
return $action === BounceAction::DecreaseCountConfirmUserAndDeleteBounce->value;
}

public function handle(array $closureData): void
Expand Down
3 changes: 2 additions & 1 deletion src/Bounce/Service/Handler/DeleteBounceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PhpList\Core\Bounce\Service\Handler;

use PhpList\Core\Bounce\Service\Manager\BounceManager;
use PhpList\Core\Domain\Messaging\Model\BounceAction;

class DeleteBounceHandler implements BounceActionHandlerInterface
{
Expand All @@ -17,7 +18,7 @@ public function __construct(BounceManager $bounceManager)

public function supports(string $action): bool
{
return $action === 'deletebounce';
return $action === BounceAction::DeleteBounce->value;
}

public function handle(array $closureData): void
Expand Down
3 changes: 2 additions & 1 deletion src/Bounce/Service/Handler/DeleteUserAndBounceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpList\Core\Bounce\Service\Manager\BounceManager;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberManager;
use PhpList\Core\Domain\Messaging\Model\BounceAction;

class DeleteUserAndBounceHandler implements BounceActionHandlerInterface
{
Expand All @@ -20,7 +21,7 @@ public function __construct(BounceManager $bounceManager, SubscriberManager $sub

public function supports(string $action): bool
{
return $action === 'deleteuserandbounce';
return $action === BounceAction::DeleteUserAndBounce->value;
}

public function handle(array $closureData): void
Expand Down
3 changes: 2 additions & 1 deletion src/Bounce/Service/Handler/DeleteUserHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\Core\Bounce\Service\Handler;

use PhpList\Core\Domain\Messaging\Model\BounceAction;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberManager;
use Psr\Log\LoggerInterface;

Expand All @@ -20,7 +21,7 @@ public function __construct(SubscriberManager $subscriberManager, LoggerInterfac

public function supports(string $action): bool
{
return $action === 'deleteuser';
return $action === BounceAction::DeleteUser->value;
}

public function handle(array $closureData): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PhpList\Core\Bounce\Service\Handler;

use PhpList\Core\Bounce\Service\Manager\BounceManager;
use PhpList\Core\Domain\Messaging\Model\BounceAction;
use PhpList\Core\Domain\Subscription\Repository\SubscriberRepository;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -30,7 +31,7 @@ public function __construct(

public function supports(string $action): bool
{
return $action === 'unconfirmuseranddeletebounce';
return $action === BounceAction::UnconfirmUserAndDeleteBounce->value;
}

public function handle(array $closureData): void
Expand Down
3 changes: 2 additions & 1 deletion src/Bounce/Service/Handler/UnconfirmUserHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\Core\Bounce\Service\Handler;

use PhpList\Core\Domain\Messaging\Model\BounceAction;
use PhpList\Core\Domain\Subscription\Repository\SubscriberRepository;
use PhpList\Core\Domain\Subscription\Service\Manager\SubscriberHistoryManager;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -26,7 +27,7 @@ public function __construct(

public function supports(string $action): bool
{
return $action === 'unconfirmuser';
return $action === BounceAction::UnconfirmUser->value;
}

public function handle(array $closureData): void
Expand Down
26 changes: 9 additions & 17 deletions src/Bounce/Service/Manager/BounceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,13 @@

class BounceManager
{
private BounceRepository $bounceRepository;
private UserMessageBounceRepository $userMessageBounceRepo;
private EntityManagerInterface $entityManager;
private LoggerInterface $logger;
private TranslatorInterface $translator;

public function __construct(
BounceRepository $bounceRepository,
UserMessageBounceRepository $userMessageBounceRepo,
EntityManagerInterface $entityManager,
LoggerInterface $logger,
TranslatorInterface $translator,
private readonly BounceRepository $bounceRepository,
private readonly UserMessageBounceRepository $userMessageBounceRepo,
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger,
private readonly TranslatorInterface $translator,
) {
$this->bounceRepository = $bounceRepository;
$this->userMessageBounceRepo = $userMessageBounceRepo;
$this->entityManager = $entityManager;
$this->logger = $logger;
$this->translator = $translator;
}

public function create(
Expand Down Expand Up @@ -93,7 +82,10 @@ public function linkUserMessageBounce(
int $subscriberId,
?int $messageId = -1
): UserMessageBounce {
$userMessageBounce = new UserMessageBounce($bounce->getId(), new DateTime($date->format('Y-m-d H:i:s')));
$userMessageBounce = new UserMessageBounce(
bounceId: $bounce->getId(),
createdAt: new DateTime($date->format('Y-m-d H:i:s'))
);
$userMessageBounce->setUserId($subscriberId);
$userMessageBounce->setMessageId($messageId);

Expand Down
16 changes: 15 additions & 1 deletion src/DependencyInjection/PhpListCoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,26 @@

class PhpListCoreExtension extends Extension
{
private array $configFiles = [
'builders.yml',
'commands.yml',
'managers.yml',
'mappers.yml',
'messengers.yml',
'processors.yml',
'providers.yml',
'repositories.yml',
'resolvers.yml',
'services.yml',
'validators.yml',
];

public function load(array $configs, ContainerBuilder $container): void
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../config/services'));

// Load core service definitions if present (keep optional to avoid breaking consumers)
foreach (['services.yml', 'builders.yml', 'managers.yml'] as $file) {
foreach ($this->configFiles as $file) {
$path = __DIR__ . '/../../config/services/' . $file;
if (is_file($path) && is_readable($path)) {
$loader->load($file);
Expand Down
Loading
Loading