AclCondition.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Layout;
  7. use Magento\Framework\View\Layout\Condition\VisibilityConditionInterface;
  8. /**
  9. * Check that user is allowed to watch resource with given acl resource..
  10. */
  11. class AclCondition implements VisibilityConditionInterface
  12. {
  13. /**
  14. * Unique name.
  15. */
  16. const NAME = 'acl';
  17. /**
  18. * @var \Magento\Framework\AuthorizationInterface
  19. */
  20. private $authorization;
  21. /**
  22. * @param \Magento\Framework\AuthorizationInterface $authorization
  23. */
  24. public function __construct(\Magento\Framework\AuthorizationInterface $authorization)
  25. {
  26. $this->authorization = $authorization;
  27. }
  28. /**
  29. * @inheritdoc
  30. */
  31. public function isVisible(array $arguments)
  32. {
  33. return $this->authorization->isAllowed($arguments['acl']);
  34. }
  35. /**
  36. * @return string
  37. */
  38. public function getName()
  39. {
  40. return self::NAME;
  41. }
  42. }