当前位置: 首页>>代码示例>>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;未经允许,请勿转载。