示例#1
0
 /**
  * Substitute payment section with PayPal configs
  *
  * @param \Magento\Backend\Model\Config\Structure $subject
  * @param \Closure $proceed
  * @param array $pathParts
  * @return \Magento\Backend\Model\Config\Structure\ElementInterface
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundGetElementByPathParts(\Magento\Backend\Model\Config\Structure $subject, \Closure $proceed, array $pathParts)
 {
     $isSectionChanged = $pathParts[0] == 'payment';
     if ($isSectionChanged) {
         $requestedCountrySection = 'payment_' . strtolower($this->_helper->getConfigurationCountryCode());
         if (in_array($requestedCountrySection, self::getPaypalConfigCountries())) {
             $pathParts[0] = $requestedCountrySection;
         } else {
             $pathParts[0] = 'payment_other';
         }
     }
     /** @var \Magento\Backend\Model\Config\Structure\ElementInterface $result */
     $result = $proceed($pathParts);
     if ($isSectionChanged && isset($result)) {
         if ($result instanceof \Magento\Backend\Model\Config\Structure\Element\Section) {
             $result->setData(array_merge($result->getData(), ['showInDefault' => true, 'showInWebsite' => true, 'showInStore' => true]), $this->_scopeDefiner->getScope());
         }
     }
     return $result;
 }
示例#2
0
 public function testGetScopeReturnsWebsiteScopeIfWebsiteIsSpecified()
 {
     $this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap(array(array('website', null, 'someWebsite'), array('store', null, null))));
     $this->assertEquals(\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, $this->_model->getScope());
 }