2 Commits
main ... test

Author SHA1 Message Date
617d2e517b Merge branch 'refs/heads/main' into test 2023-05-31 16:00:30 +01:00
d9f3136cd9 Test task 2022-05-19 16:45:56 +01:00
7 changed files with 47 additions and 44 deletions

View File

@@ -1,35 +1,3 @@
# sprinkle-scheduler
A UserFrosting sprinkle to add scheduled events.
Either a crontab set to run once a minute is required or a systemd timer:
Systemd service: /etc/systemd/system/uf-scheduler.service
```systemd
[Unit]
Description=UserFrosting Scheduler
[Service]
Restart=no
Type=simple
ExecStart=/usr/bin/php bakery schedule -n
WorkingDirectory=/srv/UserFrosting
User=www-data
Group=www-data
[Install]
WantedBy=multi-user.target
```
Systemd timer: /etc/systemd/system/uf-scheduler.timer
```systemd
[Unit]
Description=UserFrosting Scheduler trigger
[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true
Unit=uf-scheduler.service
[Install]
WantedBy=multi-user.target
```
A UserFrosting sprinkle to add scheduled events

View File

@@ -107,4 +107,4 @@ class TaskController extends SimpleController
'tasks' => $tasks
]);
}
}
}

View File

@@ -0,0 +1,38 @@
<?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\Scheduler\Tasks;
use UserFrosting\Sprinkle\Scheduler\Scheduler\BaseTask;
/**
* Task Class
* Base class for scheduled tasks.
*
* @author Craig Williams (https://avsdev.uk)
*/
class TestTask extends BaseTask
{
/**
* Function used to specify the schedule for the task.
*/
public function schedule()
{
$this->everyMinute();
}
/**
* Function used to specify what the task does.
*/
public function run()
{
$this->ci->debugLogger->debug("running task");
return true;
}
}

View File

@@ -50,9 +50,7 @@ class ServicesProvider
$container->extend('view', function ($view, $c) {
$twig = $view->getEnvironment();
if (!$twig->hasExtension('Twig\Extra\Intl\IntlExtension')) {
$twig->addExtension(new IntlExtension());
}
$twig->addExtension(new IntlExtension());
$twig->addExtension(new FormatCronExtension($c));
return $view;

View File

@@ -57,7 +57,7 @@ class FormatCronExtension extends AbstractExtension implements GlobalsInterface
];
}
public function getGlobals(): array
public function getGlobals()
{
return [];
}

View File

@@ -1,5 +0,0 @@
{% if checkAccess('uri_tasks') %}
<li>
<a href="{{site.uri.public}}/tasks"><i class="fas fa-tasks fa-fw"></i> <span>{{ translate("TASK", 2) }}</span></a>
</li>
{% endif %}

View File

@@ -2,5 +2,9 @@
{% block navigation %}
{{ parent() }}
{% include "navigation/partials/sidebar-tasks.html.twig" %}
{% if checkAccess('uri_tasks') %}
<li>
<a href="{{site.uri.public}}/tasks"><i class="fas fa-tasks fa-fw"></i> <span>{{ translate("TASK", 2) }}</span></a>
</li>
{% endif %}
{% endblock %}