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


PHP AbstractModel::setCreatedAt方法代码示例

本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::setCreatedAt方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::setCreatedAt方法的具体用法?PHP AbstractModel::setCreatedAt怎么用?PHP AbstractModel::setCreatedAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::setCreatedAt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _beforeSave

 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     $object->setUpdatedAt($this->_date->gmtDate());
     return $this;
 }
开发者ID:pradeeprcs,项目名称:TestModule,代码行数:8,代码来源:Test.php

示例2: _beforeSave

 /**
  * Prepare data to be saved to database
  * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\Object $object
  *
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->dateTime->formatDate(true));
     }
     $object->setUpdatedAt($this->dateTime->formatDate(true));
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:14,代码来源:Bookmark.php

示例3: _beforeSave

 /**
  * @param \Magento\Framework\Model\AbstractModel $object
  *
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->isObjectNew() && !$object->hasCreatedAt()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     $object->setUpdatedAt($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
开发者ID:pyvil,项目名称:magento2-blog-module,代码行数:14,代码来源:Comment.php

示例4: _prepareDataForSave

 /**
  * Prepare data for save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return array
  */
 protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $currentTime = $this->dateTime->now();
     if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
         $object->setCreatedAt($currentTime);
     }
     $object->setUpdatedAt($currentTime);
     $data = parent::_prepareDataForSave($object);
     return $data;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:AbstractResource.php

示例5: _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

