Permissions.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\Cache;
  7. use Magento\Framework\AuthorizationInterface;
  8. use Magento\Framework\View\Element\Block\ArgumentInterface;
  9. /**
  10. * Class Permissions
  11. */
  12. class Permissions implements ArgumentInterface
  13. {
  14. /**
  15. * @var AuthorizationInterface
  16. */
  17. private $authorization;
  18. /**
  19. * Permissions constructor.
  20. *
  21. * @param AuthorizationInterface $authorization
  22. */
  23. public function __construct(AuthorizationInterface $authorization)
  24. {
  25. $this->authorization = $authorization;
  26. }
  27. /**
  28. * @return bool
  29. */
  30. public function hasAccessToFlushCatalogImages()
  31. {
  32. return $this->authorization->isAllowed('Magento_Backend::flush_catalog_images');
  33. }
  34. /**
  35. * @return bool
  36. */
  37. public function hasAccessToFlushJsCss()
  38. {
  39. return $this->authorization->isAllowed('Magento_Backend::flush_js_css');
  40. }
  41. /**
  42. * @return bool
  43. */
  44. public function hasAccessToFlushStaticFiles()
  45. {
  46. return $this->authorization->isAllowed('Magento_Backend::flush_static_files');
  47. }
  48. /**
  49. * @return bool
  50. */
  51. public function hasAccessToAdditionalActions()
  52. {
  53. return ($this->hasAccessToFlushCatalogImages()
  54. || $this->hasAccessToFlushJsCss()
  55. || $this->hasAccessToFlushStaticFiles());
  56. }
  57. }