GenericButton.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Block\Adminhtml\Edit;
  9. use Magento\Backend\Block\Widget\Context;
  10. use Magento\Framework\Exception\NoSuchEntityException;
  11. /**
  12. * Class GenericButton
  13. */
  14. class GenericButton
  15. {
  16. /**
  17. * @var Context
  18. */
  19. protected $context;
  20. /**
  21. * @param Context $context
  22. * @param BlockRepositoryInterface $blockRepository
  23. */
  24. public function __construct(
  25. Context $context
  26. ) {
  27. $this->context = $context;
  28. }
  29. /**
  30. * Return CMS block ID
  31. *
  32. * @return int|null
  33. */
  34. public function getPostId()
  35. {
  36. return $this->context->getRequest()->getParam('id');
  37. }
  38. /**
  39. * Generate url by route and parameters
  40. *
  41. * @param string $route
  42. * @param array $params
  43. * @return string
  44. */
  45. public function getUrl($route = '', $params = [])
  46. {
  47. return $this->context->getUrlBuilder()->getUrl($route, $params);
  48. }
  49. }