Role.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\User\Block;
  7. /**
  8. * Magento_User role block
  9. *
  10. * @api
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. * @since 100.0.2
  13. */
  14. class Role extends \Magento\Backend\Block\Widget\Grid\Container
  15. {
  16. /**
  17. * @var string
  18. */
  19. protected $_controller = 'user_role';
  20. /**
  21. * @var string
  22. */
  23. protected $_blockGroup = 'Magento_User';
  24. /**
  25. * Class constructor
  26. *
  27. * @return void
  28. */
  29. protected function _construct()
  30. {
  31. $this->_headerText = __('Roles');
  32. $this->_addButtonLabel = __('Add New Role');
  33. parent::_construct();
  34. }
  35. /**
  36. * @return string
  37. */
  38. public function getCreateUrl()
  39. {
  40. return $this->getUrl('*/*/editrole');
  41. }
  42. /**
  43. * @return $this
  44. */
  45. protected function _prepareLayout()
  46. {
  47. if (!$this->getLayout()->getChildName($this->getNameInLayout(), 'grid')) {
  48. $this->setChild(
  49. 'grid',
  50. $this->getLayout()->createBlock(
  51. $this->_blockGroup . '\\Block\\Role\\Grid',
  52. $this->_controller . '.grid'
  53. )->setSaveParametersInSession(
  54. true
  55. )
  56. );
  57. }
  58. return \Magento\Backend\Block\Widget\Container::_prepareLayout();
  59. }
  60. /**
  61. * Prepare output HTML
  62. *
  63. * @return string
  64. */
  65. protected function _toHtml()
  66. {
  67. $this->_eventManager->dispatch('permissions_role_html_before', ['block' => $this]);
  68. return parent::_toHtml();
  69. }
  70. }