Skip to content

Commit

Permalink
MAGETWO-71372: #10045 Rename item resolver to item provider #10442
Browse files Browse the repository at this point in the history
 - Merge Pull Request #10442 from piotrkwiecinski/magento2:sitemap-item-provider
 - Merged commits:
   1. 16b77ca
  • Loading branch information
Oleksii Korshenko committed Aug 4, 2017
2 parents c955c32 + 16b77ca commit 8e5c686
Show file tree
Hide file tree
Showing 805 changed files with 16,524 additions and 8,689 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,35 @@
*/
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;

use Magento\Backend\App\Action;
use Magento\Framework\Controller\ResultFactory;

class AjaxMarkAsRead extends \Magento\AdminNotification\Controller\Adminhtml\Notification
{
/**
* @var \Magento\AdminNotification\Model\NotificationService
*/
private $notificationService;

/**
* @param Action\Context $context
* @param \Magento\AdminNotification\Model\NotificationService|null $notificationService
* @throws \RuntimeException
*/
public function __construct(
Action\Context $context,
\Magento\AdminNotification\Model\NotificationService $notificationService = null
) {
parent::__construct($context);
$this->notificationService = $notificationService?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\AdminNotification\Model\NotificationService::class);
}

/**
* Mark notification as read (AJAX action)
*
* @return void
* @return \Magento\Framework\Controller\Result\Json|void
* @throws \InvalidArgumentException
*/
public function execute()
{
Expand All @@ -21,17 +44,15 @@ public function execute()
$notificationId = (int)$this->getRequest()->getPost('id');
$responseData = [];
try {
$this->_objectManager->create(
\Magento\AdminNotification\Model\NotificationService::class
)->markAsRead(
$notificationId
);
$this->notificationService->markAsRead($notificationId);
$responseData['success'] = true;
} catch (\Exception $e) {
$responseData['success'] = false;
}
$this->getResponse()->representJson(
$this->_objectManager->create(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($responseData)
);

/** @var \Magento\Framework\Controller\Result\Json $resultJson */
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($responseData);
return $resultJson;
}
}
12 changes: 6 additions & 6 deletions app/code/Magento/AdminNotification/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"description": "N/A",
"require": {
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
"magento/module-store": "100.2.*",
"magento/module-backend": "100.2.*",
"magento/module-media-storage": "100.2.*",
"magento/framework": "100.2.*",
"magento/module-ui": "100.2.*",
"magento/module-store": "100.3.*",
"magento/module-backend": "100.3.*",
"magento/module-media-storage": "100.3.*",
"magento/framework": "100.3.*",
"magento/module-ui": "100.3.*",
"lib-libxml": "*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
"version": "100.3.0-dev",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
23 changes: 11 additions & 12 deletions app/code/Magento/AdminNotification/i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"Read Details","Read Details"
"Mark as Read","Mark as Read"
"Are you sure?","Are you sure?"
"Remove","Remove"
Remove,Remove
"Messages Inbox","Messages Inbox"
"You have %1 new system messages","You have %1 new system messages"
"You have %1 new system message","You have %1 new system message"
"Incoming Message","Incoming Message"
"close","close"
"Notifications","Notifications"
close,close
Notifications,Notifications
"The message has been marked as Read.","The message has been marked as Read."
"We couldn't mark the notification as Read because of an error.","We couldn't mark the notification as Read because of an error."
"Please select messages.","Please select messages."
Expand All @@ -20,10 +20,10 @@
"6 Hours","6 Hours"
"12 Hours","12 Hours"
"24 Hours","24 Hours"
"critical","critical"
"major","major"
"minor","minor"
"notice","notice"
critical,critical
major,major
minor,minor
notice,notice
"Wrong message type","Wrong message type"
"Wrong notification ID specified.","Wrong notification ID specified."
"{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. We highly recommend changing this value in your Magento <a href=""%1"">configuration</a>.","{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. We highly recommend changing this value in your Magento <a href=""%1"">configuration</a>."
Expand All @@ -32,20 +32,19 @@
"We were unable to synchronize one or more media files. Please refer to the log file for details.","We were unable to synchronize one or more media files. Please refer to the log file for details."
"Synchronization of media storages has been completed.","Synchronization of media storages has been completed."
"Your web server is set up incorrectly and allows unauthorized access to sensitive files. Please contact your hosting provider.","Your web server is set up incorrectly and allows unauthorized access to sensitive files. Please contact your hosting provider."
"Close popup","Close popup"
"Close","Close"
"System Messages:","System Messages:"
"Critical System Messages","Critical System Messages"
"Major System Messages","Major System Messages"
"System messages","System messages"
Close,Close
"See All (","See All ("
" unread)"," unread)"
"Show Toolbar","Show Toolbar"
"Show List","Show List"
"Use HTTPS to Get Feed","Use HTTPS to Get Feed"
"Update Frequency","Update Frequency"
"Last Update","Last Update"
"Severity","Severity"
Severity,Severity
"Date Added","Date Added"
"Message","Message"
"Actions","Actions"
Message,Message
Actions,Actions
18 changes: 9 additions & 9 deletions app/code/Magento/AdvancedPricingImportExport/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"description": "N/A",
"require": {
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
"magento/module-catalog": "101.1.*",
"magento/module-catalog-inventory": "100.2.*",
"magento/module-eav": "100.2.*",
"magento/module-import-export": "100.2.*",
"magento/module-catalog-import-export": "100.2.*",
"magento/module-customer": "100.2.*",
"magento/module-store": "100.2.*",
"magento/framework": "100.2.*"
"magento/module-catalog": "101.2.*",
"magento/module-catalog-inventory": "100.3.*",
"magento/module-eav": "100.3.*",
"magento/module-import-export": "100.3.*",
"magento/module-catalog-import-export": "100.3.*",
"magento/module-customer": "100.3.*",
"magento/module-store": "100.3.*",
"magento/framework": "100.3.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
"version": "100.3.0-dev",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Please correct the data sent.","Please correct the data sent."
"Entity type model \'%1\' is not found","Entity type model \'%1\' is not found"
"Entity type model '%1' is not found","Entity type model '%1' is not found"
"Entity type model must be an instance of \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType","Entity type model must be an instance of \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType"
"There are no product types available for export","There are no product types available for export"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Analytics\Controller\Adminhtml\Reports;

use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
use Magento\Analytics\Model\ReportUrlProvider;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand Down Expand Up @@ -55,6 +56,9 @@ public function execute()
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
try {
$resultRedirect->setUrl($this->reportUrlProvider->getUrl());
} catch (SubscriptionUpdateException $e) {
$this->getMessageManager()->addNoticeMessage($e->getMessage());
$resultRedirect->setPath('adminhtml');
} catch (LocalizedException $e) {
$this->getMessageManager()->addExceptionMessage($e, $e->getMessage());
$resultRedirect->setPath('adminhtml');
Expand Down
41 changes: 28 additions & 13 deletions app/code/Magento/Analytics/Cron/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/
namespace Magento\Analytics\Cron;

use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;

/**
* Class Update
* Executes by cron schedule in case base url was changed
*/
class Update
Expand All @@ -28,8 +28,6 @@ class Update
private $configWriter;

/**
* Reinitable Config Model.
*
* @var ReinitableConfigInterface
*/
private $reinitableConfig;
Expand All @@ -40,22 +38,29 @@ class Update
private $flagManager;

/**
* Update constructor.
* @var AnalyticsToken
*/
private $analyticsToken;

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

/**
Expand All @@ -65,13 +70,23 @@ public function __construct(
*/
public function execute()
{
$updateResult = $this->connector->execute('update');
if ($updateResult === false) {
return false;
$result = false;
$attemptsCount = $this->flagManager
->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);

if ($attemptsCount) {
$attemptsCount -= 1;
$result = $this->connector->execute('update');
}

if ($result || ($attemptsCount <= 0) || (!$this->analyticsToken->isTokenExist())) {
$this->flagManager
->deleteFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
$this->flagManager->deleteFlag(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
$this->configWriter->delete(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH);
$this->reinitableConfig->reinit();
}
$this->configWriter->delete(BaseUrlConfigPlugin::UPDATE_CRON_STRING_PATH);
$this->flagManager->deleteFlag(BaseUrlConfigPlugin::OLD_BASE_URL_FLAG_CODE);
$this->reinitableConfig->reinit();
return true;

return $result;
}
}
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;
}
}
Loading

0 comments on commit 8e5c686

Please sign in to comment.