Skip to main content
Corrected a typo 'batch_rediect' => 'batch_redirect'
Source Link

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback:

public static function finished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

As far as I can tell this is an undocumented behavior.

From the helpful comment below, you can also add batch_rediectbatch_redirect on the batch array that's either a string or Url object:

$batch = [ 'title' => $this->t('job running'), 'init_message' => $this->t('starting job'), 'operations' => $ops, 'finished' => '\Drupal\my_module\MyClass::finished', 'batch_rediect''batch_redirect' => '/job/results', ]; 

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback:

public static function finished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

As far as I can tell this is an undocumented behavior.

From the helpful comment below, you can also batch_rediect on the batch array that's either a string or Url object:

$batch = [ 'title' => $this->t('job running'), 'init_message' => $this->t('starting job'), 'operations' => $ops, 'finished' => '\Drupal\my_module\MyClass::finished', 'batch_rediect' => '/job/results', ]; 

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback:

public static function finished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

As far as I can tell this is an undocumented behavior.

From the helpful comment below, you can also add batch_redirect on the batch array that's either a string or Url object:

$batch = [ 'title' => $this->t('job running'), 'init_message' => $this->t('starting job'), 'operations' => $ops, 'finished' => '\Drupal\my_module\MyClass::finished', 'batch_redirect' => '/job/results', ]; 
Added alternate solution from comments
Source Link
acrosman
  • 2.7k
  • 21
  • 33

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback:

public static function finished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

As far as I can tell this is an undocumented behavior.

From the helpful comment below, you can also batch_rediect on the batch array that's either a string or Url object:

$batch = [ 'title' => $this->t('job running'), 'init_message' => $this->t('starting job'), 'operations' => $ops, 'finished' => '\Drupal\my_module\MyClass::finished', 'batch_rediect' => '/job/results', ]; 

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback:

public static function finished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

As far as I can tell this is an undocumented behavior.

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback:

public static function finished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

As far as I can tell this is an undocumented behavior.

From the helpful comment below, you can also batch_rediect on the batch array that's either a string or Url object:

$batch = [ 'title' => $this->t('job running'), 'init_message' => $this->t('starting job'), 'operations' => $ops, 'finished' => '\Drupal\my_module\MyClass::finished', 'batch_rediect' => '/job/results', ]; 
edited to match question better.
Source Link
acrosman
  • 2.7k
  • 21
  • 33

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback.:

public static function scanFinishedfinished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

As far as I can tell this is an undocumented behavior.

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback.

public static function scanFinished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

Apparently I needed to ask to see the answer: return a RedirectResponse from the finish callback:

public static function finished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. $message = t("@count tasks were done.", array( '@count' => count($results), )); drupal_set_message($message); } return new RedirectResponse('/job/results'); } 

As far as I can tell this is an undocumented behavior.

Source Link
acrosman
  • 2.7k
  • 21
  • 33
Loading