Skip to content

Commit 9e07d6e

Browse files
committed
#20918: Enabled 'Shopping Cart' tab for customer edit interface in admin.
1 parent 6d9d7f0 commit 9e07d6e

File tree

2 files changed

+49
-13
lines changed

2 files changed

+49
-13
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
}

app/code/Magento/Sales/Block/Adminhtml/ShoppingCartsTab.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Sales\Block\Adminhtml;
77

88
use Magento\Backend\Block\Template\Context;
9-
use Magento\Customer\Controller\RegistryConstants;
9+
use Magento\Customer\Model\CustomerIdProvider;
1010
use Magento\Framework\Registry;
1111
use Magento\Ui\Component\Layout\Tabs\TabWrapper;
1212

@@ -18,36 +18,32 @@
1818
class ShoppingCartsTab extends TabWrapper
1919
{
2020
/**
21-
* Core registry
22-
*
23-
* @var Registry
21+
* @var bool
2422
*/
25-
private $coreRegistry;
23+
protected $isAjaxLoaded = true;
2624

2725
/**
28-
* @var bool
26+
* @var CustomerIdProvider
2927
*/
30-
protected $isAjaxLoaded = true;
28+
private $customerIdProvider;
3129

3230
/**
33-
* Constructor
34-
*
3531
* @param Context $context
36-
* @param Registry $registry
32+
* @param CustomerIdProvider $customerIdProvider
3733
* @param array $data
3834
*/
39-
public function __construct(Context $context, Registry $registry, array $data = [])
35+
public function __construct(Context $context, CustomerIdProvider $customerIdProvider, array $data = [])
4036
{
41-
$this->coreRegistry = $registry;
4237
parent::__construct($context, $data);
38+
$this->customerIdProvider = $customerIdProvider;
4339
}
4440

4541
/**
4642
* @inheritdoc
4743
*/
4844
public function canShowTab()
4945
{
50-
return $this->coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
46+
return $this->customerIdProvider->getCustomerId();
5147
}
5248

5349
/**

0 commit comments

Comments
 (0)