![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Soon/Faq/Block/Adminhtml/Category/Edit/Button/ |
<?php /** * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @author Hervé Guétin <[email protected]> <@herveguetin> * @copyright Copyright (c) 2016 Agence Soon (http://www.agence-soon.fr) */ namespace Soon\Faq\Block\Adminhtml\Category\Edit\Button; use Magento\Framework\App\RequestInterface; use Magento\Framework\Model\AbstractModel; use Magento\Framework\UrlInterface; use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; use Soon\Faq\Model\CategoryFactory as ModelFactory; class Delete implements ButtonProviderInterface { /** * @var ModelFactory */ private $modelFactory; /** * @var RequestInterface */ private $request; /** * @var UrlInterface */ private $url; public function __construct( ModelFactory $modelFactory, RequestInterface $request, UrlInterface $url ) { $this->modelFactory = $modelFactory; $this->request = $request; $this->url = $url; } /** * Retrieve button-specified settings * * @return array */ public function getButtonData() { $data = []; if ($this->getInstanceId()) { $data = [ 'label' => __('Delete'), 'class' => 'delete', 'on_click' => 'deleteConfirm(\'' . __( 'Are you sure you want to do this?' ) . '\', \'' . $this->getDeleteUrl() . '\')', 'sort_order' => 20, ]; } return $data; } /** * @return string */ private function getDeleteUrl() { return $this->url->getUrl('*/*/delete', ['id' => $this->getInstanceId()]); } /** * @return int|null */ private function getInstanceId() { $model = $this->modelFactory->create(); $id = $this->request->getParam('id'); /** @var AbstractModel $model */ $model->getResource()->load($model, $id); return ($model->getId()) ? $model->getId() : null; } }