本文整理汇总了PHP中Magento\Framework\Data\Form\Element\AbstractElement::setInherit方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractElement::setInherit方法的具体用法?PHP AbstractElement::setInherit怎么用?PHP AbstractElement::setInherit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Data\Form\Element\AbstractElement
的用法示例。
在下文中一共展示了AbstractElement::setInherit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRender
/**
* @param null|string $requestCountry
* @param null|string $requestDefaultCountry
* @param bool $canUseDefault
* @param bool $inherit
* @dataProvider renderDataProvider
*/
public function testRender($requestCountry, $requestDefaultCountry, $canUseDefault, $inherit)
{
$this->_request->expects($this->any())->method('getParam')->will($this->returnCallback(function ($param) use($requestCountry, $requestDefaultCountry) {
if ($param == \Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY) {
return $requestCountry;
}
if ($param == Country::REQUEST_PARAM_DEFAULT_COUNTRY) {
return $requestDefaultCountry;
}
return $param;
}));
$this->_element->setInherit($inherit);
$this->_element->setCanUseDefaultValue($canUseDefault);
$constraints = [new \PHPUnit_Framework_Constraint_StringContains('document.observe("dom:loaded", function() {'), new \PHPUnit_Framework_Constraint_StringContains('$("' . $this->_element->getHtmlId() . '").observe("change", function () {')];
if ($canUseDefault && $requestCountry == 'US' && $requestDefaultCountry) {
$constraints[] = new \PHPUnit_Framework_Constraint_StringContains('$("' . $this->_element->getHtmlId() . '_inherit").observe("click", function () {');
}
$this->_jsHelper->expects($this->once())->method('getScript')->with(new \PHPUnit_Framework_Constraint_And($constraints));
$this->_url->expects($this->once())->method('getUrl')->with('*/*/*', ['section' => 'section', 'website' => 'website', 'store' => 'store', \Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY => '__country__']);
$this->_model->render($this->_element);
}
示例2: render
/**
* Render country field considering request parameter
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$country = $this->getRequest()->getParam(StructurePlugin::REQUEST_PARAM_COUNTRY);
if ($country) {
$element->setValue($country);
}
if ($element->getCanUseDefaultValue()) {
$this->_defaultCountry = $this->_scopeConfig->getValue(self::FIELD_CONFIG_PATH);
if (!$this->_defaultCountry) {
$this->_defaultCountry = $this->directoryHelper->getDefaultCountry();
}
if ($country) {
$shouldInherit = $country == $this->_defaultCountry && $this->getRequest()->getParam(self::REQUEST_PARAM_DEFAULT_COUNTRY);
$element->setInherit($shouldInherit);
}
if ($element->getInherit()) {
$this->_defaultCountry = null;
}
}
return parent::render($element);
}