Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
namespace Drupal\sitemanager\Plugin\TaskPlugin;
use Drupal\sitemanager\Plugin\TaskPluginBase;
/**
* Class RunCron.
*
* @package Drupal\sitemanager\Plugin\TaskPlugin
*
* @SMTaskPlugin(
* id = "run_cron",
* taskName = @Translation("Run Cron"),
* status = "Waiting",
* )
*/
class RunCron extends TaskPluginBase {
public function run($site) {
$path = $site->getFullSystemPath();
$response = $this->processService->run('drush cron', $path);
if ($response['status'] == 'Error') {
$this->output = [
'#type' => 'markup',
'#markup' => $this->t('Error running cron'),
];
$this->pluginDefinition['status'] = 'Error';
}
else {
$this->output = [
'#type' => 'markup',
'#markup' => $this->t('Cron run complete'),
];
$this->pluginDefinition['status'] = 'Success';
}
return $this->getTaskStatus();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment