123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace Dotdigitalgroup\Email\Model;
- class Wishlist extends \Magento\Framework\Model\AbstractModel
- {
- /**
- * @var \Magento\Framework\Stdlib\DateTime
- */
- private $dateTime;
- /**
- * Wishlist constructor.
- *
- * @param \Magento\Framework\Model\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\Stdlib\DateTime $dateTime
- * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
- * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
- * @param array $data
- */
- public function __construct(
- \Magento\Framework\Model\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\Stdlib\DateTime $dateTime,
- \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
- \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
- array $data = []
- ) {
- $this->dateTime = $dateTime;
- parent::__construct(
- $context,
- $registry,
- $resource,
- $resourceCollection,
- $data
- );
- }
- /**
- * Constructor.
- *
- * @return null
- */
- public function _construct()
- {
- parent::_construct();
- $this->_init(\Dotdigitalgroup\Email\Model\ResourceModel\Wishlist::class);
- }
- /**
- * Prepare data to be saved to database.
- *
- * @return $this
- */
- public function beforeSave()
- {
- parent::beforeSave();
- if ($this->isObjectNew() && !$this->getCreatedAt()) {
- $this->setCreatedAt($this->dateTime->formatDate(true));
- }
- $this->setUpdatedAt($this->dateTime->formatDate(true));
- return $this;
- }
- }
|