示例6: _beforeSave

 /**
  * before save callback
  *
  * @param \Magento\Framework\Model\AbstractModel|\Mageplaza\Blog\Model\Topic $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $object->setUpdatedAt($this->date->date());
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->date->date());
     }
     //Check Url Key
     if ($object->isObjectNew()) {
         $count = 0;
         $objName = $object->getName();
         if ($object->getUrlKey()) {
             $urlKey = $object->getUrlKey();
         } else {
             $urlKey = $this->generateUrlKey($objName, $count);
         }
         while ($this->checkUrlKey($urlKey)) {
             $count++;
             $urlKey = $this->generateUrlKey($urlKey, $count);
         }
         $object->setUrlKey($urlKey);
     } else {
         $objectId = $object->getId();
         $count = 0;
         $objName = $object->getName();
         if ($object->getUrlKey()) {
             $urlKey = $object->getUrlKey();
         } else {
             $urlKey = $this->generateUrlKey($objName, $count);
         }
         while ($this->checkUrlKey($urlKey, $objectId)) {
             $count++;
             $urlKey = $this->generateUrlKey($urlKey, $count);
         }
         $object->setUrlKey($urlKey);
     }
     return parent::_beforeSave($object);
 }
开发者ID:mageplaza,项目名称:magento-2-blog-extension,代码行数:43,代码来源:Topic.php

示例7: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     if (!$object->getId()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     if ($object->hasData('stores') && is_array($object->getStores())) {
         $stores = $object->getStores();
         $stores[] = 0;
         $object->setStores($stores);
     } elseif ($object->hasData('stores')) {
         $object->setStores([$object->getStores(), 0]);
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:20,代码来源:Review.php

示例8: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $connection = $this->getConnection();
     $columns = $connection->describeTable($this->getMainTable());
     if (isset($columns['created_at'], $columns['updated_at'])) {
         $select = $connection->select()->from($this->getMainTable(), ['created_at', 'updated_at'])->where($this->getIdFieldName() . ' = :entity_id');
         $row = $connection->fetchRow($select, [':entity_id' => $object->getId()]);
         if (is_array($row) && isset($row['created_at'], $row['updated_at'])) {
             $object->setCreatedAt($row['created_at']);
             $object->setUpdatedAt($row['updated_at']);
         }
     }
     parent::_afterSave($object);
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:EntityAbstract.php

示例9: _beforeSave

 /**
  * Set template type, added at and modified at time
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->dateTime->formatDate(true));
     }
     $object->setModifiedAt($this->dateTime->formatDate(true));
     $object->setTemplateType((int) $object->getTemplateType());
     return parent::_beforeSave($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Template.php

示例10: _beforeSave

 /**
  * before save callback
  *
  * @param AbstractModel|\Sample\News\Model\Author $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     foreach (['dob'] as $field) {
         $value = !$object->getData($field) ? null : $object->getData($field);
         $object->setData($field, $this->dateTime->formatDate($value));
     }
     $object->setUpdatedAt($this->date->gmtDate());
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->date->gmtDate());
     }
     $urlKey = $object->getData('url_key');
     if ($urlKey == '') {
         $urlKey = $object->getName();
     }
     $urlKey = $object->formatUrlKey($urlKey);
     $object->setUrlKey($urlKey);
     $validKey = false;
     while (!$validKey) {
         if ($this->getIsUniqueAuthorToStores($object)) {
             $validKey = true;
         } else {
             $parts = explode('-', $urlKey);
             $last = $parts[count($parts) - 1];
             if (!is_numeric($last)) {
                 $urlKey = $urlKey . '-1';
             } else {
                 $suffix = '-' . ($last + 1);
                 unset($parts[count($parts) - 1]);
                 $urlKey = implode('-', $parts) . $suffix;
             }
             $object->setData('url_key', $urlKey);
         }
     }
     return parent::_beforeSave($object);
 }
开发者ID:sz-bill,项目名称:Magento2.x,代码行数:41,代码来源:Author.php

示例11: _beforeSave

 /**
  * before save callback
  *
  * @param \Magento\Framework\Model\AbstractModel|\Mageplaza\Blog\Model\Category $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $object->setUpdatedAt($this->date->date());
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->date->date());
     }
     /** @var \Mageplaza\Blog\Model\Category $object */
     parent::_beforeSave($object);
     if (!$object->getChildrenCount()) {
         $object->setChildrenCount(0);
     }
     if ($object->isObjectNew()) {
         if ($object->getPosition() === null) {
             $object->setPosition($this->getMaxPosition($object->getPath()) + 1);
         }
         $path = explode('/', $object->getPath());
         $level = count($path) - ($object->getId() ? 1 : 0);
         $toUpdateChild = array_diff($path, [$object->getId()]);
         if (!$object->hasPosition()) {
             $object->setPosition($this->getMaxPosition(implode('/', $toUpdateChild)) + 1);
         }
         if (!$object->hasLevel()) {
             $object->setLevel($level);
         }
         if (!$object->hasParentId() && $level && !$object->getInitialSetupFlag()) {
             $object->setParentId($path[$level - 1]);
         }
         if (!$object->getId() && !$object->getInitialSetupFlag()) {
             $object->setPath($object->getPath() . '/');
         }
         if (!$object->getInitialSetupFlag()) {
             $this->getConnection()->update($this->getMainTable(), ['children_count' => new \Zend_Db_Expr('children_count+1')], ['category_id IN(?)' => $toUpdateChild]);
         }
     }
     //Check Url Key
     if ($object->isObjectNew()) {
         $count = 0;
         $objName = $object->getName();
         if ($object->getUrlKey()) {
             $urlKey = $object->getUrlKey();
         } else {
             $urlKey = $this->generateUrlKey($objName, $count);
         }
         while ($this->checkUrlKey($urlKey)) {
             $count++;
             $urlKey = $this->generateUrlKey($urlKey, $count);
         }
         $object->setUrlKey($urlKey);
     } else {
         $objectId = $object->getId();
         $count = 0;
         $objName = $object->getName();
         if ($object->getUrlKey()) {
             $urlKey = $object->getUrlKey();
         } else {
             $urlKey = $this->generateUrlKey($objName, $count);
         }
         while ($this->checkUrlKey($urlKey, $objectId)) {
             $count++;
             $urlKey = $this->generateUrlKey($urlKey, $count);
         }
         $object->setUrlKey($urlKey);
     }
     return $this;
 }
开发者ID:mageplaza,项目名称:magento-2-blog-extension,代码行数:71,代码来源:Category.php


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