65 lines
1.4 KiB
PHP
65 lines
1.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* AVSDev UF Scheduler (https://avsdev.uk)
|
|
*
|
|
* @link https://git.avsdev.uk/avsdev/sprinkle-scheduler
|
|
* @license https://git.avsdev.uk/avsdev/sprinkle-scheduler/blob/master/LICENSE.md (LGPL-3.0 License)
|
|
*/
|
|
|
|
namespace UserFrosting\Sprinkle\Scheduler\Twig;
|
|
|
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
|
use Lorisleiva\CronTranslator\CronTranslator;
|
|
use Psr\Container\ContainerInterface;
|
|
use Twig\Extension\AbstractExtension;
|
|
use Twig\Extension\GlobalsInterface;
|
|
use Twig\TwigFilter;
|
|
use UserFrosting\Support\Repository\Repository as Config;
|
|
|
|
/**
|
|
* Extends Twig functionality to add formatCron.
|
|
*
|
|
* @author Craig Williams (https://avsdev.uk)
|
|
*/
|
|
class FormatCronExtension extends AbstractExtension implements GlobalsInterface
|
|
{
|
|
/**
|
|
* @var ContainerInterface
|
|
*/
|
|
protected $services;
|
|
|
|
/**
|
|
* @var Config
|
|
*/
|
|
protected $config;
|
|
|
|
/**
|
|
* @param ContainerInterface $services
|
|
*/
|
|
public function __construct(ContainerInterface $services)
|
|
{
|
|
$this->services = $services;
|
|
$this->config = $services->config;
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return 'avsdev/schedule-formatCron';
|
|
}
|
|
|
|
public function getFilters()
|
|
{
|
|
return [
|
|
new TwigFilter('formatCron', function ($cron) {
|
|
return CronTranslator::translate($cron);
|
|
}),
|
|
];
|
|
}
|
|
|
|
public function getGlobals()
|
|
{
|
|
return [];
|
|
}
|
|
}
|