Skip to content

Commit 1a73182

Browse files
committed
Created separate block class inheriting TabWrapper and removed public methods from API block class
1 parent e062906 commit 1a73182

File tree

3 files changed

+77
-58
lines changed

3 files changed

+77
-58
lines changed

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -97,59 +97,4 @@ protected function _getCustomer()
9797
);
9898
return $customerDataObject;
9999
}
100-
101-
/**
102-
* @return bool
103-
*/
104-
public function canShowTab()
105-
{
106-
if ($this->_getCustomer()->getId()) {
107-
return true;
108-
}
109-
return false;
110-
}
111-
112-
/**
113-
* @return \Magento\Framework\Phrase
114-
*/
115-
public function getTabLabel()
116-
{
117-
return __('Shopping cart');
118-
}
119-
120-
/**
121-
* @return \Magento\Framework\Phrase
122-
*/
123-
public function getTabTitle()
124-
{
125-
return __('Shopping cart');
126-
}
127-
128-
/**
129-
* Return URL link to Tab content, used with isAjaxLoaded to true
130-
*
131-
* @return string
132-
*/
133-
public function getTabUrl()
134-
{
135-
return $this->getUrl('customer/*/cart', ['_current' => true]);
136-
}
137-
138-
/**
139-
* Tab should be loaded trough Ajax call
140-
*
141-
* @return bool
142-
*/
143-
public function isAjaxLoaded()
144-
{
145-
return true;
146-
}
147-
148-
/**
149-
* @return bool
150-
*/
151-
public function canDisplayContainer()
152-
{
153-
return true;
154-
}
155100
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Block\Adminhtml;
7+
8+
use Magento\Backend\Block\Template\Context;
9+
use Magento\Customer\Controller\RegistryConstants;
10+
use Magento\Framework\Registry;
11+
use Magento\Ui\Component\Layout\Tabs\TabWrapper;
12+
13+
/**
14+
* Class ShoppingCarts
15+
*
16+
* @package Magento\Sales\Block\Adminhtml
17+
*/
18+
class ShoppingCartsTab extends TabWrapper
19+
{
20+
/**
21+
* Core registry
22+
*
23+
* @var Registry
24+
*/
25+
protected $coreRegistry = null;
26+
27+
/**
28+
* @var bool
29+
*/
30+
protected $isAjaxLoaded = true;
31+
32+
/**
33+
* Constructor
34+
*
35+
* @param Context $context
36+
* @param Registry $registry
37+
* @param array $data
38+
*/
39+
public function __construct(Context $context, Registry $registry, array $data = [])
40+
{
41+
$this->coreRegistry = $registry;
42+
parent::__construct($context, $data);
43+
}
44+
45+
/**
46+
* @inheritdoc
47+
*/
48+
public function canShowTab()
49+
{
50+
return $this->coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
51+
}
52+
53+
/**
54+
* Return Tab label
55+
*
56+
* @codeCoverageIgnore
57+
*
58+
* @return \Magento\Framework\Phrase
59+
*/
60+
public function getTabLabel()
61+
{
62+
return __('Shopping cart');
63+
}
64+
65+
/**
66+
* Return URL link to Tab content
67+
*
68+
* @return string
69+
*/
70+
public function getTabUrl()
71+
{
72+
return $this->getUrl('customer/*/cart', ['_current' => true]);
73+
}
74+
}

app/code/Magento/Sales/view/base/ui_component/customer_form.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
*/
77
-->
88
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
9-
<htmlContent name="cart_content">
10-
<block class="Magento\Customer\Block\Adminhtml\Edit\Tab\Carts" name="cart"/>
11-
</htmlContent>
129
<htmlContent name="orders_content">
1310
<block acl="Magento_Sales::actions_view" class="Magento\Sales\Block\Adminhtml\CustomerOrdersTab" name="orders" />
1411
</htmlContent>
12+
<htmlContent name="cart_content">
13+
<block class="Magento\Sales\Block\Adminhtml\ShoppingCartsTab" name="cart"/>
14+
</htmlContent>
1515
</form>

0 commit comments

Comments
 (0)