Skip to content

ISSUE-345 #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"symfony/validator": "^6.4",
"doctrine/doctrine-fixtures-bundle": "^3.7",
"doctrine/instantiator": "^2.0",
"masterminds/html5": "^2.9"
"masterminds/html5": "^2.9",
"ext-dom": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand Down
1 change: 0 additions & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
imports:
- { resource: services.yml }
- { resource: repositories.yml }
- { resource: doctrine.yml }

# Put parameters here that don't need to change on each machine where the app is deployed
Expand Down
8 changes: 4 additions & 4 deletions config/doctrine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ doctrine:
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
auto_mapping: false
mappings:
PhpList\Core\Domain\Model:
Identity:
is_bundle: false
type: attribute
dir: '%kernel.project_dir%/src/Domain/Model/'
prefix: 'PhpList\Core\Domain\Model\'
dir: '%kernel.project_dir%/src/Domain/Identity/Model'
prefix: 'PhpList\Core\Domain\Identity\Model'
controller_resolver:
auto_mapping: false
10 changes: 10 additions & 0 deletions config/packages/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
app:
config:
message_from_address: '[email protected]'
admin_address: '[email protected]'
default_message_age: 15768000
message_footer: 'Thanks for reading'
forward_footer: 'Forwarded message'
notify_start_default: '[email protected]'
notify_end_default: '[email protected]'
always_add_google_tracking: true
42 changes: 0 additions & 42 deletions config/repositories.yml

This file was deleted.

14 changes: 8 additions & 6 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
imports:
- { resource: 'services/*.yml' }

services:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: true
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: false

PhpList\Core\Core\ConfigProvider:
arguments:
$config: '%app.config%'

PhpList\Core\Core\ApplicationStructure:
public: true

Expand All @@ -21,7 +23,7 @@ services:
PhpList\Core\Routing\ExtraLoader:
tags: [routing.loader]

PhpList\Core\Domain\Repository:
PhpList\Core\Domain\Common\Repository\AbstractRepository:
abstract: true
autowire: true
autoconfigure: false
Expand Down
25 changes: 25 additions & 0 deletions config/services/builders.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

PhpList\Core\Domain\Messaging\Service\Builder\MessageBuilder:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\Builder\MessageFormatBuilder:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\Builder\MessageScheduleBuilder:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\Builder\MessageContentBuilder:
autowire: true
autoconfigure: true

PhpListPhpList\Core\Domain\Messaging\Service\Builder\MessageOptionsBuilder:
autowire: true
autoconfigure: true
63 changes: 63 additions & 0 deletions config/services/managers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

PhpList\Core\Domain\Subscription\Service\SubscriberManager:
autowire: true
autoconfigure: true

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

PhpList\Core\Domain\Subscription\Service\SubscriberListManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Subscription\Service\SubscriptionManager:
autowire: true
autoconfigure: true

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

PhpList\Core\Domain\Messaging\Service\TemplateManager:
autowire: true
autoconfigure: true

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

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

PhpList\Core\Domain\Identity\Service\AdminAttributeDefinitionManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Identity\Service\AdminAttributeManager:
autowire: true
autoconfigure: true

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

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

PhpList\Core\Domain\Subscription\Service\SubscriberCsvExportManager:
autowire: true
autoconfigure: true
public: true

PhpList\Core\Domain\Subscription\Service\SubscriberCsvImportManager:
autowire: true
autoconfigure: true
public: true
62 changes: 62 additions & 0 deletions config/services/repositories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
services:
PhpList\Core\Domain\Identity\Repository\AdministratorRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Identity\Model\Administrator
- Doctrine\ORM\Mapping\ClassMetadata\ClassMetadata
- PhpList\Core\Security\HashGenerator

PhpList\Core\Domain\Identity\Repository\AdminAttributeValueRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Identity\Model\AdminAttributeValue

PhpList\Core\Domain\Identity\Repository\AdminAttributeDefinitionRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Identity\Model\AdminAttributeDefinition

PhpList\Core\Domain\Identity\Repository\AdministratorTokenRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Identity\Model\AdministratorToken

PhpList\Core\Domain\Subscription\Repository\SubscriberListRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Subscription\Model\SubscriberList

