Skip to content

Commit b0caf80

Browse files
committed
Fix configs
1 parent f9a7a3c commit b0caf80

File tree

9 files changed

+108
-92
lines changed

9 files changed

+108
-92
lines changed

config/parameters.yml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ parameters:
2121
env(PHPLIST_DATABASE_USER): 'phplist'
2222
database_password: '%%env(PHPLIST_DATABASE_PASSWORD)%%'
2323
env(PHPLIST_DATABASE_PASSWORD): 'phplist'
24+
database_prefix: '%%env(DATABASE_PREFIX)%%'
25+
env(DATABASE_PREFIX): 'phplist_'
2426

2527
# Email configuration
2628
app.mailer_from: '%%env(MAILER_FROM)%%'

config/services/providers.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ services:
1313
arguments:
1414
$confPath: '%app.phplist_isp_conf_path%'
1515

16-
PhpList\Core\Domain\Subscription\Service\Provider\CheckboxGroupValueProvider: ~
17-
PhpList\Core\Domain\Subscription\Service\Provider\SelectOrRadioValueProvider: ~
18-
PhpList\Core\Domain\Subscription\Service\Provider\ScalarValueProvider: ~
16+
PhpList\Core\Domain\Subscription\Service\Provider\CheckboxGroupValueProvider:
17+
autowire: true
18+
PhpList\Core\Domain\Subscription\Service\Provider\SelectOrRadioValueProvider:
19+
autowire: true
20+
PhpList\Core\Domain\Subscription\Service\Provider\ScalarValueProvider:
21+
autowire: true
1922

2023
PhpList\Core\Domain\Configuration\Service\Provider\DefaultConfigProvider:
21-
calls:
22-
- [ setTranslator, [ '@translator' ] ]
24+
autowire: true
2325

2426
PhpList\Core\Domain\Configuration\Service\Provider\ConfigProvider:
27+
autowire: true
28+
arguments:
29+
$cache: '@Psr\SimpleCache\CacheInterface'

config/services/repositories.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ services:
6868
arguments:
6969
- PhpList\Core\Domain\Subscription\Model\Subscription
7070
PhpList\Core\Domain\Subscription\Repository\DynamicListAttrRepository:
71+
autowire: true
7172
arguments:
72-
$prefix: '%env(default:phplist_ DATABASE_PREFIX)%'
73+
$prefix: '%database_prefix%'
7374
PhpList\Core\Domain\Subscription\Repository\SubscriberHistoryRepository:
7475
parent: PhpList\Core\Domain\Common\Repository\AbstractRepository
7576
arguments:

config/services/services.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,9 @@ services:
132132
PhpList\Core\Domain\Configuration\Service\LegacyUrlBuilder:
133133
autowire: true
134134
autoconfigure: true
135+
136+
cache.app.simple:
137+
class: Symfony\Component\Cache\Psr16Cache
138+
arguments: [ '@cache.app' ]
139+
140+
Psr\SimpleCache\CacheInterface: '@cache.app.simple'

src/Domain/Configuration/Repository/ConfigRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ class ConfigRepository extends AbstractRepository
1010
{
1111
public function findValueByItem(string $name): ?string
1212
{
13-
return $this->findOneBy(['item' => $name])?->getValue();
13+
return $this->findOneBy(['key' => $name])?->getValue();
1414
}
1515
}

src/Domain/Configuration/Service/Provider/ConfigProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class ConfigProvider
1818
public function __construct(
1919
private readonly ConfigRepository $configRepository,
2020
private readonly CacheInterface $cache,
21-
private readonly int $ttlSeconds = 300
21+
private readonly DefaultConfigProvider $defaultConfigs,
22+
private readonly ?int $ttlSeconds = 300
2223
) {
2324
}
2425

@@ -37,7 +38,7 @@ public function isEnabled(ConfigOption $key): bool
3738
$config->getValue() === '1';
3839
}
3940

40-
return DefaultConfigProvider::has($key->value) && DefaultConfigProvider::get($key->value) === '1';
41+
return $this->defaultConfigs->has($key->value) && $this->defaultConfigs->get($key->value)['value'] === '1';
4142
}
4243

4344
/**
@@ -61,7 +62,7 @@ public function getValue(ConfigOption $key): ?string
6162
return $value;
6263
}
6364

64-
return DefaultConfigProvider::has($key->value) ? DefaultConfigProvider::get($key->value) : null;
65+
return $this->defaultConfigs->has($key->value) ? $this->defaultConfigs->get($key->value)['value'] : null;
6566
}
6667

6768
/** @SuppressWarnings(PHPMD.StaticAccess) */

src/Domain/Configuration/Service/Provider/DefaultConfigProvider.php

Lines changed: 80 additions & 77 deletions
Large diffs are not rendered by default.

src/Domain/Subscription/Repository/DynamicListAttrRepository.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
use Doctrine\DBAL\ArrayParameterType;
88
use Doctrine\DBAL\Connection;
9-
use Doctrine\DBAL\Exception;
109
use InvalidArgumentException;
11-
use PhpList\Core\Domain\Common\Model\Interfaces\DomainModel;
1210

1311
class DynamicListAttrRepository
1412
{

tests/Integration/Domain/Subscription/Service/SubscriberCsvImportManagerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function testImportFromCsvCreatesNewSubscribers(): void
4242
$this->entityManager->flush();
4343

4444
$csvContent = "email,confirmed,html_email,blacklisted,disabled,extra_data,first_name\n";
45-
$csvContent .= "test@example.com,1,1,0,0,\"Some extra data\",John\n";
46-
$csvContent .= "another@example.com,0,0,1,1,\"More data\",Jane\n";
45+
$csvContent .= "test1@example.com,1,1,0,0,\"Some extra data\",John\n";
46+
$csvContent .= "another1@example.com,0,0,1,1,\"More data\",Jane\n";
4747

4848
$tempFile = tempnam(sys_get_temp_dir(), 'csv_test');
4949
file_put_contents($tempFile, $csvContent);
@@ -58,7 +58,7 @@ public function testImportFromCsvCreatesNewSubscribers(): void
5858

5959
$subscriberCountBefore = count($this->subscriberRepository->findAll());
6060

61-
$options = new SubscriberImportOptions();
61+
$options = new SubscriberImportOptions(true);
6262
$result = $this->subscriberCsvImportManager->importFromCsv($uploadedFile, $options);
6363

6464
$subscriberCountAfter = count($this->subscriberRepository->findAll());

0 commit comments

Comments
 (0)