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\Search\Block\Adminhtml\Synonyms\Edit;
  7. use Magento\Search\Controller\RegistryConstants;
  8. /**
  9. * Class GenericButton
  10. */
  11. class GenericButton
  12. {
  13. /**
  14. * Url Builder
  15. *
  16. * @var \Magento\Framework\UrlInterface
  17. */
  18. protected $urlBuilder;
  19. /**
  20. * Registry
  21. *
  22. * @var \Magento\Framework\Registry
  23. */
  24. protected $registry;
  25. /**
  26. * Constructor
  27. *
  28. * @param \Magento\Backend\Block\Widget\Context $context
  29. * @param \Magento\Framework\Registry $registry
  30. */
  31. public function __construct(
  32. \Magento\Backend\Block\Widget\Context $context,
  33. \Magento\Framework\Registry $registry
  34. ) {
  35. $this->urlBuilder = $context->getUrlBuilder();
  36. $this->registry = $registry;
  37. }
  38. /**
  39. * Return the synonyms group Id.
  40. *
  41. * @return int|null
  42. */
  43. public function getGroupId()
  44. {
  45. $synGroup = $this->registry->registry(RegistryConstants::SEARCH_SYNONYMS);
  46. return $synGroup ? $synGroup->getId() : null;
  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. }