Solve.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Controller\Adminhtml\Batch;
  6. use Magento\Backend\App\Action\Context;
  7. use Magento\Backend\Block\Widget\Button;
  8. use Magento\Framework\Controller\ResultFactory;
  9. use Temando\Shipping\Model\BatchInterface;
  10. use Temando\Shipping\Model\BatchProviderInterface;
  11. use Temando\Shipping\Model\ResourceModel\Repository\BatchRepositoryInterface;
  12. use Temando\Shipping\ViewModel\DataProvider\BatchUrl;
  13. use Magento\Backend\Model\View\Result\Page;
  14. /**
  15. * Temando Solve Batch Failures Action
  16. *
  17. * @package Temando\Shipping\Controller
  18. * @author Rhodri Davies <rhodri.davies@temando.com>
  19. * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  20. * @link https://www.temando.com/
  21. */
  22. class Solve extends AbstractBatchAction
  23. {
  24. /**
  25. * @var BatchProviderInterface
  26. */
  27. private $batchProvider;
  28. /**
  29. * @var BatchUrl
  30. */
  31. private $batchUrl;
  32. /**
  33. * AbstractBatchAction constructor.
  34. * @param Context $context
  35. * @param BatchRepositoryInterface $batchRepository
  36. * @param BatchProviderInterface $batchProvider
  37. * @param BatchUrl $batchUrl
  38. */
  39. public function __construct(
  40. Context $context,
  41. BatchRepositoryInterface $batchRepository,
  42. BatchProviderInterface $batchProvider,
  43. BatchUrl $batchUrl
  44. ) {
  45. $this->batchProvider = $batchProvider;
  46. $this->batchUrl = $batchUrl;
  47. parent::__construct($context, $batchRepository, $batchProvider);
  48. }
  49. /**
  50. * Render template.
  51. *
  52. * @return Page
  53. */
  54. public function execute()
  55. {
  56. /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
  57. $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
  58. $resultPage->setActiveMenu('Temando_Shipping::batches');
  59. $resultPage->getConfig()->getTitle()->prepend(__('Find Solutions'));
  60. $resultPage->addBreadcrumb(__('Batches'), __('Batches'), $this->getUrl('temando/batch'));
  61. $resultPage->addBreadcrumb(__('Find Solutions'), __('Find Solutions'));
  62. /** @var \Magento\Backend\Block\Template $toolbar */
  63. $toolbar = $this->_view->getLayout()->getBlock('page.actions.toolbar');
  64. $toolbar->addChild('back', Button::class, [
  65. 'label' => __('Back'),
  66. 'onclick' => sprintf("setLocation('%s')", $this->batchUrl->getViewActionUrl([
  67. BatchInterface::BATCH_ID => $this->batchProvider->getBatch()->getBatchId(),
  68. ])),
  69. 'class' => 'back',
  70. 'level' => -1
  71. ]);
  72. return $resultPage;
  73. }
  74. }