當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。