. */ namespace Storefront\BTCPay\Ui\Component\Listing\Column; use Storefront\BTCPay\Model\BTCPay\BTCPayService; class InvoiceActions extends \Magento\Ui\Component\Listing\Columns\Column { const URL_PATH_UPDATE = 'btcpay/invoice/update'; // const URL_PATH_EDIT = 'btcpay/invoice/edit'; // const URL_PATH_DELETE = 'btcpay/invoice/delete'; // const URL_PATH_DETAILS = 'btcpay/invoice/details'; /** * @var \Magento\Framework\UrlInterface */ protected $urlBuilder; /** * @var BTCPayService */ private $btcPayService; /** * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context * @param \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory * @param \Magento\Framework\UrlInterface $urlBuilder * @param array $components * @param array $data */ public function __construct(\Magento\Framework\View\Element\UiComponent\ContextInterface $context, \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory, \Magento\Framework\UrlInterface $urlBuilder, BTCPayService $btcPayService, array $components = [], array $data = []) { $this->urlBuilder = $urlBuilder; $this->btcPayService = $btcPayService; parent::__construct($context, $uiComponentFactory, $components, $data); } /** * Prepare Data Source * * @param array $dataSource * @return array */ public function prepareDataSource(array $dataSource) { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as & $item) { if (isset($item['invoice_id'])) { // TODO add view URL + add multi store support $viewUrl = $this->btcPayService->getInvoiceDetailUrl(0, $item['invoice_id']); $item[$this->getData('name')] = [ 'update' => [ 'href' => $this->urlBuilder->getUrl(static::URL_PATH_UPDATE, [ 'invoice_id' => $item['id'], 'btcpay_store_id' => $item['btcpay_store_id'] ]), 'label' => __('Update') ], // 'delete' => [ // 'href' => $this->urlBuilder->getUrl( // static::URL_PATH_DELETE, // [ // 'invoice_id' => $item['invoice_id'] // ] // ), // 'label' => __('Delete'), // 'confirm' => [ // 'title' => __('Delete "${ $.$data.title }"'), // 'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?') // ] // ] ]; } } } return $dataSource; } }