-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathFroshToolsChecker.php
More file actions
51 lines (44 loc) · 1.99 KB
/
Copy pathFroshToolsChecker.php
File metadata and controls
51 lines (44 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Frosh\MailArchive\Services;
use Frosh\MailArchive\Content\MailArchive\MailArchiveEntity;
use Frosh\Tools\Components\Health\Checker\CheckerInterface;
use Frosh\Tools\Components\Health\HealthCollection;
use Frosh\Tools\Components\Health\SettingsResult;
use Shopware\Core\Framework\Api\Context\SystemSource;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
if (\interface_exists(CheckerInterface::class) &&
\class_exists(HealthCollection::class) &&
\class_exists(SettingsResult::class)) {
#[AutoconfigureTag('frosh_tools.health_checker')]
class FroshToolsChecker implements CheckerInterface
{
/**
* @param EntityRepository<EntityCollection<MailArchiveEntity>> $froshMailArchiveRepository
*/
public function __construct(
private readonly EntityRepository $froshMailArchiveRepository,
) {}
public function collect(HealthCollection $collection): void
{
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('transportState', MailSender::TRANSPORT_STATE_FAILED));
$count = $this->froshMailArchiveRepository->searchIds($criteria, new Context(new SystemSource()))->getTotal();
$result = new SettingsResult();
$result->assign([
'id' => 'frosh_mail_archive_failed',
'snippet' => 'Failed mails in MailArchive',
'current' => (string) $count,
'recommended' => '0',
'state' => $count === 0 ? SettingsResult::GREEN : SettingsResult::ERROR,
]);
$collection->add($result);
}
}
} else {
class FroshToolsChecker {}
}