當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractDb::_beforeSave方法代碼示例

本文整理匯總了PHP中Magento\Framework\Model\ResourceModel\Db\AbstractDb::_beforeSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractDb::_beforeSave方法的具體用法?PHP AbstractDb::_beforeSave怎麽用?PHP AbstractDb::_beforeSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Model\ResourceModel\Db\AbstractDb的用法示例。


在下文中一共展示了AbstractDb::_beforeSave方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param \Smart2Pay\GlobalPay\Model\ConfiguredMethods $object
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($existing_arr = $this->checkMethodCountryID($object->getMethodID(), $object->getCountryID())) {
         $this->getConnection()->delete($this->getMainTable(), $this->getConnection()->quoteInto($this->getIdFieldName() . '=?', $existing_arr[$this->getIdFieldName()]));
     }
     return parent::_beforeSave($object);
 }
開發者ID:smart2pay,項目名稱:magento20,代碼行數:14,代碼來源:ConfiguredMethods.php

示例2: _beforeSave

 /**
  * Validate website code before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Website code may only contain letters (a-z), numbers (0-9) or underscore (_),' . ' and the first character must be a letter.'));
     }
     return parent::_beforeSave($object);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:14,代碼來源:Website.php

示例3: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($date = $object->getDateFrom()) {
         $object->setDateFrom($this->dateTime->formatDate($date));
     } else {
         $object->setDateFrom(null);
     }
     if ($date = $object->getDateTo()) {
         $object->setDateTo($this->dateTime->formatDate($date));
     } else {
         $object->setDateTo(null);
     }
     if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && (new \DateTime($object->getDateFrom()))->getTimestamp() > (new \DateTime($object->getDateTo()))->getTimestamp()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The start date can\'t follow the end date.'));
     }
     $check = $this->_checkIntersection($object->getStoreId(), $object->getDateFrom(), $object->getDateTo(), $object->getId());
     if ($check) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The date range for this design change overlaps another design change for the specified store.'));
     }
     if ($object->getDateFrom() === null) {
         $object->setDateFrom(new \Zend_Db_Expr('null'));
     }
     if ($object->getDateTo() === null) {
         $object->setDateTo(new \Zend_Db_Expr('null'));
     }
     parent::_beforeSave($object);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:34,代碼來源:Design.php

示例4: _beforeSave

 /**
  * Prepare rule's active "from" and "to" dates
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 public function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $this->resolveDate($object, 'from_date');
     $this->resolveDate($object, 'to_date');
     parent::_beforeSave($object);
     return $this;
 }
開發者ID:dragonsword007008,項目名稱:magento2,代碼行數:13,代碼來源:AbstractResource.php

示例5: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getSortOrder()) {
         $object->setSortOrder($this->_getMaxSortOrder($object) + 1);
     }
     return parent::_beforeSave($object);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:13,代碼來源:Group.php

示例6: _beforeSave

 /**
  * Process post data before saving
  *
  * @param \Smart2Pay\GlobalPay\Model\Method $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($this->checkObjectMethodID($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Method ID already exists in database.'));
     }
     return parent::_beforeSave($object);
 }
開發者ID:smart2pay,項目名稱:magento20,代碼行數:14,代碼來源:Method.php

示例7: _beforeSave

 /**
  * Process post data before saving
  *
  * @param \Smart2Pay\GlobalPay\Model\Transaction $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getMethodId()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please provide a method id.'));
     }
     if (!$object->getMerchantTransactionId()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please provide merchant transaction id.'));
     }
     if ($current_id = $this->checkMerchantTransactionID($object->getMerchantTransactionId()) and $object->getID() != $current_id) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Merchant transaction id already exists in database.'));
     }
     $time = time();
     if (!$object->getPaymentID()) {
         $object->setPaymentID(0);
     }
     if (!$object->getSiteId()) {
         $object->setSiteId(0);
     }
     if (!$object->getPaymentStatus()) {
         $object->setPaymentStatus(0);
     }
     if (!$object->getCreated()) {
         $object->setCreated($time);
     }
     $object->setUpdated($time);
     return parent::_beforeSave($object);
 }
開發者ID:smart2pay,項目名稱:magento20,代碼行數:34,代碼來源:Transaction.php

示例8: _beforeSave

 /**
  * Process testimonial data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId() || !$object->getDate()) {
         $object->setDate($this->_date->gmtDate());
     }
     return parent::_beforeSave($object);
 }
開發者ID:swissup,項目名稱:testimonials,代碼行數:14,代碼來源:Data.php

示例9: _beforeSave

 /**
  * {@inheritdoc}
  */
 protected function _beforeSave(AbstractModel $tag)
 {
     /** @var \Mirasvit\Blog\Model\Tag $tag */
     if (!$tag->getData('url_key')) {
         $tag->setData('url_key', $this->filter->translitUrl($tag->getName()));
     }
     return parent::_beforeSave($tag);
 }
開發者ID:mirasvit,項目名稱:module-blog,代碼行數:11,代碼來源:Tag.php

示例10: _beforeSave

 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->isValidNewsblock($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please fill out newsblock fields.'));
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
開發者ID:Tossimo,項目名稱:Newsblock,代碼行數:15,代碼來源:Newsblock.php

示例11: _beforeSave

 /**
  * Before saving the object, add the created or updated times
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
開發者ID:richdynamix,項目名稱:personalised-products,代碼行數:14,代碼來源:Export.php

示例12: _beforeSave

 /**
  * Process category data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->isValidPageIdentifier($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The category URL key contains capital letters or disallowed symbols.'));
     }
     if ($this->isNumericPageIdentifier($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The category URL key cannot be made of only numbers.'));
     }
     return parent::_beforeSave($object);
 }
開發者ID:samitrimal,項目名稱:Blog-Extension-for-Magento-2,代碼行數:17,代碼來源:Category.php

示例13: _beforeSave

 /**
  * Convert array to comma separated value
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId()) {
         $this->_checkUnique($object);
     }
     if (is_array($object->getValue())) {
         $object->setValue(join(',', $object->getValue()));
     }
     return parent::_beforeSave($object);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:16,代碼來源:Data.php

示例14: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param AbstractModel $object
  * @return $this
  */
 public function _beforeSave(AbstractModel $object)
 {
     if (!$object->getExpirationDate()) {
         $object->setExpirationDate(null);
     } elseif ($object->getExpirationDate() instanceof \DateTimeInterface) {
         $object->setExpirationDate($object->getExpirationDate()->format('Y-m-d H:i:s'));
     }
     // maintain single primary coupon per rule
     $object->setIsPrimary($object->getIsPrimary() ? 1 : null);
     return parent::_beforeSave($object);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:17,代碼來源:Coupon.php

示例15: _beforeSave

 /**
  * Set date of last update
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb
  */
 protected function _beforeSave(AbstractModel $object)
 {
     /* @var $object \ClassyLlama\AvaTax\Model\Queue */
     $date = $this->dateTime->gmtDate();
     if ($object->isObjectNew() && !$object->getCreatedAt()) {
         $object->setCreatedAt($date);
     } else {
         $object->setUpdatedAt($date);
     }
     return parent::_beforeSave($object);
 }
開發者ID:classyllama,項目名稱:ClassyLlama_AvaTax,代碼行數:17,代碼來源:Queue.php


注:本文中的Magento\Framework\Model\ResourceModel\Db\AbstractDb::_beforeSave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。