Skip to content

Commit 720799b

Browse files
committed
updated PHPDoc
1 parent d2a09d3 commit 720799b

File tree

1 file changed

+28
-36
lines changed

1 file changed

+28
-36
lines changed

app/code/Magento/Checkout/Controller/Cart/UpdateItemQty.php

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Psr\Log\LoggerInterface;
2121

2222
/**
23-
* Class UpdateItemQty
23+
* UpdateItemQty ajax request
2424
*
2525
* @package Magento\Checkout\Controller\Cart
2626
*/
@@ -55,12 +55,12 @@ class UpdateItemQty extends Action implements HttpPostActionInterface
5555
/**
5656
* UpdateItemQty constructor
5757
*
58-
* @param Context $context Parent dependency
58+
* @param Context $context
5959
* @param RequestQuantityProcessor $quantityProcessor Request quantity
60-
* @param FormKeyValidator $formKeyValidator Form validator
61-
* @param CheckoutSession $checkoutSession Session
62-
* @param Json $json Json serializer
63-
* @param LoggerInterface $logger Logger
60+
* @param FormKeyValidator $formKeyValidator Form validator
61+
* @param CheckoutSession $checkoutSession Session
62+
* @param Json $json Json serializer
63+
* @param LoggerInterface $logger Logger
6464
*/
6565

6666
public function __construct(
@@ -72,12 +72,12 @@ public function __construct(
7272
LoggerInterface $logger
7373
) {
7474
$this->quantityProcessor = $quantityProcessor;
75-
$this->formKeyValidator = $formKeyValidator;
76-
$this->checkoutSession = $checkoutSession;
77-
$this->json = $json;
78-
$this->logger = $logger;
75+
$this->formKeyValidator = $formKeyValidator;
76+
$this->checkoutSession = $checkoutSession;
77+
$this->json = $json;
78+
$this->logger = $logger;
7979
parent::__construct($context);
80-
}//end __construct()
80+
}
8181

8282
/**
8383
* Controller execute method
@@ -95,11 +95,11 @@ public function execute()
9595
$this->validateCartData($cartData);
9696

9797
$cartData = $this->quantityProcessor->process($cartData);
98-
$quote = $this->checkoutSession->getQuote();
98+
$quote = $this->checkoutSession->getQuote();
9999

100100
foreach ($cartData as $itemId => $itemInfo) {
101101
$item = $quote->getItemById($itemId);
102-
$qty = isset($itemInfo['qty']) ? (double) $itemInfo['qty'] : 0;
102+
$qty = isset($itemInfo['qty']) ? (double) $itemInfo['qty'] : 0;
103103
if ($item) {
104104
$this->updateItemQuantity($item, $qty);
105105
}
@@ -111,18 +111,16 @@ public function execute()
111111
} catch (\Exception $e) {
112112
$this->logger->critical($e->getMessage());
113113
$this->jsonResponse('Something went wrong while saving the page. Please refresh the page and try again.');
114-
}//end try
115-
}//end execute()
114+
}
115+
}
116116

117117
/**
118118
* Updates quote item quantity.
119119
*
120-
* @param Item $item
120+
* @param Item $item
121121
* @param float $qty
122-
*
123-
* @throws LocalizedException
124-
*
125122
* @return void
123+
* @throws LocalizedException
126124
*/
127125
private function updateItemQuantity(Item $item, float $qty)
128126
{
@@ -134,27 +132,25 @@ private function updateItemQuantity(Item $item, float $qty)
134132
throw new LocalizedException(__($item->getMessage()));
135133
}
136134
}
137-
}//end updateItemQuantity()
135+
}
138136

139137
/**
140138
* JSON response builder.
141139
*
142140
* @param string $error
143-
*
144141
* @return void
145142
*/
146143
private function jsonResponse(string $error = '')
147144
{
148145
$this->getResponse()->representJson(
149146
$this->json->serialize($this->getResponseData($error))
150147
);
151-
}//end jsonResponse()
148+
}
152149

153150
/**
154151
* Returns response data.
155152
*
156153
* @param string $error
157-
*
158154
* @return array
159155
*/
160156
private function getResponseData(string $error = ''): array
@@ -163,34 +159,32 @@ private function getResponseData(string $error = ''): array
163159

164160
if (!empty($error)) {
165161
$response = [
166-
'success' => false,
162+
'success' => false,
167163
'error_message' => $error,
168164
];
169165
}
170166

171167
return $response;
172-
}//end getResponseData()
168+
}
173169

174170
/**
175171
* Validates the Request HTTP method
176172
*
177-
* @throws NotFoundException
178-
*
179173
* @return void
174+
* @throws NotFoundException
180175
*/
181176
private function validateRequest()
182177
{
183178
if ($this->getRequest()->isPost() === false) {
184179
throw new NotFoundException(__('Page Not Found'));
185180
}
186-
}//end validateRequest()
181+
}
187182

188183
/**
189184
* Validates form key
190185
*
191-
* @throws LocalizedException
192-
*
193186
* @return void
187+
* @throws LocalizedException
194188
*/
195189
private function validateFormKey()
196190
{
@@ -199,16 +193,14 @@ private function validateFormKey()
199193
__('Something went wrong while saving the page. Please refresh the page and try again.')
200194
);
201195
}
202-
}//end validateFormKey()
196+
}
203197

204198
/**
205199
* Validates cart data
206200
*
207201
* @param array|null $cartData
208-
*
209-
* @throws LocalizedException
210-
*
211202
* @return void
203+
* @throws LocalizedException
212204
*/
213205
private function validateCartData($cartData = null)
214206
{
@@ -217,5 +209,5 @@ private function validateCartData($cartData = null)
217209
__('Something went wrong while saving the page. Please refresh the page and try again.')
218210
);
219211
}
220-
}//end validateCartData()
221-
}//end class
212+
}
213+
}

0 commit comments

Comments
 (0)