Skip to content

Commit

Permalink
Merge 9224419 into api_coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Magento CICD authored Apr 13, 2017
2 parents e8ce36f + 9224419 commit 6e2fa56
Show file tree
Hide file tree
Showing 194 changed files with 4,316 additions and 1,680 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ atlassian*
!/pub/media/customer/.htaccess
/pub/media/downloadable/*
!/pub/media/downloadable/.htaccess
/pub/media/favicon/*
/pub/media/import/*
!/pub/media/import/.htaccess
/pub/media/theme/*
Expand Down
2 changes: 1 addition & 1 deletion COPYING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy.

Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file.
Please see <insert file name of the MEE license> for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise.
Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,33 @@ To suggest documentation improvements, click [here][4].
[3]: <https://github.com/magento/magento2/issues>
[4]: <http://devdocs.magento.com>

<h3>Labels applied by the Magento team</h3>

| Label | Description |
| ------------- |-------------|
| ![DOC](http://devdocs.magento.com/common/images/github_DOC.png) | Affects Documentation domain. |
| ![PROD](http://devdocs.magento.com/common/images/github_PROD.png) | Affects the Product team (mostly feature requests or business logic change). |
| ![TECH](http://devdocs.magento.com/common/images/github_TECH.png) | Affects Architect Group (mostly to make decisions around technology changes). |
| ![accept](http://devdocs.magento.com/common/images/github_accept.png) | The pull request has been accepted and will be merged into mainline code. |
| ![reject](http://devdocs.magento.com/common/images/github_reject.png) | The pull request has been rejected and will not be merged into mainline code. Possible reasons can include but are not limited to: issue has already been fixed in another code contribution, or there is an issue with the code contribution. |
| ![bug report](http://devdocs.magento.com/common/images/github_bug.png) | The Magento Team has confirmed that this issue contains the minimum required information to reproduce. |
| ![acknowledged](http://devdocs.magento.com/common/images/gitHub_acknowledged.png) | The Magento Team has validated the issue and an internal ticket has been created. |
| ![acknowledged](http://devdocs.magento.com/common/images/github_inProgress.png) | The internal ticket is currently in progress, fix is scheduled to be delivered. |
| ![acknowledged](http://devdocs.magento.com/common/images/github_needsUpdate.png) | The Magento Team needs additional information from the reporter to properly prioritize and process the issue or pull request. |

<h2>Reporting security issues</h2>

To report security vulnerabilities in Magento software or web sites, please e-mail <a href="mailto:security@magento.com">security@magento.com</a>. Please do not report security issues using GitHub. Be sure to encrypt your e-mail with our <a href="https://info2.magento.com/rs/magentoenterprise/images/security_at_magento.asc">encryption key</a> if it includes sensitive information. Learn more about reporting security issues <a href="https://magento.com/security/reporting-magento-security-issue">here</a>.

Stay up-to-date on the latest vulnerabilities and patches for Magento by signing up for <a href="https://magento.com/security/sign-up">Security Alert Notifications</a>.
Stay up-to-date on the latest security news and patches for Magento by signing up for <a href="https://magento.com/security/sign-up">Security Alert Notifications</a>.

<h2>License</h2>

Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license

http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy.

Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file.
Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise.

Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,24 @@

namespace Magento\Analytics\Controller\Adminhtml\Subscription;

use Magento\Analytics\Model\Config\Backend\Enabled;
use Magento\Analytics\Model\NotificationTime;
use Magento\Analytics\Model\Subscription;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Config\Model\Config\Source\Enabledisable;
use Magento\Config\Model\PreparedValueFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Psr\Log\LoggerInterface;

/**
* Activates subscription to Magento BI Advanced Reporting.
*/
class Activate extends Action
{
/**
* Resource for managing subscription to Magento BI.
*
* @var Subscription
*/
private $subscription;

/**
* @var LoggerInterface
*/
Expand All @@ -46,23 +43,36 @@ class Activate extends Action
*/
private $subscriptionApprovedField = 'analytics_subscription_checkbox';

/**
* @var AbstractDb
*/
private $configValueResource;

/**
* @var PreparedValueFactory
*/
private $preparedValueFactory;

/**
* Activate constructor.
*
* @param Context $context
* @param Subscription $subscription
* @param LoggerInterface $logger
* @param NotificationTime $notificationTime
* @param AbstractDb $configValueResource
* @param PreparedValueFactory $preparedValueFactory
*/
public function __construct(
Context $context,
Subscription $subscription,
LoggerInterface $logger,
NotificationTime $notificationTime
NotificationTime $notificationTime,
AbstractDb $configValueResource,
PreparedValueFactory $preparedValueFactory
) {
$this->subscription = $subscription;
$this->logger = $logger;
$this->notificationTime = $notificationTime;
$this->configValueResource = $configValueResource;
$this->preparedValueFactory = $preparedValueFactory;
parent::__construct($context);
}

Expand All @@ -85,7 +95,14 @@ public function execute()
{
try {
if ($this->getRequest()->getParam($this->subscriptionApprovedField)) {
$this->subscription->enable();
$configValue = $this->preparedValueFactory->create(
Enabled::XML_ENABLED_CONFIG_STRUCTURE_PATH,
Enabledisable::ENABLE_VALUE,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);

$this->configValueResource
->save($configValue);
} else {
$this->notificationTime->unsetLastTimeNotificationValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Magento\Analytics\Controller\Adminhtml\Subscription;

use Magento\Analytics\Model\Subscription;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\Result\Redirect;
Expand All @@ -21,19 +21,19 @@ class Retry extends Action
/**
* Resource for managing subscription to Magento Analytics.
*
* @var Subscription
* @var SubscriptionHandler
*/
private $subscription;
private $subscriptionHandler;

/**
* @param Context $context
* @param Subscription $subscription
* @param SubscriptionHandler $subscriptionHandler
*/
public function __construct(
Context $context,
Subscription $subscription
SubscriptionHandler $subscriptionHandler
) {
$this->subscription = $subscription;
$this->subscriptionHandler = $subscriptionHandler;
parent::__construct($context);
}

Expand All @@ -58,7 +58,7 @@ public function execute()
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
try {
$resultRedirect->setPath('adminhtml');
$this->subscription->retry();
$this->subscriptionHandler->processEnabled();
} catch (LocalizedException $e) {
$this->getMessageManager()->addExceptionMessage($e, $e->getMessage());
} catch (\Exception $e) {
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Analytics/Model/Config/Backend/Enabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
*/
class Enabled extends Value
{
/**
* Path to field subscription enabled into config structure.
*/
const XML_ENABLED_CONFIG_STRUCTURE_PATH = 'analytics/general/enabled';

/**
* Service for processing of activation/deactivation MBI subscription.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\CollectionTime;
use Magento\Analytics\Model\NotificationTime;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;

/**
* Class for processing of activation/deactivation MBI subscription.
Expand Down Expand Up @@ -61,22 +62,30 @@ class SubscriptionHandler
*/
private $notificationTime;

/**
* @var ReinitableConfigInterface
*/
private $reinitableConfig;

/**
* @param WriterInterface $configWriter
* @param FlagManager $flagManager
* @param AnalyticsToken $analyticsToken
* @param NotificationTime $notificationTime
* @param ReinitableConfigInterface $reinitableConfig
*/
public function __construct(
WriterInterface $configWriter,
FlagManager $flagManager,
AnalyticsToken $analyticsToken,
NotificationTime $notificationTime
NotificationTime $notificationTime,
ReinitableConfigInterface $reinitableConfig
) {
$this->configWriter = $configWriter;
$this->flagManager = $flagManager;
$this->analyticsToken = $analyticsToken;
$this->notificationTime = $notificationTime;
$this->reinitableConfig = $reinitableConfig;
}

/**
Expand All @@ -92,6 +101,7 @@ public function processEnabled()
$this->setCronSchedule();
$this->setAttemptsFlag();
$this->notificationTime->unsetLastTimeNotificationValue();
$this->reinitableConfig->reinit();
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ interface CommandInterface
/**
* Execute call to external service
* Information about destination and arguments appears from config
* @return void
*
* @return bool
*/
public function execute();
}
77 changes: 55 additions & 22 deletions app/code/Magento/Analytics/Model/Connector/Http/Client/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
namespace Magento\Analytics\Model\Connector\Http\Client;

use Magento\Analytics\Model\Connector\Http\ResponseFactory;
use Magento\Framework\HTTP\Adapter\CurlFactory;
use Magento\Analytics\Model\Connector\Http\ConverterInterface;
use Psr\Log\LoggerInterface;
use Magento\Framework\HTTP\Adapter\CurlFactory;
use Magento\Analytics\Model\Connector\Http\ResponseFactory;

/**
* A CURL HTTP client.
Expand All @@ -16,11 +17,6 @@
*/
class Curl implements \Magento\Analytics\Model\Connector\Http\ClientInterface
{
/**
* @var LoggerInterface
*/
private $logger;

/**
* @var CurlFactory
*/
Expand All @@ -31,46 +27,83 @@ class Curl implements \Magento\Analytics\Model\Connector\Http\ClientInterface
*/
private $responseFactory;

/**
* @var ConverterInterface
*/
private $converter;

/**
* @var LoggerInterface
*/
private $logger;

/**
* @param CurlFactory $curlFactory
* @param ResponseFactory $responseFactory
* @param ConverterInterface $converter
* @param LoggerInterface $logger
*/
public function __construct(
CurlFactory $curlFactory,
ResponseFactory $responseFactory,
ConverterInterface $converter,
LoggerInterface $logger
) {
$this->curlFactory = $curlFactory;
$this->responseFactory = $responseFactory;
$this->converter = $converter;
$this->logger = $logger;
}

/**
* {@inheritdoc}
*/
public function request($method, $url, $body = '', array $headers = [], $version = '1.1')
public function request($method, $url, array $body = [], array $headers = [], $version = '1.1')
{
$curl = $this->curlFactory->create();
$response = new \Zend_Http_Response(0, []);

$curl->write($method, $url, $version, $headers, $body);
try {
$curl = $this->curlFactory->create();
$headers = $this->applyContentTypeHeaderFromConverter($headers);

$result = $curl->read();
$curl->write($method, $url, $version, $headers, $this->converter->toBody($body));

if ($curl->getErrno()) {
$this->logger->critical(
new \Exception(
sprintf(
'MBI service CURL connection error #%s: %s',
$curl->getErrno(),
$curl->getError()
$result = $curl->read();

if ($curl->getErrno()) {
$this->logger->critical(
new \Exception(
sprintf(
'MBI service CURL connection error #%s: %s',
$curl->getErrno(),
$curl->getError()
)
)
)
);
);

return $response;
}

return false;
$response = $this->responseFactory->create($result);
} catch (\Exception $e) {
$this->logger->critical($e);
}

return $response;
}

/**
* @param array $headers
*
* @return array
*/
private function applyContentTypeHeaderFromConverter(array $headers)
{
$contentTypeHeaderKey = array_search($this->converter->getContentTypeHeader(), $headers);
if ($contentTypeHeaderKey === false) {
$headers[] = $this->converter->getContentTypeHeader();
}

return $this->responseFactory->create($result);
return $headers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ interface ClientInterface
*
* @param string $method
* @param string $url
* @param string $body
* @param array $body
* @param array $headers
* @param string $version
*
* @return \Zend_Http_Response|bool
* @return \Zend_Http_Response
*/
public function request($method, $url, $body = '', array $headers = [], $version = '1.1');
public function request($method, $url, array $body = [], array $headers = [], $version = '1.1');
}
Loading

0 comments on commit 6e2fa56

Please sign in to comment.