Scope.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Theme\Block\Adminhtml\Design\Config\Edit;
  7. use Magento\Backend\Block\Template;
  8. use Magento\Backend\Block\Template\Context;
  9. use Magento\Framework\App\Config\ScopeConfigInterface;
  10. use Magento\Framework\App\ScopeResolverPool;
  11. /**
  12. * Scope information block
  13. *
  14. * @api
  15. * @since 100.1.0
  16. */
  17. class Scope extends Template
  18. {
  19. /**
  20. * @var ScopeResolverPool
  21. */
  22. private $scopeResolverPool;
  23. /**
  24. * @param Context $context
  25. * @param ScopeResolverPool $scopeResolverPool
  26. */
  27. public function __construct(
  28. Context $context,
  29. ScopeResolverPool $scopeResolverPool
  30. ) {
  31. parent::__construct($context);
  32. $this->scopeResolverPool = $scopeResolverPool;
  33. }
  34. /**
  35. * Retrieve scope title
  36. *
  37. * @return string
  38. * @since 100.1.0
  39. */
  40. public function getScopeTitle()
  41. {
  42. $scope = $this->getRequest()->getParam('scope');
  43. $scopeId = $this->getRequest()->getParam('scope_id');
  44. if ($scope != ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
  45. $scopeResolver = $this->scopeResolverPool->get($scope);
  46. $scopeObject = $scopeResolver->getScope($scopeId);
  47. return __('%1', $scopeObject->getScopeTypeName());
  48. }
  49. return __('Default');
  50. }
  51. /**
  52. * @inheritdoc
  53. * @since 100.1.0
  54. */
  55. public function toHtml()
  56. {
  57. if ($this->_storeManager->isSingleStoreMode()) {
  58. return '';
  59. }
  60. return parent::toHtml();
  61. }
  62. }