1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace Dotdigitalgroup\Email\Model;
- class Review extends \Magento\Framework\Model\AbstractModel
- {
- const EMAIL_REVIEW_IMPORTED = 1;
- /**
- * @var \Magento\Framework\Stdlib\DateTime
- */
- private $dateTime;
- /**
- * Review 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\Review::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;
- }
- }
|