1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Security\Model\ResourceModel;
/**
* Password reset request event mysql resource model
*/
class PasswordResetRequestEvent extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* @var \Magento\Framework\Stdlib\DateTime
*/
protected $dateTime;
/**
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param null $connectionName
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Framework\Stdlib\DateTime $dateTime,
$connectionName = null
) {
parent::__construct($context, $connectionName);
$this->dateTime = $dateTime;
}
/**
* Initialize resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('password_reset_request_event', 'id');
}
/**
* Delete records which has been created earlier than specified timestamp
*
* @param int $timestamp
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function deleteRecordsOlderThen($timestamp)
{
$this->getConnection()->delete(
$this->getMainTable(),
['created_at < ?' => $this->dateTime->formatDate($timestamp)]
);
return $this;
}
}