![]() 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/vendor/extmag/shiplab/Block/Adminhtml/ManualLabel/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Block\Adminhtml\ManualLabel; use Extmag\Shiplab\Api\LabelRepositoryInterface; use Magento\Backend\Block\Widget\Context; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; class GenericButton { /** * @var Context */ protected $context; /** * @var LabelRepositoryInterface */ protected $entityRepository; /** * @param Context $context * @param LabelRepositoryInterface $entityRepository */ public function __construct( Context $context, LabelRepositoryInterface $entityRepository ) { $this->context = $context; $this->entityRepository = $entityRepository; } /** * @return int|null * @throws LocalizedException */ public function getEntityId() { try { return $this->entityRepository->getById( $this->context->getRequest()->getParam('entity_id') )->getId(); } catch (NoSuchEntityException $e) { } return null; } /** * Generate url by route and parameters * * @param string $route * @param array $params * @return string */ public function getUrl($route = '', $params = []) { return $this->context->getUrlBuilder()->getUrl($route, $params); } }