本文整理汇总了PHP中Magento\Framework\App\Config\Value::beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Value::beforeSave方法的具体用法?PHP Value::beforeSave怎么用?PHP Value::beforeSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Config\Value
的用法示例。
在下文中一共展示了Value::beforeSave方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Validate minimum product qty value
*
* @return $this
*/
public function beforeSave()
{
parent::beforeSave();
$minQty = (int) $this->getValue() >= 0 ? (int) $this->getValue() : (int) $this->getOldValue();
$this->setValue((string) $minQty);
return $this;
}
示例2: beforeSave
/**
* @return $this
*/
public function beforeSave()
{
if (is_array($this->getValue())) {
$this->setValue(serialize($this->getValue()));
}
return parent::beforeSave();
}
示例3: beforeSave
/**
* Validate specified value against frontend area
*
* @return $this
*/
public function beforeSave()
{
if ('' != $this->getValue()) {
$design = clone $this->_design;
$design->setDesignTheme($this->getValue(), \Magento\Framework\App\Area::AREA_FRONTEND);
}
return parent::beforeSave();
}
示例4: beforeSave
/**
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function beforeSave()
{
if (!empty($this->getValue()) && !$this->_isRegexp($this->getValue())) {
$this->messageManager->addNotice(__('Invalid regular expression: %value', ['value' => $this->getValue()]));
$this->setValue(null);
}
return parent::beforeSave();
}
示例5: beforeSave
/**
* Validate a domain name value
*
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function beforeSave()
{
$value = $this->getValue();
if (!empty($value) && !$this->configValidator->isValid($value)) {
$msg = __('Invalid cookie lifetime: ' . join('; ', $this->configValidator->getMessages()));
throw new \Magento\Framework\Exception\LocalizedException($msg);
}
return parent::beforeSave();
}
示例6: beforeSave
/**
* Validate expiration period value before saving
*
* @return $this
*/
public function beforeSave()
{
parent::beforeSave();
$expirationPeriod = (int) $this->getValue();
if ($expirationPeriod < 1) {
$expirationPeriod = (int) $this->getOldValue();
}
$this->setValue((string) $expirationPeriod);
return $this;
}
示例7: beforeSave
/**
* Validate expiration period value before saving
*
* @return $this
*/
public function beforeSave()
{
parent::beforeSave();
$resetPasswordLinkExpirationPeriod = (int) $this->getValue();
if ($resetPasswordLinkExpirationPeriod < 1) {
$resetPasswordLinkExpirationPeriod = (int) $this->getOldValue();
}
$this->setValue((string) $resetPasswordLinkExpirationPeriod);
return $this;
}
示例8: beforeSave
public function beforeSave()
{
$value = (int) $this->getValue();
if ($value > self::MAX_LIFETIME) {
throw new LocalizedException(__('Admin session lifetime must be less than or equal to 31536000 seconds (one year)'));
} else {
if ($value < self::MIN_LIFETIME) {
throw new LocalizedException(__('Admin session lifetime must be greater than or equal to 60 seconds'));
}
}
return parent::beforeSave();
}
示例9: beforeSave
/**
* Cron settings after save
*
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function beforeSave()
{
$active = $this->getData(self::XML_PATH_BAIDUPUSH_ACTIVE);
$url = $this->getValue();
if (!empty($url)) {
if (!preg_match('/http:\\/\\/[\\w.]+[\\w\\/]*[\\w.]*\\??[\\w=&\\+\\%]*/is', $url)) {
throw new \Magento\Framework\Exception\LocalizedException(__($url . 'is not a valid URL'));
}
if (strpos($url, 'data.zz.baidu.com/urls') === false) {
throw new \Magento\Framework\Exception\LocalizedException(__($url . 'is not a valid Baidu API URL'));
}
} elseif ($active) {
throw new \Magento\Framework\Exception\LocalizedException(__('Baidu API URL should not be null'));
}
return parent::beforeSave();
}
示例10: beforeSave
/**
* Validate ip addresses before save
*
* @return $this
*/
public function beforeSave()
{
$allowedIpsRaw = $this->getValue();
$noticeMsgArray = [];
$allowedIpsArray = [];
if (empty($allowedIpsRaw)) {
return parent::beforeSave();
}
$dataArray = explode(',', $allowedIpsRaw);
foreach ($dataArray as $data) {
if (filter_var(trim($data), FILTER_VALIDATE_IP)) {
$allowedIpsArray[] = $data;
} else {
$noticeMsgArray[] = $data;
}
}
$noticeMsg = implode(',', $noticeMsgArray);
if (!empty($noticeMsgArray)) {
$this->messageManager->addNotice(__(__('The following invalid values cannot be saved: %values', ['values' => $noticeMsg])));
}
$this->setValue(implode(',', $allowedIpsArray));
return parent::beforeSave();
}