3 namespace Drupal\system;
5 use Drupal\Core\Controller\ControllerBase;
6 use Drupal\Core\CronInterface;
7 use Symfony\Component\DependencyInjection\ContainerInterface;
8 use Symfony\Component\HttpFoundation\Response;
11 * Controller for Cron handling.
13 class CronController extends ControllerBase {
18 * @var \Drupal\Core\CronInterface
23 * Constructs a CronController object.
25 * @param \Drupal\Core\CronInterface $cron
28 public function __construct(CronInterface $cron) {
35 public static function create(ContainerInterface $container) {
36 return new static($container->get('cron'));
43 * @return \Symfony\Component\HttpFoundation\Response
44 * A Symfony response object.
46 public function run() {
49 // HTTP 204 is "No content", meaning "I did what you asked and we're done."
50 return new Response('', 204);
56 * @return \Symfony\Component\HttpFoundation\RedirectResponse
57 * A Symfony direct response object.
59 public function runManually() {
60 if ($this->cron->run()) {
61 drupal_set_message($this->t('Cron ran successfully.'));
64 drupal_set_message($this->t('Cron run failed.'), 'error');
67 return $this->redirect('system.status');