5
5
*/
6
6
namespace Magento \Backend \Model \Auth ;
7
7
8
- use Magento \Framework \Acl ;
9
- use Magento \Framework \AclFactory ;
10
- use Magento \Framework \App \ObjectManager ;
11
8
use Magento \Framework \Stdlib \Cookie \CookieMetadataFactory ;
12
9
use Magento \Framework \Stdlib \CookieManagerInterface ;
13
- use Magento \Backend \Spi \SessionUserHydratorInterface ;
14
- use Magento \Backend \Spi \SessionAclHydratorInterface ;
15
- use Magento \User \Model \User ;
16
- use Magento \User \Model \UserFactory ;
17
10
18
11
/**
19
12
* Backend Auth session model
20
13
*
21
14
* @api
15
+ * @method \Magento\User\Model\User|null getUser()
16
+ * @method \Magento\Backend\Model\Auth\Session setUser(\Magento\User\Model\User $value)
17
+ * @method \Magento\Framework\Acl|null getAcl()
18
+ * @method \Magento\Backend\Model\Auth\Session setAcl(\Magento\Framework\Acl $value)
22
19
* @method int getUpdatedAt()
23
20
* @method \Magento\Backend\Model\Auth\Session setUpdatedAt(int $value)
24
21
*
@@ -59,36 +56,6 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
59
56
*/
60
57
protected $ _config ;
61
58
62
- /**
63
- * @var SessionUserHydratorInterface
64
- */
65
- private $ userHydrator ;
66
-
67
- /**
68
- * @var SessionAclHydratorInterface
69
- */
70
- private $ aclHydrator ;
71
-
72
- /**
73
- * @var UserFactory
74
- */
75
- private $ userFactory ;
76
-
77
- /**
78
- * @var AclFactory
79
- */
80
- private $ aclFactory ;
81
-
82
- /**
83
- * @var User|null
84
- */
85
- private $ user ;
86
-
87
- /**
88
- * @var Acl|null
89
- */
90
- private $ acl ;
91
-
92
59
/**
93
60
* @param \Magento\Framework\App\Request\Http $request
94
61
* @param \Magento\Framework\Session\SidResolverInterface $sidResolver
@@ -103,10 +70,6 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
103
70
* @param \Magento\Backend\Model\UrlInterface $backendUrl
104
71
* @param \Magento\Backend\App\ConfigInterface $config
105
72
* @throws \Magento\Framework\Exception\SessionException
106
- * @param SessionUserHydratorInterface|null $userHydrator
107
- * @param SessionAclHydratorInterface|null $aclHydrator
108
- * @param UserFactory|null $userFactory
109
- * @param AclFactory|null $aclFactory
110
73
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
111
74
*/
112
75
public function __construct (
@@ -121,19 +84,11 @@ public function __construct(
121
84
\Magento \Framework \App \State $ appState ,
122
85
\Magento \Framework \Acl \Builder $ aclBuilder ,
123
86
\Magento \Backend \Model \UrlInterface $ backendUrl ,
124
- \Magento \Backend \App \ConfigInterface $ config ,
125
- ?SessionUserHydratorInterface $ userHydrator = null ,
126
- ?SessionAclHydratorInterface $ aclHydrator = null ,
127
- ?UserFactory $ userFactory = null ,
128
- ?AclFactory $ aclFactory = null
87
+ \Magento \Backend \App \ConfigInterface $ config
129
88
) {
130
89
$ this ->_config = $ config ;
131
90
$ this ->_aclBuilder = $ aclBuilder ;
132
91
$ this ->_backendUrl = $ backendUrl ;
133
- $ this ->userHydrator = $ userHydrator ?? ObjectManager::getInstance ()->get (SessionUserHydratorInterface::class);
134
- $ this ->aclHydrator = $ aclHydrator ?? ObjectManager::getInstance ()->get (SessionAclHydratorInterface::class);
135
- $ this ->userFactory = $ userFactory ?? ObjectManager::getInstance ()->get (UserFactory::class);
136
- $ this ->aclFactory = $ aclFactory ?? ObjectManager::getInstance ()->get (AclFactory::class);
137
92
parent ::__construct (
138
93
$ request ,
139
94
$ sidResolver ,
@@ -277,16 +232,6 @@ public function processLogin()
277
232
return $ this ;
278
233
}
279
234
280
- /**
281
- * @inheritDoc
282
- */
283
- public function destroy (array $ options = null )
284
- {
285
- $ this ->user = null ;
286
- $ this ->acl = null ;
287
- parent ::destroy ($ options );
288
- }
289
-
290
235
/**
291
236
* Process of configuring of current auth storage when logout was performed
292
237
*
@@ -310,142 +255,4 @@ public function isValidForPath($path)
310
255
{
311
256
return true ;
312
257
}
313
-
314
- /**
315
- * Logged-in user.
316
- *
317
- * @return User|null
318
- */
319
- public function getUser ()
320
- {
321
- if (!$ this ->user ) {
322
- $ userData = $ this ->getUserData ();
323
- if ($ userData ) {
324
- /** @var User $user */
325
- $ user = $ this ->userFactory ->create ();
326
- $ this ->userHydrator ->hydrate ($ user , $ userData );
327
- $ this ->user = $ user ;
328
- } elseif ($ user = parent ::getUser ()) {
329
- $ this ->setUser ($ user );
330
- }
331
- }
332
-
333
- return $ this ->user ;
334
- }
335
-
336
- /**
337
- * Set logged-in user instance.
338
- *
339
- * @param User|null $user
340
- * @return Session
341
- */
342
- public function setUser ($ user )
343
- {
344
- $ this ->setUserData (null );
345
- if ($ user ) {
346
- $ this ->setUserData ($ this ->userHydrator ->extract ($ user ));
347
- }
348
- $ this ->user = $ user ;
349
-
350
- return $ this ;
351
- }
352
-
353
- /**
354
- * Is user logged in?
355
- *
356
- * @return bool
357
- */
358
- public function hasUser ()
359
- {
360
- return (bool )$ this ->getUser ();
361
- }
362
-
363
- /**
364
- * Remove logged-in user.
365
- *
366
- * @return Session
367
- */
368
- public function unsUser ()
369
- {
370
- $ this ->user = null ;
371
- parent ::unsUser ();
372
- return $ this ->unsUserData ();
373
- }
374
-
375
- /**
376
- * Logged-in user's ACL data.
377
- *
378
- * @return Acl|null
379
- */
380
- public function getAcl ()
381
- {
382
- if (!$ this ->acl ) {
383
- $ aclData = $ this ->getUserAclData ();
384
- if ($ aclData ) {
385
- /** @var Acl $acl */
386
- $ acl = $ this ->aclFactory ->create ();
387
- $ this ->aclHydrator ->hydrate ($ acl , $ aclData );
388
- $ this ->acl = $ acl ;
389
- } elseif ($ acl = parent ::getAcl ()) {
390
- $ this ->setAcl ($ acl );
391
- }
392
- }
393
-
394
- return $ this ->acl ;
395
- }
396
-
397
- /**
398
- * Set logged-in user's ACL data instance.
399
- *
400
- * @param Acl|null $acl
401
- * @return Session
402
- */
403
- public function setAcl ($ acl )
404
- {
405
- $ this ->setUserAclData (null );
406
- if ($ acl ) {
407
- $ this ->setUserAclData ($ this ->aclHydrator ->extract ($ acl ));
408
- }
409
- $ this ->acl = $ acl ;
410
-
411
- return $ this ;
412
- }
413
-
414
- /**
415
- * Whether ACL data is present.
416
- *
417
- * @return bool
418
- */
419
- public function hasAcl ()
420
- {
421
- return (bool )$ this ->getAcl ();
422
- }
423
-
424
- /**
425
- * Remove ACL data.
426
- *
427
- * @return Session
428
- */
429
- public function unsAcl ()
430
- {
431
- $ this ->acl = null ;
432
- parent ::unsAcl ();
433
- return $ this ->unsUserAclData ();
434
- }
435
-
436
- /**
437
- * @inheritDoc
438
- */
439
- public function writeClose ()
440
- {
441
- //Updating data in session in case these objects has been changed.
442
- if ($ this ->user ) {
443
- $ this ->setUser ($ this ->user );
444
- }
445
- if ($ this ->acl ) {
446
- $ this ->setAcl ($ this ->acl );
447
- }
448
-
449
- parent ::writeClose ();
450
- }
451
258
}
0 commit comments