Skip to content

Commit

Permalink
Fix generation of urls to switch to specific scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Hansen committed Nov 16, 2015
1 parent a3c9d3a commit 0cca279
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,29 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
/** @var \Magento\Store\Model\StoreManagerInterface */
protected $storeManager;

/**
* Url Builder
*
* @var \Magento\Backend\Model\Url
*/
protected $urlBuilder;

/**
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Backend\Model\Url $urlBuilder
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Backend\Model\Url $urlBuilder
) {
$this->storeManager = $storeManager;
$this->context = $context;
// Ideally we would just retrieve the urlBuilder using $this->content->getUrlBuilder(), but since it retrieves
// an instance of \Magento\Framework\Url instead of \Magento\Backend\Model\Url, we must explicitly request it
// via DI.
$this->urlBuilder = $urlBuilder;
}

/**
Expand Down Expand Up @@ -142,11 +155,11 @@ public function formatOverriddenScopes(\Magento\Config\Block\System\Config\Form
$section = $form->getSectionCode();
switch($scope) {
case 'website':
$url = $this->_context->getUrlBuilder()->getUrl(
$url = $this->urlBuilder->getUrl(
'*/*/*',
array(
'section'=>$section,
'website'=>$scopeId
'section' => $section,
'website' => $scopeId
)
);
$scopeLabel = sprintf(
Expand All @@ -159,12 +172,11 @@ public function formatOverriddenScopes(\Magento\Config\Block\System\Config\Form
case 'store':
$store = $this->storeManager->getStore($scopeId);
$website = $store->getWebsite();
$url = $this->_context->getUrlBuilder()->getUrl(
$url = $this->urlBuilder->getUrl(
'*/*/*',
array(
'section' => $section,
'website' => $website->getCode(),
'store' => $store->getCode()
'store' => $store->getId()
)
);
$scopeLabel = sprintf(
Expand All @@ -182,4 +194,4 @@ public function formatOverriddenScopes(\Magento\Config\Block\System\Config\Form

return $formatted;
}
}
}

0 comments on commit 0cca279

Please sign in to comment.