Skip to content

Commit be7cbf2

Browse files
author
Volodymyr Klymenko
authored
Merge pull request magento#967 from magento-firedrakes/bugfixes
[Firedrakes] Analytics critical changes
2 parents ab23fb9 + c936991 commit be7cbf2

File tree

107 files changed

+3154
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3154
-474
lines changed

app/code/Magento/Analytics/Api/Data/LinkInterface.php

-12
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,4 @@ public function getUrl();
2121
* @return string
2222
*/
2323
public function getInitializationVector();
24-
25-
/**
26-
* @param string $url
27-
* @return void
28-
*/
29-
public function setUrl($url);
30-
31-
/**
32-
* @param string $initializationVector
33-
* @return void
34-
*/
35-
public function setInitializationVector($initializationVector);
3624
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Block\Adminhtml\System\Config;
7+
8+
/**
9+
* Provides field with additional information
10+
*/
11+
class AdditionalComment extends \Magento\Config\Block\System\Config\Form\Field
12+
{
13+
/**
14+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
15+
* @return string
16+
*/
17+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
18+
{
19+
$html = '<div class="config-additional-comment-title">' . $element->getLabel() . '</div>';
20+
$html .= '<div class="config-additional-comment-content">' . $element->getComment() . '</div>';
21+
return $this->decorateRowHtml($element, $html);
22+
}
23+
24+
/**
25+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
26+
* @param string $html
27+
* @return string
28+
*/
29+
private function decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
30+
{
31+
return sprintf(
32+
'<tr id="row_%s"><td colspan="3"><div class="config-additional-comment">%s</div></td></tr>',
33+
$element->getHtmlId(),
34+
$html
35+
);
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Block\Adminhtml\System\Config;
7+
8+
/**
9+
* Provides label with default Time Zone
10+
*/
11+
class CollectionTimeLabel extends \Magento\Config\Block\System\Config\Form\Field
12+
{
13+
/**
14+
* Add default time zone to comment
15+
*
16+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
17+
* @return string
18+
*/
19+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
20+
{
21+
$timeZoneCode = $this->_localeDate->getConfigTimezone();
22+
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)->getDisplayName();
23+
$element->setData(
24+
'comment',
25+
sprintf("%s (%s)", $getLongTimeZoneName, $timeZoneCode)
26+
);
27+
return parent::render($element);
28+
}
29+
}

app/code/Magento/Analytics/Block/Adminhtml/System/Config/SubscriptionStatusLabel.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@ public function __construct(
3939
}
4040

4141
/**
42-
* Unset some non-related element parameters
42+
* Add Subscription status to comment
4343
*
4444
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
4545
* @return string
4646
*/
4747
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
4848
{
49-
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
5049
$element->setData(
51-
'value',
50+
'comment',
5251
$this->prepareLabelValue()
5352
);
5453
return parent::render($element);

app/code/Magento/Analytics/Controller/Adminhtml/BasicTier/SignUp.php app/code/Magento/Analytics/Controller/Adminhtml/BIEssentials/SignUp.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,38 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Analytics\Controller\Adminhtml\BasicTier;
6+
namespace Magento\Analytics\Controller\Adminhtml\BIEssentials;
77

88
use Magento\Backend\App\Action;
9-
use Magento\Config\Model\Config;
109
use Magento\Backend\App\Action\Context;
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
1111

1212
/**
1313
* Class SignUp
1414
*
15-
* Provides link to Basic Tier signup
15+
* Provides link to BI Essentials signup
1616
*/
1717
class SignUp extends Action
1818
{
1919
/**
20+
* Path to config value with URL to BI Essentials sign-up page.
21+
*
2022
* @var string
2123
*/
22-
private $basicTierUrlPath = 'analytics/url/basic_tier';
24+
private $urlBIEssentialsConfigPath = 'analytics/url/bi_essentials';
2325

2426
/**
25-
* @var Config
27+
* @var ScopeConfigInterface
2628
*/
2729
private $config;
2830

2931
/**
3032
* @param Context $context
31-
* @param Config $config
33+
* @param ScopeConfigInterface $config
3234
*/
3335
public function __construct(
3436
Context $context,
35-
Config $config
37+
ScopeConfigInterface $config
3638
) {
3739
$this->config = $config;
3840
parent::__construct($context);
@@ -45,18 +47,18 @@ public function __construct(
4547
*/
4648
protected function _isAllowed()
4749
{
48-
return $this->_authorization->isAllowed('Magento_Analytics::report_basic_tier');
50+
return $this->_authorization->isAllowed('Magento_Analytics::bi_essentials');
4951
}
5052

5153
/**
52-
* Provides link to Basic Tier signup
54+
* Provides link to BI Essentials signup
5355
*
5456
* @return \Magento\Framework\Controller\AbstractResult
5557
*/
5658
public function execute()
5759
{
5860
return $this->resultRedirectFactory->create()->setUrl(
59-
$this->config->getConfigDataValue($this->basicTierUrlPath)
61+
$this->config->getValue($this->urlBIEssentialsConfigPath)
6062
);
6163
}
6264
}

app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Activate.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
use Psr\Log\LoggerInterface;
1717

1818
/**
19-
* Class Activate
20-
*
21-
* Activates subscription with Free Tier program
19+
* Activates subscription to Magento BI Advanced Reporting.
2220
*/
2321
class Activate extends Action
2422
{
2523
/**
26-
* Resource for managing subscription to Magento Analytics.
24+
* Resource for managing subscription to Magento BI.
2725
*
2826
* @var Subscription
2927
*/
@@ -35,7 +33,7 @@ class Activate extends Action
3533
private $logger;
3634

3735
/**
38-
* Resource for managing last notification time about subscription to Magento Analytics.
36+
* Resource for managing last notification time about subscription to Magento BI.
3937
*
4038
* @var NotificationTime
4139
*/
@@ -79,7 +77,7 @@ protected function _isAllowed()
7977
}
8078

8179
/**
82-
* Activate subscription to Magento Analytics via AJAX.
80+
* Activate subscription to Magento BI via AJAX.
8381
*
8482
* @return Json
8583
*/

app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Postpone.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
use Psr\Log\LoggerInterface;
1717

1818
/**
19-
* Class Postpone
20-
*
21-
* Postpones notification about Free Tier program
19+
* Postpones notification about subscription to Magento BI Advanced Reporting.
2220
*/
2321
class Postpone extends Action
2422
{
@@ -38,8 +36,6 @@ class Postpone extends Action
3836
private $logger;
3937

4038
/**
41-
* Postpone constructor.
42-
*
4339
* @param Context $context
4440
* @param DateTimeFactory $dateTimeFactory
4541
* @param NotificationTime $notificationTime
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Analytics\Controller\Adminhtml\Subscription;
8+
9+
use Magento\Analytics\Model\Subscription;
10+
use Magento\Backend\App\Action;
11+
use Magento\Backend\App\Action\Context;
12+
use Magento\Framework\Controller\Result\Redirect;
13+
use Magento\Framework\Controller\ResultFactory;
14+
use Magento\Framework\Exception\LocalizedException;
15+
16+
/**
17+
* Retry subscription to Magento BI Advanced Reporting.
18+
*/
19+
class Retry extends Action
20+
{
21+
/**
22+
* Resource for managing subscription to Magento Analytics.
23+
*
24+
* @var Subscription
25+
*/
26+
private $subscription;
27+
28+
/**
29+
* @param Context $context
30+
* @param Subscription $subscription
31+
*/
32+
public function __construct(
33+
Context $context,
34+
Subscription $subscription
35+
) {
36+
$this->subscription = $subscription;
37+
parent::__construct($context);
38+
}
39+
40+
/**
41+
* Check admin permissions for this controller
42+
*
43+
* @return boolean
44+
*/
45+
protected function _isAllowed()
46+
{
47+
return $this->_authorization->isAllowed('Magento_Analytics::analytics_settings');
48+
}
49+
50+
/**
51+
* Retry process of subscription.
52+
*
53+
* @return Redirect
54+
*/
55+
public function execute()
56+
{
57+
/** @var Redirect $resultRedirect */
58+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
59+
try {
60+
$resultRedirect->setPath('adminhtml');
61+
$this->subscription->retry();
62+
} catch (LocalizedException $e) {
63+
$this->getMessageManager()->addExceptionMessage($e, $e->getMessage());
64+
} catch (\Exception $e) {
65+
$this->getMessageManager()->addExceptionMessage(
66+
$e,
67+
__('Sorry, there has been an error processing your request. Please try again later.')
68+
);
69+
}
70+
71+
return $resultRedirect;
72+
}
73+
}

app/code/Magento/Analytics/Cron/SignUp.php

+1-31
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
1010
use Magento\Framework\App\Config\ReinitableConfigInterface;
1111
use Magento\Framework\App\Config\Storage\WriterInterface;
12-
use Magento\AdminNotification\Model\InboxFactory;
13-
use Magento\AdminNotification\Model\ResourceModel\Inbox as InboxResource;
1412
use Magento\Analytics\Model\FlagManager;
1513

1614
/**
@@ -28,16 +26,6 @@ class SignUp
2826
*/
2927
private $configWriter;
3028

31-
/**
32-
* @var InboxFactory
33-
*/
34-
private $inboxFactory;
35-
36-
/**
37-
* @var InboxResource
38-
*/
39-
private $inboxResource;
40-
4129
/**
4230
* @var FlagManager
4331
*/
@@ -51,27 +39,19 @@ class SignUp
5139
private $reinitableConfig;
5240

5341
/**
54-
* SignUp constructor.
55-
*
5642
* @param Connector $connector
5743
* @param WriterInterface $configWriter
58-
* @param InboxFactory $inboxFactory
59-
* @param InboxResource $inboxResource
6044
* @param FlagManager $flagManager
6145
* @param ReinitableConfigInterface $reinitableConfig
6246
*/
6347
public function __construct(
6448
Connector $connector,
6549
WriterInterface $configWriter,
66-
InboxFactory $inboxFactory,
67-
InboxResource $inboxResource,
6850
FlagManager $flagManager,
6951
ReinitableConfigInterface $reinitableConfig
7052
) {
7153
$this->connector = $connector;
7254
$this->configWriter = $configWriter;
73-
$this->inboxFactory = $inboxFactory;
74-
$this->inboxResource = $inboxResource;
7555
$this->flagManager = $flagManager;
7656
$this->reinitableConfig = $reinitableConfig;
7757
}
@@ -85,20 +65,10 @@ public function __construct(
8565
public function execute()
8666
{
8767
$attemptsCount = $this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
88-
if ($attemptsCount === null) {
89-
$this->deleteAnalyticsCronExpr();
90-
return false;
91-
}
9268

93-
if ($attemptsCount <= 0) {
69+
if (($attemptsCount === null) || ($attemptsCount <= 0)) {
9470
$this->deleteAnalyticsCronExpr();
9571
$this->flagManager->deleteFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
96-
$inboxNotification = $this->inboxFactory->create();
97-
$inboxNotification->addNotice(
98-
"Analytics subscription unsuccessful",
99-
"Analytics subscription unsuccessful"
100-
);
101-
$this->inboxResource->save($inboxNotification);
10272
return false;
10373
}
10474

0 commit comments

Comments
 (0)