diff --git a/docs/en/configuration.md b/docs/en/configuration.md index 5cf89a5c..312f837a 100644 --- a/docs/en/configuration.md +++ b/docs/en/configuration.md @@ -7,22 +7,24 @@ In order to apply workflow to other classes (e.g. `MyObject`), you need to apply it to both the model class and the controller which is used for editing it. Here's an example for `MyObject` which is managed through a `MyObjectAdmin` controller, -extending from `ModelAdmin`. `mysite/_config/config.yml`: - - :::yml - MyObject: - extensions: - - WorkflowApplicable - MyObjectAdmin: - extensions: - - AdvancedWorkflowExtension - -We strongly recommend also setting the `NotifyUsersWorkflowAction` configuration parameter `whitelist_template_variables` +extending from `ModelAdmin`. `app/_config/config.yml`: + +```yml +MyObject: + extensions: + - Symbiote\AdvancedWorkflow\Extensions\WorkflowApplicable +MyObjectAdmin: + extensions: + - Symbiote\AdvancedWorkflow\Extensions\AdvancedWorkflowExtension +``` + +We strongly recommend also setting the `NotifyUsersWorkflowAction` configuration parameter `whitelist_template_variables` to true on new projects. This configuration will achieve this: - :::yml - NotifyUsersWorkflowAction: - whitelist_template_variables: true +```yml +Symbiote\AdvancedWorkflow\Actions\NotifyUsersWorkflowAction: + whitelist_template_variables: true +``` See the Security section below for more details. @@ -30,17 +32,20 @@ See the Security section below for more details. This add-on functionality allows you to embargo some content changes to only appear as published at some future date. To enable it, add the `WorkflowEmbargoExpiryExtension`. - :::yml - SiteTree: - extensions: - - WorkflowEmbargoExpiryExtension +```yml +SilverStripe\CMS\Model\SiteTree: + extensions: + - Symbiote\AdvancedWorkflow\Extensions\WorkflowEmbargoExpiryExtension +``` -Make sure the [QueuedJobs](https://github.com/nyeholt/silverstripe-queuedjobs) +Make sure the [QueuedJobs](https://github.com/nyeholt/silverstripe-queuedjobs) module is installed and configured correctly. -You should have a cronjob similar to the following in place, running +You should have a cronjob similar to the following in place, running as the webserver user. - */1 * * * * cd && sudo -u www php /var/www/framework/cli-script.php dev/tasks/ProcessJobQueueTask +```sh +*/1 * * * * cd && sudo -u www php /var/www/vendor/bin/sake tasks:ProcessJobQueueTask +``` It also allows for an optional subsequent expiry date. Note: Changes to these dates also constitute modifications to the content and as such are subject to the same workflow approval processes, where a particular workflow instance is in effect. The embargo export functionality can also be used independently of any workflow. @@ -52,9 +57,11 @@ than a couple of days (configurable in each "Workflow Definition" through the CM Periodically run the Workflow Reminder Task by adding a task like this one to the crontab: - # Check every minute if someone needs to be reminded about pending workflows - */1 * * * * cd /var/www && sudo -u www ./sapphire/sake dev/tasks/WorkflowReminderTask +```sh +# Check every minute if someone needs to be reminded about pending workflows +*/1 * * * * cd /var/www && sudo -u www vendor/bin/sake tasks:WorkflowReminderTask +``` This is an example only. The key is to run the task as the same user as the web server. -You can run the task manually for testing by visiting the `/dev/tasks/WorkflowReminderTask` URL of your site. \ No newline at end of file +You can run the task manually for testing by visiting the `/dev/tasks/WorkflowReminderTask` URL of your site. diff --git a/src/Tasks/WorkflowReminderTask.php b/src/Tasks/WorkflowReminderTask.php index c32be378..0ce3e457 100644 --- a/src/Tasks/WorkflowReminderTask.php +++ b/src/Tasks/WorkflowReminderTask.php @@ -5,9 +5,11 @@ use SilverStripe\Dev\BuildTask; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Control\Email\Email; +use SilverStripe\PolyExecution\PolyOutput; use SilverStripe\ORM\FieldType\DBDatetime; -use Symbiote\AdvancedWorkflow\DataObjects\WorkflowDefinition; use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; /** * A task that sends a reminder email to users assigned to a workflow that has @@ -17,12 +19,13 @@ */ class WorkflowReminderTask extends BuildTask { - protected $title = 'Workflow Reminder Task'; - protected $description = 'Sends out workflow reminder emails to stale workflow instances'; + protected string $title = 'Workflow Reminder Task'; - private static $segment = 'WorkflowReminderTask'; + protected static string $description = 'Sends out workflow reminder emails to stale workflow instances'; - public function run($request) + protected static string $commandName = 'WorkflowReminderTask'; + + protected function execute(InputInterface $input, PolyOutput $output): int { $sent = 0; if (WorkflowInstance::get()->count()) { // Don't attempt the filter if no instances -- prevents a crash @@ -69,6 +72,7 @@ public function run($request) } } } - echo "Sent $sent workflow reminder emails.\n"; + $output->writeln("Sent $sent workflow reminder emails."); + return Command::SUCCESS; } }