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
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"shopware/core": "~6.6.0 || ~6.7.0",
"zbateson/mail-mime-parser": "^3.0"
},
"require-dev": {
"frosh/tools": ">2.0.0"
},
"config": {
"allow-plugins": {
"symfony/runtime": true
Expand Down
51 changes: 51 additions & 0 deletions src/Services/FroshToolsChecker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,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,

Check failure on line 43 in src/Services/FroshToolsChecker.php

View workflow job for this annotation

GitHub Actions / check (lowest)

phpstan/classConstant.private

Access to private constant GREEN of class Frosh\Tools\Components\Health\SettingsResult.

Check failure on line 43 in src/Services/FroshToolsChecker.php

View workflow job for this annotation

GitHub Actions / check (lowest)

phpstan/classConstant.private

Access to private constant ERROR of class Frosh\Tools\Components\Health\SettingsResult.
]);

$collection->add($result);
}
}
} else {
class FroshToolsChecker {}
}
Loading