-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'mainline/develop' into publication
- Loading branch information
Showing
81 changed files
with
4,482 additions
and
2,183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Checkout\Controller\Sidebar; | ||
|
||
use Magento\Checkout\Model\Sidebar; | ||
use Magento\Framework\App\Action\Action; | ||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\App\Response\Http; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Json\Helper\Data; | ||
use Magento\Framework\View\Result\PageFactory; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class RemoveItem extends Action | ||
{ | ||
/** | ||
* @var Sidebar | ||
*/ | ||
protected $sidebar; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
protected $logger; | ||
|
||
/** | ||
* @var Data | ||
*/ | ||
protected $jsonHelper; | ||
|
||
/** | ||
* @var PageFactory | ||
*/ | ||
protected $resultPageFactory; | ||
|
||
/** | ||
* @param Context $context | ||
* @param Sidebar $sidebar | ||
* @param LoggerInterface $logger | ||
* @param Data $jsonHelper | ||
* @param PageFactory $resultPageFactory | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Sidebar $sidebar, | ||
LoggerInterface $logger, | ||
Data $jsonHelper, | ||
PageFactory $resultPageFactory | ||
) { | ||
$this->sidebar = $sidebar; | ||
$this->logger = $logger; | ||
$this->jsonHelper = $jsonHelper; | ||
$this->resultPageFactory = $resultPageFactory; | ||
parent::__construct($context); | ||
} | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function execute() | ||
{ | ||
$itemId = (int)$this->getRequest()->getParam('item_id'); | ||
try { | ||
$this->sidebar->checkQuoteItem($itemId); | ||
$this->sidebar->removeQuoteItem($itemId); | ||
return $this->jsonResponse(); | ||
} catch (LocalizedException $e) { | ||
return $this->jsonResponse($e->getMessage()); | ||
} catch (\Exception $e) { | ||
$this->logger->critical($e); | ||
return $this->jsonResponse($e->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Compile JSON response | ||
* | ||
* @param string $error | ||
* @return Http | ||
*/ | ||
protected function jsonResponse($error = '') | ||
{ | ||
$response = $this->sidebar->getResponseData($error); | ||
|
||
if (empty($error)) { | ||
$resultPage = $this->resultPageFactory->create(); | ||
$block = $resultPage->getLayout()->getBlock('minicart.content')->toHtml(); | ||
$response['content'] = $block; | ||
} | ||
|
||
return $this->getResponse()->representJson( | ||
$this->jsonHelper->jsonEncode($response) | ||
); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
app/code/Magento/Checkout/Controller/Sidebar/UpdateItemQty.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Checkout\Controller\Sidebar; | ||
|
||
use Magento\Checkout\Model\Sidebar; | ||
use Magento\Framework\App\Action\Action; | ||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\App\Response\Http; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Json\Helper\Data; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class UpdateItemQty extends Action | ||
{ | ||
/** | ||
* @var Sidebar | ||
*/ | ||
protected $sidebar; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
protected $logger; | ||
|
||
/** | ||
* @var Data | ||
*/ | ||
protected $jsonHelper; | ||
|
||
/** | ||
* @param Context $context | ||
* @param Sidebar $sidebar | ||
* @param LoggerInterface $logger | ||
* @param Data $jsonHelper | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Sidebar $sidebar, | ||
LoggerInterface $logger, | ||
Data $jsonHelper | ||
) { | ||
$this->sidebar = $sidebar; | ||
$this->logger = $logger; | ||
$this->jsonHelper = $jsonHelper; | ||
parent::__construct($context); | ||
} | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function execute() | ||
{ | ||
$itemId = (int)$this->getRequest()->getParam('item_id'); | ||
$itemQty = (int)$this->getRequest()->getParam('item_qty'); | ||
|
||
try { | ||
$this->sidebar->checkQuoteItem($itemId); | ||
$this->sidebar->updateQuoteItem($itemId, $itemQty); | ||
return $this->jsonResponse(); | ||
} catch (LocalizedException $e) { | ||
return $this->jsonResponse($e->getMessage()); | ||
} catch (\Exception $e) { | ||
$this->logger->critical($e); | ||
return $this->jsonResponse($e->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Compile JSON response | ||
* | ||
* @param string $error | ||
* @return Http | ||
*/ | ||
protected function jsonResponse($error = '') | ||
{ | ||
return $this->getResponse()->representJson( | ||
$this->jsonHelper->jsonEncode($this->sidebar->getResponseData($error)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.