GenericButton.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Block\Adminhtml\Edit;
  7. use Magento\Customer\Controller\RegistryConstants;
  8. /**
  9. * Class GenericButton
  10. * @package Magento\Customer\Block\Adminhtml\Edit
  11. */
  12. class GenericButton
  13. {
  14. /**
  15. * Url Builder
  16. *
  17. * @var \Magento\Framework\UrlInterface
  18. */
  19. protected $urlBuilder;
  20. /**
  21. * Registry
  22. *
  23. * @var \Magento\Framework\Registry
  24. */
  25. protected $registry;
  26. /**
  27. * Constructor
  28. *
  29. * @param \Magento\Backend\Block\Widget\Context $context
  30. * @param \Magento\Framework\Registry $registry
  31. */
  32. public function __construct(
  33. \Magento\Backend\Block\Widget\Context $context,
  34. \Magento\Framework\Registry $registry
  35. ) {
  36. $this->urlBuilder = $context->getUrlBuilder();
  37. $this->registry = $registry;
  38. }
  39. /**
  40. * Return the customer Id.
  41. *
  42. * @return int|null
  43. */
  44. public function getCustomerId()
  45. {
  46. return $this->registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
  47. }
  48. /**
  49. * Generate url by route and parameters
  50. *
  51. * @param string $route
  52. * @param array $params
  53. * @return string
  54. */
  55. public function getUrl($route = '', $params = [])
  56. {
  57. return $this->urlBuilder->getUrl($route, $params);
  58. }
  59. }