Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into public-pulls
Browse files Browse the repository at this point in the history
  • Loading branch information
vpelipenko committed Feb 26, 2015
2 parents 65fee49 + 116d26d commit 8f68565
Show file tree
Hide file tree
Showing 1,181 changed files with 7,055 additions and 4,150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function execute()
$notificationId
);
$this->messageManager->addSuccess(__('The message has been marked as Read.'));
} catch (\Magento\Framework\Model\Exception $e) {
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute()
$this->messageManager->addSuccess(
__('A total of %1 record(s) have been marked as Read.', count($ids))
);
} catch (\Magento\Framework\Model\Exception $e) {
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function execute()
}
}
$this->messageManager->addSuccess(__('Total of %1 record(s) have been removed.', count($ids)));
} catch (\Magento\Framework\Model\Exception $e) {
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __("We couldn't remove the messages because of an error."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function execute()
try {
$model->setIsRemove(1)->save();
$this->messageManager->addSuccess(__('The message has been removed.'));
} catch (\Magento\Framework\Model\Exception $e) {
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __("We couldn't remove the messages because of an error."));
Expand Down
40 changes: 33 additions & 7 deletions app/code/Magento/AdminNotification/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* AdminNotification Feed model
*
* @author Magento Core Team <core@magentocommerce.com>
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Feed extends \Magento\Framework\Model\AbstractModel
{
Expand Down Expand Up @@ -50,16 +51,29 @@ class Feed extends \Magento\Framework\Model\AbstractModel
*/
protected $_deploymentConfig;

/**
* @var \Magento\Framework\App\ProductMetadataInterface
*/
protected $productMetadata;

/**
* @var \Magento\Framework\UrlInterface
*/
protected $urlBuilder;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Backend\App\ConfigInterface $backendConfig
* @param \Magento\AdminNotification\Model\InboxFactory $inboxFactory
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param InboxFactory $inboxFactory
* @param \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\Db $resourceCollection
* @param \Magento\Framework\HTTP\Adapter\curlFactory $curlFactory
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\Model\Context $context,
Expand All @@ -68,15 +82,19 @@ public function __construct(
\Magento\AdminNotification\Model\InboxFactory $inboxFactory,
\Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory,
\Magento\Framework\App\DeploymentConfig $deploymentConfig,
\Magento\Framework\App\ProductMetadataInterface $productMetadata,
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\Db $resourceCollection = null,
array $data = []
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
$this->_backendConfig = $backendConfig;
$this->_inboxFactory = $inboxFactory;
$this->curlFactory = $curlFactory;
$this->_backendConfig = $backendConfig;
$this->_inboxFactory = $inboxFactory;
$this->curlFactory = $curlFactory;
$this->_deploymentConfig = $deploymentConfig;
$this->productMetadata = $productMetadata;
$this->urlBuilder = $urlBuilder;
}

/**
Expand Down Expand Up @@ -191,7 +209,15 @@ public function setLastUpdate()
public function getFeedData()
{
$curl = $this->curlFactory->create();
$curl->setConfig(['timeout' => 2]);
$curl->setConfig(
[
'timeout' => 2,
'useragent' => $this->productMetadata->getName()
. '/' . $this->productMetadata->getVersion()
. ' (' . $this->productMetadata->getEdition() . ')',
'referer' => $this->urlBuilder->getUrl('*/*/*')
]
);
$curl->write(\Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
$data = $curl->read();
if ($data === false) {
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/AdminNotification/Model/Inbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ public function parse(array $data)
* @param string|string[] $description
* @param string $url
* @param bool $isInternal
* @throws \Magento\Framework\Model\Exception
* @throws \Magento\Framework\Exception\LocalizedException
* @return $this
*/
public function add($severity, $title, $description, $url = '', $isInternal = true)
{
if (!$this->getSeverities($severity)) {
throw new \Magento\Framework\Model\Exception(__('Wrong message type'));
throw new \Magento\Framework\Exception\LocalizedException(__('Wrong message type'));
}
if (is_array($description)) {
$description = '<ul><li>' . implode('</li><li>', $description) . '</li></ul>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public function __construct(\Magento\AdminNotification\Model\InboxFactory $notif
*
* @param int $notificationId
* @return void
* @throws \Magento\Framework\Model\Exception
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function markAsRead($notificationId)
{
$notification = $this->_notificationFactory->create();
$notification->load($notificationId);
if (!$notification->getId()) {
throw new \Magento\Framework\Model\Exception('Wrong notification ID specified.');
throw new \Magento\Framework\Exception\LocalizedException(__('Wrong notification ID specified.'));
}
$notification->setIsRead(1);
$notification->save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function _getConfigUrl()
) {
$output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', ['section' => 'web']);
} else {
/** @var $dataCollection \Magento\Core\Model\Resource\Config\Data\Collection */
/** @var $dataCollection \Magento\Config\Model\Resource\Config\Data\Collection */
$dataCollection = $this->_configValueFactory->create()->getCollection();
$dataCollection->addValueFilter(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER);

Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/AdminNotification/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/system_file.xsd">
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
<system>
<section id="system">
<group id="adminnotification" translate="label" type="text" sortOrder="250" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Notifications</label>
<field id="use_https" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Use HTTPS to Get Feed</label>
<source_model>Magento\Backend\Model\Config\Source\Yesno</source_model>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="frequency" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Update Frequency</label>
<source_model>Magento\AdminNotification\Model\Config\Source\Frequency</source_model>
</field>
<field id="last_update" translate="label" type="label" sortOrder="3" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Last Update</label>
<frontend_model>Magento\Backend\Block\System\Config\Form\Field\Notification</frontend_model>
<frontend_model>Magento\Config\Block\System\Config\Form\Field\Notification</frontend_model>
</field>
</group>
</section>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/AdminNotification/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<default>
<system>
<adminnotification>
<feed_url>notifications.magentocommerce.com/community/notifications.rss</feed_url>
<feed_url>notifications.magentocommerce.com/magento2/community/notifications.rss</feed_url>
<popup_url>widgets.magentocommerce.com/notificationPopup</popup_url>
<severity_icons_url>widgets.magentocommerce.com/%s/%s.gif</severity_icons_url>
<use_https>0</use_https>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Authorization/Model/Acl/AclRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getAllowedResourcesByUser($userType, $userId)
} catch (\Exception $e) {
$this->logger->critical($e);
throw new LocalizedException(
'Error happened while getting a list of allowed resources. Check exception log for details.'
__('Error happened while getting a list of allowed resources. Check exception log for details.')
);
}
return $allowedResources;
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Authorization/Model/Resource/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function _construct()
*
* @param \Magento\Authorization\Model\Rules $rule
* @return void
* @throws \Magento\Framework\Model\Exception
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function saveRel(\Magento\Authorization\Model\Rules $rule)
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public function saveRel(\Magento\Authorization\Model\Rules $rule)

$adapter->commit();
$this->_aclCache->clean();
} catch (\Magento\Framework\Model\Exception $e) {
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$adapter->rollBack();
throw $e;
} catch (\Exception $e) {
Expand Down
5 changes: 3 additions & 2 deletions app/code/Magento/Backend/App/Action/Plugin/Authentication.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
/**
*
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\App\Action\Plugin;

use Magento\Framework\Exception\AuthenticationException;

class Authentication
{
/**
Expand Down Expand Up @@ -167,7 +168,7 @@ protected function _performLogin(\Magento\Framework\App\RequestInterface $reques

try {
$this->_auth->login($username, $password);
} catch (\Magento\Backend\Model\Auth\Exception $e) {
} catch (AuthenticationException $e) {
if (!$request->getParam('messageSent')) {
$this->messageManager->addError($e->getMessage());
$request->setParam('messageSent', true);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/App/UserConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
namespace Magento\Backend\App;

use Magento\Backend\Model\Config\Factory;
use Magento\Config\Model\Config\Factory;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\Console\Response;
use Magento\Framework\AppInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Reset extends \Magento\Backend\Block\System\Config\Form\Field
class Reset extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Pasge robots default instructions
Expand All @@ -39,7 +39,7 @@ public function __construct(
protected function _construct()
{
parent::_construct();
$this->setTemplate('page/system/config/robots/reset.phtml');
$this->setTemplate('Magento_Config::page/system/config/robots/reset.phtml');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Dependence extends \Magento\Backend\Block\AbstractBlock
protected $_configOptions = [];

/**
* @var \Magento\Backend\Model\Config\Structure\Element\Dependency\FieldFactory
* @var \Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory
*/
protected $_fieldFactory;

Expand All @@ -52,13 +52,13 @@ class Dependence extends \Magento\Backend\Block\AbstractBlock
/**
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
* @param \Magento\Backend\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory
* @param \Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
\Magento\Backend\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory,
\Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory,
array $data = []
) {
$this->_jsonEncoder = $jsonEncoder;
Expand All @@ -84,13 +84,13 @@ public function addFieldMap($fieldId, $fieldName)
*
* @param string $fieldName
* @param string $fieldNameFrom
* @param \Magento\Backend\Model\Config\Structure\Element\Dependency\Field|string $refField
* @param \Magento\Config\Model\Config\Structure\Element\Dependency\Field|string $refField
* @return \Magento\Backend\Block\Widget\Form\Element\Dependence
*/
public function addFieldDependence($fieldName, $fieldNameFrom, $refField)
{
if (!is_object($refField)) {
/** @var $refField \Magento\Backend\Model\Config\Structure\Element\Dependency\Field */
/** @var $refField \Magento\Config\Model\Config\Structure\Element\Dependency\Field */
$refField = $this->_fieldFactory->create(
['fieldData' => ['value' => (string)$refField], 'fieldPrefix' => '']
);
Expand Down Expand Up @@ -139,7 +139,7 @@ protected function _getDependsJson()
$result = [];
foreach ($this->_depends as $to => $row) {
foreach ($row as $from => $field) {
/** @var $field \Magento\Backend\Model\Config\Structure\Element\Dependency\Field */
/** @var $field \Magento\Config\Model\Config\Structure\Element\Dependency\Field */
$result[$this->_fields[$to]][$this->_fields[$from]] = [
'values' => $field->getValues(),
'negative' => $field->isNegative(),
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/Backend/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,15 @@ public function getColumnSet()
/**
* Retrieve export block
*
* @throws \Magento\Framework\Model\Exception
* @throws \Magento\Framework\Exception\LocalizedException
* @return \Magento\Framework\View\Element\AbstractBlock|bool
*/
public function getExportBlock()
{
if (!$this->getChildBlock('grid.export')) {
throw new \Magento\Framework\Model\Exception('Export block for grid ' . $this->getNameInLayout() . ' is not defined');
throw new \Magento\Framework\Exception\LocalizedException(
__('Export block for grid %1 is not defined', $this->getNameInLayout())
);
}
return $this->getChildBlock('grid.export');
}
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/Backend/Block/Widget/Grid/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,17 @@ public function __construct(

/**
* @return void
* @throws \Magento\Framework\Model\Exception
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _construct()
{
parent::_construct();
if ($this->hasData('exportTypes')) {
foreach ($this->getData('exportTypes') as $type) {
if (!isset($type['urlPath']) || !isset($type['label'])) {
throw new \Magento\Framework\Model\Exception('Invalid export type supplied for grid export block');
throw new \Magento\Framework\Exception\LocalizedException(
__('Invalid export type supplied for grid export block')
);
}
$this->addExportType($type['urlPath'], $type['label']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getMassaction()
*
* @param string|\Magento\Framework\View\Element\AbstractBlock $block
* @return $this
* @throws \Magento\Framework\Model\Exception
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function setAdditionalActionBlock($block)
{
Expand All @@ -53,7 +53,7 @@ public function setAdditionalActionBlock($block)
} elseif (is_array($block)) {
$block = $this->_createFromConfig($block);
} elseif (!$block instanceof \Magento\Framework\View\Element\AbstractBlock) {
throw new \Magento\Framework\Model\Exception('Unknown block type');
throw new \Magento\Framework\Exception\LocalizedException(__('Unknown block type'));
}

$this->setChild('additional_action', $block);
Expand Down
Loading

0 comments on commit 8f68565

Please sign in to comment.