1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit;
- use Magento\SalesRule\Model\RegistryConstants;
- class GenericButton
- {
- /**
- * Url Builder
- *
- * @var \Magento\Framework\UrlInterface
- */
- protected $urlBuilder;
- /**
- * Registry
- *
- * @var \Magento\Framework\Registry
- */
- protected $registry;
- /**
- * Constructor
- *
- * @param \Magento\Backend\Block\Widget\Context $context
- * @param \Magento\Framework\Registry $registry
- */
- public function __construct(
- \Magento\Backend\Block\Widget\Context $context,
- \Magento\Framework\Registry $registry
- ) {
- $this->urlBuilder = $context->getUrlBuilder();
- $this->registry = $registry;
- }
- /**
- * Return the current sales Rule Id.
- *
- * @return int|null
- */
- public function getRuleId()
- {
- $salesRule = $this->registry->registry(RegistryConstants::CURRENT_SALES_RULE);
- return $salesRule ? $salesRule->getId() : null;
- }
- /**
- * Generate url by route and parameters
- *
- * @param string $route
- * @param array $params
- * @return string
- */
- public function getUrl($route = '', $params = [])
- {
- return $this->urlBuilder->getUrl($route, $params);
- }
- /**
- * Check where button can be rendered
- *
- * @param string $name
- * @return string
- */
- public function canRender($name)
- {
- return $name;
- }
- }
|