Skip to content

Commit

Permalink
🔀 merge upstream/2.3-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad HAJ SALEM committed Mar 13, 2018
2 parents 73482be + 33b92f6 commit 50c16e0
Show file tree
Hide file tree
Showing 1,437 changed files with 51,872 additions and 3,206 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ addons:
firefox: "46.0"
hosts:
- magento2.travis
services:
- rabbitmq
language: php
php:
- 7.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=develop)](https://travis-ci.org/magento/magento2)
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=2.3-develop)](https://travis-ci.org/magento/magento2)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.png)](https://crowdin.com/project/magento-2)
<h2>Welcome</h2>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/AdminNotification/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/schema.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="adminnotification_inbox" resource="default" engine="innodb" comment="Adminnotification Inbox">
<column xsi:type="int" name="notification_id" padding="10" unsigned="true" nullable="false" identity="true"
comment="Notification id"/>
Expand Down
16 changes: 16 additions & 0 deletions app/code/Magento/Amqp/Model/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Amqp\Model;

/**
* {@inheritdoc}
*
* @deprecated 100.2.0
*/
class Config extends \Magento\Framework\Amqp\Config
{

}
68 changes: 68 additions & 0 deletions app/code/Magento/Amqp/Model/Exchange.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Amqp\Model;

use Magento\Framework\MessageQueue\ConfigInterface as QueueConfig;
use Magento\Framework\Communication\ConfigInterface as CommunicationConfigInterface;
use Magento\Framework\MessageQueue\Publisher\ConfigInterface as PublisherConfig;
use Magento\Framework\MessageQueue\Rpc\ResponseQueueNameBuilder;

/**
* {@inheritdoc}
*
* @deprecated 100.2.0
*/
class Exchange extends \Magento\Framework\Amqp\Exchange
{
/**
* Initialize dependencies.
*
* @param Config $amqpConfig
* @param QueueConfig $queueConfig
* @param CommunicationConfigInterface $communicationConfig
* @param int $rpcConnectionTimeout
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
Config $amqpConfig,
QueueConfig $queueConfig,
CommunicationConfigInterface $communicationConfig,
$rpcConnectionTimeout = self::RPC_CONNECTION_TIMEOUT
) {
parent::__construct(
$amqpConfig,
$this->getPublisherConfig(),
$this->getResponseQueueNameBuilder(),
$communicationConfig,
$rpcConnectionTimeout
);
}

/**
* Get publisher config.
*
* @return PublisherConfig
*
* @deprecated 100.2.0
*/
private function getPublisherConfig()
{
return \Magento\Framework\App\ObjectManager::getInstance()->get(PublisherConfig::class);
}

/**
* Get response queue name builder.
*
* @return ResponseQueueNameBuilder
*
* @deprecated 100.2.0
*/
private function getResponseQueueNameBuilder()
{
return \Magento\Framework\App\ObjectManager::getInstance()->get(ResponseQueueNameBuilder::class);
}
}
16 changes: 16 additions & 0 deletions app/code/Magento/Amqp/Model/Queue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Amqp\Model;

/**
* {@inheritdoc}
*
* @deprecated 100.2.0
*/
class Queue extends \Magento\Framework\Amqp\Queue
{

}
67 changes: 67 additions & 0 deletions app/code/Magento/Amqp/Model/Topology.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Amqp\Model;

use Magento\Framework\Amqp\Topology\ExchangeInstaller;
use Magento\Framework\Amqp\Topology\QueueInstaller;
use Magento\Framework\MessageQueue\ConfigInterface as QueueConfig;
use Magento\Framework\Communication\ConfigInterface as CommunicationConfig;
use Magento\Framework\MessageQueue\Topology\ConfigInterface as TopologyConfig;
use Magento\Framework\Amqp\ConfigPool;
use Magento\Framework\Amqp\ConnectionTypeResolver;
use Magento\Framework\Amqp\TopologyInstaller;

/**
* Class Topology creates topology for Amqp messaging
*
* @deprecated 100.2.0
*/
class Topology extends TopologyInstaller
{
/**
* Type of exchange
*
* @deprecated
*/
const TOPIC_EXCHANGE = 'topic';

/**
* Amqp connection
*/
const AMQP_CONNECTION = 'amqp';

/**
* Durability for exchange and queue
*
* @deprecated
*/
const IS_DURABLE = true;

/**
* Initialize dependencies
*
* @param Config $amqpConfig
* @param QueueConfig $queueConfig
* @param CommunicationConfig $communicationConfig
* @param \Psr\Log\LoggerInterface $logger
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
Config $amqpConfig,
QueueConfig $queueConfig,
CommunicationConfig $communicationConfig,
\Psr\Log\LoggerInterface $logger
) {
parent::__construct(
\Magento\Framework\App\ObjectManager::getInstance()->get(TopologyConfig::class),
\Magento\Framework\App\ObjectManager::getInstance()->get(ExchangeInstaller::class),
\Magento\Framework\App\ObjectManager::getInstance()->get(ConfigPool::class),
\Magento\Framework\App\ObjectManager::getInstance()->get(QueueInstaller::class),
\Magento\Framework\App\ObjectManager::getInstance()->get(ConnectionTypeResolver::class),
$logger
);
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/Amqp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Amqp

**Amqp** provides functionality to publish/consume messages with Amqp.
188 changes: 188 additions & 0 deletions app/code/Magento/Amqp/Setup/ConfigOptionsList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Amqp\Setup;

use Magento\Framework\Config\Data\ConfigData;
use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\Setup\ConfigOptionsListInterface;
use Magento\Framework\Setup\Option\TextConfigOption;
use Magento\Framework\App\DeploymentConfig;

/**
* Deployment configuration options needed for Setup application
*/
class ConfigOptionsList implements ConfigOptionsListInterface
{
/**
* Input key for the options
*/
const INPUT_KEY_QUEUE_AMQP_HOST = 'amqp-host';
const INPUT_KEY_QUEUE_AMQP_PORT = 'amqp-port';
const INPUT_KEY_QUEUE_AMQP_USER = 'amqp-user';
const INPUT_KEY_QUEUE_AMQP_PASSWORD = 'amqp-password';
const INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST = 'amqp-virtualhost';
const INPUT_KEY_QUEUE_AMQP_SSL = 'amqp-ssl';

/**
* Path to the values in the deployment config
*/
const CONFIG_PATH_QUEUE_AMQP_HOST = 'queue/amqp/host';
const CONFIG_PATH_QUEUE_AMQP_PORT = 'queue/amqp/port';
const CONFIG_PATH_QUEUE_AMQP_USER = 'queue/amqp/user';
const CONFIG_PATH_QUEUE_AMQP_PASSWORD = 'queue/amqp/password';
const CONFIG_PATH_QUEUE_AMQP_VIRTUAL_HOST = 'queue/amqp/virtualhost';
const CONFIG_PATH_QUEUE_AMQP_SSL = 'queue/amqp/ssl';

/**
* Default values
*/
const DEFAULT_AMQP_HOST = '';
const DEFAULT_AMQP_PORT = '5672';
const DEFAULT_AMQP_USER = '';
const DEFAULT_AMQP_PASSWORD = '';
const DEFAULT_AMQP_VIRTUAL_HOST = '/';
const DEFAULT_AMQP_SSL = '';

/**
* @var ConnectionValidator
*/
private $connectionValidator;

/**
* Constructor
*
* @param ConnectionValidator $connectionValidator
*/
public function __construct(ConnectionValidator $connectionValidator)
{
$this->connectionValidator = $connectionValidator;
}

/**
* {@inheritdoc}
*/
public function getOptions()
{
return [
new TextConfigOption(
self::INPUT_KEY_QUEUE_AMQP_HOST,
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_QUEUE_AMQP_HOST,
'Amqp server host',
self::DEFAULT_AMQP_HOST
),
new TextConfigOption(
self::INPUT_KEY_QUEUE_AMQP_PORT,
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_QUEUE_AMQP_PORT,
'Amqp server port',
self::DEFAULT_AMQP_PORT
),
new TextConfigOption(
self::INPUT_KEY_QUEUE_AMQP_USER,
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_QUEUE_AMQP_USER,
'Amqp server username',
self::DEFAULT_AMQP_USER
),
new TextConfigOption(
self::INPUT_KEY_QUEUE_AMQP_PASSWORD,
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_QUEUE_AMQP_PASSWORD,
'Amqp server password',
self::DEFAULT_AMQP_PASSWORD
),
new TextConfigOption(
self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST,
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_QUEUE_AMQP_VIRTUAL_HOST,
'Amqp virtualhost',
self::DEFAULT_AMQP_VIRTUAL_HOST
),
new TextConfigOption(
self::INPUT_KEY_QUEUE_AMQP_SSL,
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_QUEUE_AMQP_SSL,
'Amqp SSL',
self::DEFAULT_AMQP_SSL
),
];
}

/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function createConfig(array $data, DeploymentConfig $deploymentConfig)
{
$configData = new ConfigData(ConfigFilePool::APP_ENV);

if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_HOST)) {
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_HOST, $data[self::INPUT_KEY_QUEUE_AMQP_HOST]);
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_PORT)) {
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_PORT, $data[self::INPUT_KEY_QUEUE_AMQP_PORT]);
}
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_USER)) {
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_USER, $data[self::INPUT_KEY_QUEUE_AMQP_USER]);
}
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_PASSWORD)) {
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_PASSWORD, $data[self::INPUT_KEY_QUEUE_AMQP_PASSWORD]);
}
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST)) {
$configData->set(
self::CONFIG_PATH_QUEUE_AMQP_VIRTUAL_HOST,
$data[self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST]
);
}
if (!$this->isDataEmpty($data, self::INPUT_KEY_QUEUE_AMQP_SSL)) {
$configData->set(self::CONFIG_PATH_QUEUE_AMQP_SSL, $data[self::INPUT_KEY_QUEUE_AMQP_SSL]);
}
}

return [$configData];
}

/**
* {@inheritdoc}
*/
public function validate(array $options, DeploymentConfig $deploymentConfig)
{
$errors = [];

if (isset($options[self::INPUT_KEY_QUEUE_AMQP_HOST])
&& $options[self::INPUT_KEY_QUEUE_AMQP_HOST] !== '') {
$result = $this->connectionValidator->isConnectionValid(
$options[self::INPUT_KEY_QUEUE_AMQP_HOST],
$options[self::INPUT_KEY_QUEUE_AMQP_PORT],
$options[self::INPUT_KEY_QUEUE_AMQP_USER],
$options[self::INPUT_KEY_QUEUE_AMQP_PASSWORD],
$options[self::INPUT_KEY_QUEUE_AMQP_VIRTUAL_HOST]
);

if (!$result) {
$errors[] = "Could not connect to the Amqp Server.";
}
}

return $errors;
}

/**
* Check if data ($data) with key ($key) is empty
*
* @param array $data
* @param string $key
* @return bool
*/
private function isDataEmpty(array $data, $key)
{
if (isset($data[$key]) && $data[$key] !== '') {
return false;
}

return true;
}
}
Loading

0 comments on commit 50c16e0

Please sign in to comment.