Skip to content

Commit 12c65e0

Browse files
committed
SubscribePageManager
1 parent c11015e commit 12c65e0

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

resources/translations/messages.en.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@
404404
<target>Another attribute with this name already exists.</target>
405405
</trans-unit>
406406

407+
<trans-unit id="subscription.subscriber_page_not_found">
408+
<source>Subscribe page not found</source>
409+
<target>Subscribe page not found</target>
410+
</trans-unit>
411+
407412
</body>
408413
</file>
409414
</xliff>

src/Domain/Subscription/Service/Manager/SubscribePageManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
use PhpList\Core\Domain\Subscription\Repository\SubscriberPageDataRepository;
1212
use PhpList\Core\Domain\Subscription\Repository\SubscriberPageRepository;
1313
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
14+
use Symfony\Contracts\Translation\TranslatorInterface;
1415

1516
class SubscribePageManager
1617
{
1718
public function __construct(
1819
private readonly SubscriberPageRepository $pageRepository,
1920
private readonly SubscriberPageDataRepository $pageDataRepository,
2021
private readonly EntityManagerInterface $entityManager,
22+
private readonly TranslatorInterface $translator,
2123
) {
2224
}
2325

@@ -41,7 +43,7 @@ public function getPage(int $id): SubscribePage
4143
/** @var SubscribePage|null $page */
4244
$page = $this->pageRepository->find($id);
4345
if (!$page) {
44-
throw new NotFoundHttpException('Subscribe page not found');
46+
throw new NotFoundHttpException($this->translator->trans('Subscribe page not found'));
4547
}
4648

4749
return $page;

tests/Unit/Domain/Subscription/Service/Manager/SubscribePageManagerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\MockObject\MockObject;
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
17+
use Symfony\Component\Translation\Translator;
1718

1819
class SubscribePageManagerTest extends TestCase
1920
{
@@ -32,6 +33,7 @@ protected function setUp(): void
3233
pageRepository: $this->pageRepository,
3334
pageDataRepository: $this->pageDataRepository,
3435
entityManager: $this->entityManager,
36+
translator: new Translator('en'),
3537
);
3638
}
3739

0 commit comments

Comments
 (0)