File tree Expand file tree Collapse file tree 2 files changed +49
-13
lines changed Expand file tree Collapse file tree 2 files changed +49
-13
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \Customer \Model ;
9
+
10
+ use Magento \Framework \App \RequestInterface ;
11
+
12
+ /**
13
+ * Provides customer id from request.
14
+ */
15
+ class CustomerIdProvider
16
+ {
17
+ /**
18
+ * @var RequestInterface
19
+ */
20
+ private $ request ;
21
+
22
+ /**
23
+ * @param RequestInterface $request
24
+ */
25
+ public function __construct (
26
+ RequestInterface $ request
27
+ ) {
28
+ $ this ->request = $ request ;
29
+ }
30
+
31
+ /**
32
+ * Get customer id from request.
33
+ *
34
+ * @return int
35
+ */
36
+ public function getCustomerId (): int
37
+ {
38
+ return (int )$ this ->request ->getParam ('id ' );
39
+ }
40
+ }
Original file line number Diff line number Diff line change 6
6
namespace Magento \Sales \Block \Adminhtml ;
7
7
8
8
use Magento \Backend \Block \Template \Context ;
9
- use Magento \Customer \Controller \ RegistryConstants ;
9
+ use Magento \Customer \Model \ CustomerIdProvider ;
10
10
use Magento \Framework \Registry ;
11
11
use Magento \Ui \Component \Layout \Tabs \TabWrapper ;
12
12
18
18
class ShoppingCartsTab extends TabWrapper
19
19
{
20
20
/**
21
- * Core registry
22
- *
23
- * @var Registry
21
+ * @var bool
24
22
*/
25
- private $ coreRegistry ;
23
+ protected $ isAjaxLoaded = true ;
26
24
27
25
/**
28
- * @var bool
26
+ * @var CustomerIdProvider
29
27
*/
30
- protected $ isAjaxLoaded = true ;
28
+ private $ customerIdProvider ;
31
29
32
30
/**
33
- * Constructor
34
- *
35
31
* @param Context $context
36
- * @param Registry $registry
32
+ * @param CustomerIdProvider $customerIdProvider
37
33
* @param array $data
38
34
*/
39
- public function __construct (Context $ context , Registry $ registry , array $ data = [])
35
+ public function __construct (Context $ context , CustomerIdProvider $ customerIdProvider , array $ data = [])
40
36
{
41
- $ this ->coreRegistry = $ registry ;
42
37
parent ::__construct ($ context , $ data );
38
+ $ this ->customerIdProvider = $ customerIdProvider ;
43
39
}
44
40
45
41
/**
46
42
* @inheritdoc
47
43
*/
48
44
public function canShowTab ()
49
45
{
50
- return $ this ->coreRegistry -> registry (RegistryConstants:: CURRENT_CUSTOMER_ID );
46
+ return $ this ->customerIdProvider -> getCustomerId ( );
51
47
}
52
48
53
49
/**
You can’t perform that action at this time.
0 commit comments