Edit.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\User\Block\Role;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class Edit extends \Magento\Backend\Block\Widget\Tabs
  12. {
  13. /**
  14. * Core registry
  15. *
  16. * @var \Magento\Framework\Registry
  17. */
  18. protected $_coreRegistry = null;
  19. /**
  20. * @param \Magento\Backend\Block\Template\Context $context
  21. * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
  22. * @param \Magento\Backend\Model\Auth\Session $authSession
  23. * @param \Magento\Framework\Registry $registry
  24. * @param array $data
  25. */
  26. public function __construct(
  27. \Magento\Backend\Block\Template\Context $context,
  28. \Magento\Framework\Json\EncoderInterface $jsonEncoder,
  29. \Magento\Backend\Model\Auth\Session $authSession,
  30. \Magento\Framework\Registry $registry,
  31. array $data = []
  32. ) {
  33. $this->_coreRegistry = $registry;
  34. parent::__construct($context, $jsonEncoder, $authSession, $data);
  35. }
  36. /**
  37. * Class constructor
  38. *
  39. * @return void
  40. */
  41. protected function _construct()
  42. {
  43. parent::_construct();
  44. $this->setId('role_info_tabs');
  45. $this->setDestElementId('role-edit-form');
  46. $this->setTitle(__('Role Information'));
  47. }
  48. /**
  49. * @return $this
  50. */
  51. protected function _prepareLayout()
  52. {
  53. $role = $this->_coreRegistry->registry('current_role');
  54. $this->addTab(
  55. 'info',
  56. $this->getLayout()->createBlock(\Magento\User\Block\Role\Tab\Info::class)->setRole($role)->setActive(true)
  57. );
  58. if ($role->getId()) {
  59. $this->addTab(
  60. 'roles',
  61. [
  62. 'label' => __('Role Users'),
  63. 'title' => __('Role Users'),
  64. 'content' => $this->getLayout()->createBlock(
  65. \Magento\User\Block\Role\Tab\Users::class,
  66. 'role.users.grid'
  67. )->toHtml()
  68. ]
  69. );
  70. }
  71. return parent::_prepareLayout();
  72. }
  73. }