Skip to content

Instantly share code, notes, and snippets.

@acrosman
Created January 8, 2017 19:20
Show Gist options
  • Save acrosman/fc5c8f6abed2d2efafdaed7fc8134a5e to your computer and use it in GitHub Desktop.
Save acrosman/fc5c8f6abed2d2efafdaed7fc8134a5e to your computer and use it in GitHub Desktop.
<?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