PhpList\Core\Domain\Subscription\Repository\SubscriberRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Subscription\Model\Subscriber

PhpList\Core\Domain\Subscription\Repository\SubscriberAttributeValueRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Subscription\Model\SubscriberAttributeValue

PhpList\Core\Domain\Subscription\Repository\SubscriberAttributeDefinitionRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Subscription\Model\SubscriberAttributeDefinition

PhpList\Core\Domain\Subscription\Repository\SubscriptionRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Subscription\Model\Subscription

PhpList\Core\Domain\Messaging\Repository\MessageRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Messaging\Model\Message

PhpList\Core\Domain\Messaging\Repository\TemplateRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Messaging\Model\Template

PhpList\Core\Domain\Messaging\Repository\TemplateImageRepository:
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
arguments:
- PhpList\Core\Domain\Messaging\Model\TemplateImage
8 changes: 8 additions & 0 deletions config/services/validators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
PhpList\Core\Domain\Messaging\Validator\TemplateLinkValidator:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Validator\TemplateImageValidator:
autowire: true
autoconfigure: true
1 change: 1 addition & 0 deletions src/Core/ApplicationKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private function getAndCreateApplicationStructure(): ApplicationStructure
protected function build(ContainerBuilder $container): void
{
$container->setParameter('kernel.application_dir', $this->getApplicationDir());
$container->addCompilerPass(new DoctrineMappingPass());
}

/**
Expand Down
22 changes: 22 additions & 0 deletions src/Core/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Core;

class ConfigProvider
{
public function __construct(private readonly array $config)
{
}

public function get(string $key, mixed $default = null): mixed
{
return $this->config[$key] ?? $default;
}

public function all(): array
{
return $this->config;
}
}
45 changes: 45 additions & 0 deletions src/Core/DoctrineMappingPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace PhpList\Core\Core;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class DoctrineMappingPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$projectDir = $container->getParameter('kernel.project_dir');
$basePath = $projectDir . '/src/Domain';

$driverDefinition = $container->getDefinition('doctrine.orm.default_metadata_driver');

foreach (scandir($basePath) as $dir) {
if ($dir === '.' || $dir === '..') {
continue;
}

$modelPath = $basePath . '/' . $dir . '/Model';
if (!is_dir($modelPath)) {
continue;
}

$namespace = 'PhpList\\Core\\Domain\\' . $dir . '\\Model';

$attributeDriverDef = new Definition(AttributeDriver::class, [[$modelPath]]);
$attributeDriverId = 'doctrine.orm.driver.' . $dir;

$container->setDefinition($attributeDriverId, $attributeDriverDef);

$driverDefinition->addMethodCall('addDriver', [
new Reference($attributeDriverId),
$namespace,
]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace PhpList\Core\Domain\Model\Analytics;
namespace PhpList\Core\Domain\Analytics\Model;

use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use PhpList\Core\Domain\Model\Interfaces\DomainModel;
use PhpList\Core\Domain\Model\Interfaces\Identity;
use PhpList\Core\Domain\Repository\Analytics\LinkTrackRepository;
use PhpList\Core\Domain\Analytics\Repository\LinkTrackRepository;
use PhpList\Core\Domain\Common\Model\Interfaces\DomainModel;
use PhpList\Core\Domain\Common\Model\Interfaces\Identity;

#[ORM\Entity(repositoryClass: LinkTrackRepository::class)]
#[ORM\Table(name: 'phplist_linktrack')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace PhpList\Core\Domain\Model\Analytics;
namespace PhpList\Core\Domain\Analytics\Model;

use Doctrine\ORM\Mapping as ORM;
use PhpList\Core\Domain\Model\Interfaces\DomainModel;
use PhpList\Core\Domain\Model\Interfaces\Identity;
use PhpList\Core\Domain\Repository\Analytics\LinkTrackForwardRepository;
use PhpList\Core\Domain\Analytics\Repository\LinkTrackForwardRepository;
use PhpList\Core\Domain\Common\Model\Interfaces\DomainModel;
use PhpList\Core\Domain\Common\Model\Interfaces\Identity;

#[ORM\Entity(repositoryClass: LinkTrackForwardRepository::class)]
#[ORM\Table(name: 'phplist_linktrack_forward')]
Expand Down
Loading
Loading