RoleLocator.php 863 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Model\Authorization;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class RoleLocator implements \Magento\Framework\Authorization\RoleLocatorInterface
  12. {
  13. /**
  14. * Authentication service
  15. *
  16. * @var \Magento\Backend\Model\Auth\Session
  17. */
  18. protected $_session;
  19. /**
  20. * @param \Magento\Backend\Model\Auth\Session $session
  21. */
  22. public function __construct(\Magento\Backend\Model\Auth\Session $session)
  23. {
  24. $this->_session = $session;
  25. }
  26. /**
  27. * Retrieve current role
  28. *
  29. * @return string|null
  30. */
  31. public function getAclRoleId()
  32. {
  33. if ($this->_session->hasUser()) {
  34. return $this->_session->getUser()->getAclRole();
  35. }
  36. return null;
  37. }
  38. }