tmgmt_ui.api.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file
  4. * API documentation file for Translation Management API.
  5. */
  6. /**
  7. * Allows to alter job checkout workflow before the default behavior kicks in.
  8. *
  9. * Note: The default behavior will ignore jobs that have already been checked
  10. * out. Remove jobs from the array to prevent the default behavior for them.
  11. *
  12. * @param $redirects
  13. * List of redirects the user is supposed to be redirected to.
  14. * @param $jobs
  15. * Array with the translation jobs to be checked out.
  16. */
  17. function hook_tmgmt_ui_job_checkout_before_alter(&$redirects, &$jobs) {
  18. foreach ($jobs as $job) {
  19. // Automatically check out all jobs using the default settings.
  20. $job->translator = 'example';
  21. $job->translator_context = $job->getTranslator()->getController()->defaultCheckoutSettings();
  22. }
  23. }
  24. /**
  25. * Allows to alter job checkout workflow after the default behavior.
  26. *
  27. * @param $redirects
  28. * List of redirects the user is supposed to be redirected to.
  29. * @param $jobs
  30. * Array with the translation jobs to be checked out.
  31. */
  32. function hook_tmgmt_ui_job_checkout_after_alter(&$redirects, &$jobs) {
  33. // Redirect to custom multi-checkout form if there are multple redirects.
  34. if (count($redirects) > 2) {
  35. $redirects = array('/my/custom/checkout/form/' . implode(',', array_keys($jobs)));
  36. }
  37. }