RetryButton.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\AsynchronousOperations\Block\Adminhtml\Bulk\Details;
  7. use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
  8. /**
  9. * Retry button configuration provider
  10. */
  11. class RetryButton implements ButtonProviderInterface
  12. {
  13. /**
  14. * @var \Magento\AsynchronousOperations\Model\Operation\Details
  15. */
  16. private $details;
  17. /**
  18. * @var \Magento\Framework\App\RequestInterface
  19. */
  20. private $request;
  21. /**
  22. * @var string
  23. */
  24. private $targetName;
  25. /**
  26. * RetryButton constructor.
  27. *
  28. * @param \Magento\AsynchronousOperations\Model\Operation\Details $details
  29. * @param \Magento\Framework\App\RequestInterface $request
  30. * @param string $targetName
  31. */
  32. public function __construct(
  33. \Magento\AsynchronousOperations\Model\Operation\Details $details,
  34. \Magento\Framework\App\RequestInterface $request,
  35. $targetName = 'bulk_details_form.bulk_details_form'
  36. ) {
  37. $this->details = $details;
  38. $this->request = $request;
  39. $this->targetName = $targetName;
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function getButtonData()
  45. {
  46. $uuid = $this->request->getParam('uuid');
  47. $details = $this->details->getDetails($uuid);
  48. if ($details['failed_retriable'] === 0) {
  49. return [];
  50. }
  51. return [
  52. 'label' => __('Retry'),
  53. 'class' => 'retry primary',
  54. 'data_attribute' => [
  55. 'mage-init' => ['button' => ['event' => 'save']],
  56. 'form-role' => 'save',
  57. ],
  58. ];
  59. }
  60. }