Skip to content

Commit c1c0bf9

Browse files
feat: add translation of cronExpression (#143)
Co-authored-by: Christopher Georg <[email protected]>
1 parent adf7f81 commit c1c0bf9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Entity/ScheduledCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\DBAL\Types\Types;
88
use Doctrine\ORM\Mapping as ORM;
99
use Dukecity\CommandSchedulerBundle\Repository\ScheduledCommandRepository;
10+
use Lorisleiva\CronTranslator\CronTranslator;
1011
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
1112
use Symfony\Component\Validator\Constraints as Assert;
1213
use Dukecity\CommandSchedulerBundle\Validator\Constraints as AssertDukecity;
@@ -325,4 +326,13 @@ public function getNextRunDate(bool $checkExecuteImmediately = true): ?DateTime
325326

326327
return (new CronExpressionLib($this->getCronExpression()))->getNextRunDate();
327328
}
329+
330+
public function getCronExpressionTranslated(): string
331+
{
332+
try{
333+
return CronTranslator::translate($this->getCronExpression());
334+
}
335+
catch(\Exception $e)
336+
{return 'error: could not translate cron expression';}
337+
}
328338
}

Resources/views/List/index.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
{{ command.command }} {{ command.arguments }}
5656
</td>
5757
<td>
58-
{{ command.cronExpression }}
58+
<span title="{{ command.getCronExpressionTranslated() }}">{{ command.cronExpression }}</span>
5959
</td>
6060
<td>
6161
{{ command.logFile }}

0 commit comments

Comments
 (0)