-
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 pull request #53 from magento-south/BUGS
[SOUTH] Bugfixes
- Loading branch information
Showing
8 changed files
with
155 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Customer\Model\Cart; | ||
|
||
use Magento\Customer\Model\Checkout\ConfigProvider; | ||
|
||
class ConfigPlugin | ||
{ | ||
/** | ||
* @var ConfigProvider | ||
*/ | ||
protected $configProvider; | ||
|
||
/** | ||
* @param ConfigProvider $configProvider | ||
*/ | ||
public function __construct( | ||
ConfigProvider $configProvider | ||
) { | ||
$this->configProvider = $configProvider; | ||
} | ||
|
||
/** | ||
* @param \Magento\Checkout\Block\Cart\Sidebar $subject | ||
* @param array $result | ||
* @return array | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterGetConfig(\Magento\Checkout\Block\Cart\Sidebar $subject, array $result) | ||
{ | ||
return array_merge_recursive($result, $this->configProvider->getConfig()); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
app/code/Magento/Customer/Model/Checkout/ConfigProvider.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,73 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Customer\Model\Checkout; | ||
|
||
use Magento\Checkout\Model\ConfigProviderInterface; | ||
use Magento\Customer\Model\Url; | ||
use Magento\Framework\UrlInterface; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
class ConfigProvider implements ConfigProviderInterface | ||
{ | ||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
protected $storeManager; | ||
|
||
/** | ||
* @var UrlInterface | ||
*/ | ||
protected $urlBuilder; | ||
|
||
/** | ||
* @param UrlInterface $urlBuilder | ||
* @param StoreManagerInterface $storeManager | ||
*/ | ||
public function __construct( | ||
UrlInterface $urlBuilder, | ||
StoreManagerInterface $storeManager | ||
) { | ||
$this->urlBuilder = $urlBuilder; | ||
$this->storeManager = $storeManager; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfig() | ||
{ | ||
return [ | ||
'customerLoginUrl' => $this->getLoginUrl(), | ||
'isRedirectRequired' => $this->isRedirectRequired(), | ||
]; | ||
} | ||
|
||
/** | ||
* Returns URL to login controller action | ||
* | ||
* @return string | ||
*/ | ||
protected function getLoginUrl() | ||
{ | ||
return $this->urlBuilder->getUrl(Url::ROUTE_ACCOUNT_LOGIN); | ||
} | ||
|
||
/** | ||
* Whether redirect to login page is required | ||
* | ||
* @return bool | ||
*/ | ||
protected function isRedirectRequired() | ||
{ | ||
$baseUrl = $this->storeManager->getStore()->getBaseUrl(); | ||
|
||
if (strpos($this->getLoginUrl(), $baseUrl) !== false) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
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