-
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 #1310 from magento-firedrakes/MAGETWO-69606
Fixed issue: - MAGETWO-69606 Conflict between BaseUrl Change and Re-Sign Up functionality in the Analytics module
- Loading branch information
Showing
22 changed files
with
1,062 additions
and
261 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
107 changes: 107 additions & 0 deletions
107
app/code/Magento/Analytics/Model/Config/Backend/Baseurl/SubscriptionUpdateHandler.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,107 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Analytics\Model\Config\Backend\Baseurl; | ||
|
||
use Magento\Analytics\Model\AnalyticsToken; | ||
use Magento\Framework\App\Config\ReinitableConfigInterface; | ||
use Magento\Framework\App\Config\Storage\WriterInterface; | ||
use Magento\Framework\FlagManager; | ||
|
||
/** | ||
* Class for processing of change of Base URL. | ||
*/ | ||
class SubscriptionUpdateHandler | ||
{ | ||
/** | ||
* Flag code for a reserve counter to update subscription. | ||
*/ | ||
const SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE = 'analytics_link_subscription_update_reverse_counter'; | ||
|
||
/** | ||
* Config path for schedule setting of update handler. | ||
*/ | ||
const UPDATE_CRON_STRING_PATH = "crontab/default/jobs/analytics_update/schedule/cron_expr"; | ||
|
||
/** | ||
* Flag code for the previous Base URL. | ||
*/ | ||
const PREVIOUS_BASE_URL_FLAG_CODE = 'analytics_previous_base_url'; | ||
|
||
/** | ||
* Max value for a reserve counter to update subscription. | ||
* | ||
* @var int | ||
*/ | ||
private $attemptsInitValue = 48; | ||
|
||
/** | ||
* @var WriterInterface | ||
*/ | ||
private $configWriter; | ||
|
||
/** | ||
* Cron expression for a update handler. | ||
* | ||
* @var string | ||
*/ | ||
private $cronExpression = '0 * * * *'; | ||
|
||
/** | ||
* @var FlagManager | ||
*/ | ||
private $flagManager; | ||
|
||
/** | ||
* @var ReinitableConfigInterface | ||
*/ | ||
private $reinitableConfig; | ||
|
||
/** | ||
* @var AnalyticsToken | ||
*/ | ||
private $analyticsToken; | ||
|
||
/** | ||
* @param AnalyticsToken $analyticsToken | ||
* @param FlagManager $flagManager | ||
* @param ReinitableConfigInterface $reinitableConfig | ||
* @param WriterInterface $configWriter | ||
*/ | ||
public function __construct( | ||
AnalyticsToken $analyticsToken, | ||
FlagManager $flagManager, | ||
ReinitableConfigInterface $reinitableConfig, | ||
WriterInterface $configWriter | ||
) { | ||
$this->analyticsToken = $analyticsToken; | ||
$this->flagManager = $flagManager; | ||
$this->reinitableConfig = $reinitableConfig; | ||
$this->configWriter = $configWriter; | ||
} | ||
|
||
/** | ||
* Activate process of subscription update handling. | ||
* | ||
* @param string $url | ||
* @return bool | ||
*/ | ||
public function processUrlUpdate(string $url) | ||
{ | ||
if ($this->analyticsToken->isTokenExist()) { | ||
if (!$this->flagManager->getFlagData(self::PREVIOUS_BASE_URL_FLAG_CODE)) { | ||
$this->flagManager->saveFlag(self::PREVIOUS_BASE_URL_FLAG_CODE, $url); | ||
} | ||
|
||
$this->flagManager | ||
->saveFlag(self::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue); | ||
$this->configWriter->save(self::UPDATE_CRON_STRING_PATH, $this->cronExpression); | ||
$this->reinitableConfig->reinit(); | ||
} | ||
|
||
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
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.