/** * Return array of scope names * * @return array */ public function toOptionArray() { $scopes = $this->scopeResolverPool->get($this->scope)->getScopes(); $array = []; foreach ($scopes as $scope) { $array[] = ['value' => $scope->getId(), 'label' => $scope->getName()]; } return $array; }
/** * Retrieve scope title * * @return string */ protected function getScopeTitle() { $scope = $this->getRequest()->getParam('scope'); $scopeId = $this->getRequest()->getParam('scope_id'); if ($scope != ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { $scopeResolver = $this->scopeResolverPool->get($scope); $scopeObject = $scopeResolver->getScope($scopeId); return __('%1', $scopeObject->getName()); } return __('Global'); }
/** * @inheritDoc */ public function isValidScope($scope, $scopeId = null) { if ($scope == ScopeConfigInterface::SCOPE_TYPE_DEFAULT && !$scopeId) { return true; } try { $scopeResolver = $this->scopeResolverPool->get($scope); if (!$scopeResolver->getScope($scopeId)->getId()) { return false; } } catch (\InvalidArgumentException $e) { return false; } catch (NoSuchEntityException $e) { return false; } return true; }
/** * Retrieve scope code value * * @param string $scopeType * @param string|\Magento\Framework\DataObject|null $scopeCode * @return string */ protected function _getScopeCode($scopeType, $scopeCode) { if (($scopeCode === null || is_numeric($scopeCode)) && $scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { $scopeResolver = $this->_scopeResolverPool->get($scopeType); $scopeCode = $scopeResolver->getScope($scopeCode); } if ($scopeCode instanceof \Magento\Framework\App\ScopeInterface) { $scopeCode = $scopeCode->getCode(); } return $scopeCode; }