From e0e9ab8c28873d7c37b2f43033a87c10772efc0b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 26 Oct 2023 16:15:45 +0200 Subject: [PATCH] register_cron_aliases.php: Register cron aliases lazily --- src/register_cron_aliases.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/register_cron_aliases.php b/src/register_cron_aliases.php index 2987248..ca7c78d 100644 --- a/src/register_cron_aliases.php +++ b/src/register_cron_aliases.php @@ -2,10 +2,17 @@ use Cron\CronExpression; -if (! CronExpression::supportsAlias('@minutely')) { - CronExpression::registerAlias('@minutely', '* * * * *'); -} +$loader = function () use (&$loader) { + if (! CronExpression::supportsAlias('@minutely')) { + CronExpression::registerAlias('@minutely', '* * * * *'); + } -if (! CronExpression::supportsAlias('@quarterly')) { - CronExpression::registerAlias('@quarterly', '0 0 1 */3 *'); -} + if (! CronExpression::supportsAlias('@quarterly')) { + CronExpression::registerAlias('@quarterly', '0 0 1 */3 *'); + } + + spl_autoload_unregister($loader); + unset($loader); +}; + +spl_autoload_register($loader, true, true);