Skip to content

Commit 6b497ed

Browse files
feat: add FroshTools integration
1 parent 4a3e01c commit 6b497ed

4 files changed

Lines changed: 69 additions & 19 deletions

File tree

src/FroshFlowBuilder.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22

33
namespace Frosh\FlowBuilder;
44

5+
use Frosh\FlowBuilder\FroshTools\Checker\FlowExecutionErrorChecker;
6+
use Frosh\Tools\Components\Health\Checker\CheckerInterface;
57
use Shopware\Core\Framework\Plugin;
6-
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
7-
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
8-
use Shopware\Core\Framework\Plugin\Context\InstallContext;
9-
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
10-
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
8+
use Symfony\Component\DependencyInjection\ContainerBuilder;
9+
use Symfony\Component\DependencyInjection\Definition;
1110

1211
class FroshFlowBuilder extends Plugin
1312
{
13+
public function build(ContainerBuilder $container): void
14+
{
15+
parent::build($container);
16+
17+
if (interface_exists(CheckerInterface::class)) {
18+
$definition = new Definition(FlowExecutionErrorChecker::class);
19+
$definition->setAutowired(true);
20+
$definition->setAutoconfigured(true);
21+
22+
$container->setDefinition(FlowExecutionErrorChecker::class, $definition);
23+
}
24+
}
1425
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Frosh\FlowBuilder\FroshTools\Checker;
4+
5+
use Doctrine\DBAL\Connection;
6+
use Frosh\FlowBuilder\Subscriber\FlowSubscriber;
7+
use Frosh\Tools\Components\Health\Checker\CheckerInterface;
8+
use Frosh\Tools\Components\Health\Checker\HealthChecker\HealthCheckerInterface;
9+
use Frosh\Tools\Components\Health\HealthCollection;
10+
use Frosh\Tools\Components\Health\SettingsResult;
11+
12+
class FlowExecutionErrorChecker implements CheckerInterface, HealthCheckerInterface
13+
{
14+
15+
public function __construct(
16+
private readonly Connection $connection,
17+
)
18+
{
19+
}
20+
21+
public function collect(HealthCollection $collection): void
22+
{
23+
$numberOfFailedFlows = $this->connection->fetchOne('SELECT COUNT(*) FROM frosh_flow_state WHERE state = :errorState LIMIT 1;', [
24+
'errorState' => FlowSubscriber::FLOW_STATE_ERROR
25+
]);
26+
27+
if ($numberOfFailedFlows > 0) {
28+
$collection->add(
29+
SettingsResult::warning(
30+
'flow-execution-failed',
31+
'Some flow executions have failed',
32+
$numberOfFailedFlows,
33+
0
34+
)
35+
);
36+
}
37+
}
38+
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"frosh-flow-builder": {
3-
"history": {
4-
"tabTitle": "Verlauf",
5-
"cardTitle": "Verlauf",
6-
"columns": {
7-
"executedAt": "Ausgeführt am",
8-
"status": "Status",
9-
"triggeredBy": "Ausgelöst von"
10-
},
11-
"state": {
12-
"success": "Erfolgreich",
13-
"error": "Fehlgeschlagen"
14-
}
15-
}
2+
"frosh-flow-builder": {
3+
"history": {
4+
"tabTitle": "Verlauf",
5+
"cardTitle": "Verlauf",
6+
"columns": {
7+
"executedAt": "Ausgeführt am",
8+
"status": "Status",
9+
"triggeredBy": "Ausgelöst von"
10+
},
11+
"state": {
12+
"success": "Erfolgreich",
13+
"error": "Fehlgeschlagen"
14+
}
1615
}
16+
}
1717
}

src/Resources/config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<prototype
1010
namespace="Frosh\FlowBuilder\"
1111
resource="../../"
12+
exclude="../../FroshTools/"
1213
/>
1314
</services>
1415
</container>

0 commit comments

Comments
 (0)