当前位置: 首页>>代码示例>>PHP>>正文


PHP Value::beforeSave方法代码示例

本文整理汇总了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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:Minqty.php

示例2: beforeSave

 /**
  * @return $this
  */
 public function beforeSave()
 {
     if (is_array($this->getValue())) {
         $this->setValue(serialize($this->getValue()));
     }
     return parent::beforeSave();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:Serialized.php

示例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();
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:13,代码来源:Theme.php

示例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();
 }
开发者ID:ytorbyk,项目名称:magento2-geo-store-switcher,代码行数:12,代码来源:Regexp.php

示例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();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Lifetime.php

示例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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Expirationperiod.php

示例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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Expirationperiod.php

示例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();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:12,代码来源:BackendModel.php

示例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();
 }
开发者ID:colinnj,项目名称:Shop123_CE,代码行数:22,代码来源:Url.php

示例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();
 }
开发者ID:opexsw,项目名称:magento2,代码行数:28,代码来源:AllowedIps.php


注:本文中的Magento\Framework\App\Config\Value::beforeSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。