Skip to content

Commit 7fee060

Browse files
committed
create DTO for user expiration (#19093)
1 parent 932559d commit 7fee060

File tree

3 files changed

+96
-5
lines changed

3 files changed

+96
-5
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Security\Api\Data;
10+
11+
/**
12+
* Interface UserExpirationInterface to be used as a DTO for expires_at property on User model.
13+
*/
14+
interface UserExpirationInterface
15+
{
16+
17+
const EXPIRES_AT = 'expires_at';
18+
19+
const USER_ID = 'user_id';
20+
21+
/**
22+
* `expires_at` getter.
23+
*
24+
* @return string
25+
*/
26+
public function getExpiresAt();
27+
28+
/**
29+
* `expires_at` setter.
30+
*
31+
* @param string $expiresAt
32+
* @return $this
33+
*/
34+
public function setExpiresAt($expiresAt);
35+
36+
/**
37+
* `user_id` getter.
38+
*
39+
* @return string
40+
*/
41+
public function getUserId();
42+
43+
/**
44+
* `user_id` setter.
45+
*
46+
* @param string $userId
47+
* @return $this
48+
*/
49+
public function setUserId($userId);
50+
}

app/code/Magento/Security/Model/UserExpiration.php

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77

88
namespace Magento\Security\Model;
99

10+
use Magento\Security\Api\Data\UserExpirationInterface;
11+
1012
/**
1113
* Admin User Expiration model.
12-
* @method string getUserId()
13-
* @method \Magento\Security\Model\UserExpiration setUserId($userId)
14-
* @method string getExpiresAt()
15-
* @method \Magento\Security\Model\UserExpiration setExpiresAt($value)
1614
*/
17-
class UserExpiration extends \Magento\Framework\Model\AbstractModel
15+
class UserExpiration extends \Magento\Framework\Model\AbstractModel implements UserExpirationInterface
1816
{
1917

2018
/**
@@ -26,4 +24,46 @@ protected function _construct()
2624
{
2725
$this->_init(\Magento\Security\Model\ResourceModel\UserExpiration::class);
2826
}
27+
28+
/**
29+
* `expires_at` getter.
30+
*
31+
* @return string
32+
*/
33+
public function getExpiresAt()
34+
{
35+
return $this->getData(self::EXPIRES_AT);
36+
}
37+
38+
/**
39+
* `expires_at` setter.
40+
*
41+
* @param string $expiresAt
42+
* @return $this
43+
*/
44+
public function setExpiresAt($expiresAt)
45+
{
46+
return $this->setData(self::EXPIRES_AT, $expiresAt);
47+
}
48+
49+
/**
50+
* `user_id` getter.
51+
*
52+
* @return string
53+
*/
54+
public function getUserId()
55+
{
56+
return $this->getData(self::USER_ID);
57+
}
58+
59+
/**
60+
* `user_id` setter.
61+
*
62+
* @param string $userId
63+
* @return $this
64+
*/
65+
public function setUserId($userId)
66+
{
67+
return $this->setData(self::USER_ID, $userId);
68+
}
2969
}

app/code/Magento/Security/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
</argument>
1919
</arguments>
2020
</type>
21+
<preference for="Magento\Security\Api\Data\UserExpirationInterface" type="Magento\Security\Model\UserExpiration"/>
2122
</config>

0 commit comments

Comments
 (0)