Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
orocrmdeployer committed Sep 14, 2018
2 parents bae1aa3 + d3ccdec commit f5c7ce5
Show file tree
Hide file tree
Showing 19 changed files with 642 additions and 218 deletions.
3 changes: 2 additions & 1 deletion src/Oro/Bundle/ApiBundle/Provider/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Oro\Bundle\ApiBundle\Config\Config;
use Oro\Bundle\ApiBundle\Config\ConfigExtraInterface;
use Oro\Bundle\ApiBundle\Exception\RuntimeException;
use Oro\Bundle\ApiBundle\Processor\Config\ConfigContext;
use Oro\Bundle\ApiBundle\Request\RequestType;
use Oro\Component\ChainProcessor\ActionProcessorInterface;
Expand Down Expand Up @@ -56,7 +57,7 @@ public function getConfig(
}

if (isset($this->processing[$cacheKey])) {
throw new \LogicException(sprintf(
throw new RuntimeException(sprintf(
'Cannot build the configuration of "%s" because this causes the circular dependency.',
$className
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function testShouldBePossibleToClearInternalCache()

// @codingStandardsIgnoreStart
/**
* @expectedException \LogicException
* @expectedException \Oro\Bundle\ApiBundle\Exception\RuntimeException
* @expectedExceptionMessage Cannot build the configuration of "Test\Class" because this causes the circular dependency.
*/
// @codingStandardsIgnoreEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
{% macro renderFieldName(objectClass, fieldKey, fieldValue) %}
{% set fieldLabel = oro_field_config_value(objectClass, fieldKey, 'label')|default(fieldKey) %}
{% if fieldValue.translationDomain is defined %}
{% set fieldLabel = fieldKey|trans({}, fieldValue.translationDomain) %}
{% set fieldLabel = fieldLabel|trans({}, fieldValue.translationDomain) %}
{% else %}
{% set fieldLabel = fieldKey|trans %}
{% set fieldLabel = fieldLabel|trans %}
{% endif %}
{{- fieldLabel -}}:
{% endmacro %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@ticket-BAP-17600
@fixture-OroUserBundle:user.yml
Feature: DataAudit labels are translated
In order to get information about changed entity fields
As a Admin user
I need to be able to see entity labels translated in data audit grid

Scenario:
Given I login as administrator
And I go to System/User Management/Users
And I click "Edit" on row "Charlie" in grid
And I fill form with:
| Username | charlie-up |
| First Name | FNUP |
| Last Name | LNUP |
| Primary Email | email-up@test.com |
And save and close form
When I go to System/ Data Audit
Then I should see "Username:" in grid
And I should see "First Name:" in grid
And I should see "Last Name:" in grid
And I should see "Primary Email:" in grid
23 changes: 0 additions & 23 deletions src/Oro/Bundle/SyncBundle/Client/Factory/GosClientFactory.php

This file was deleted.

This file was deleted.

98 changes: 98 additions & 0 deletions src/Oro/Bundle/SyncBundle/Client/Wamp/Factory/ClientAttributes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

namespace Oro\Bundle\SyncBundle\Client\Wamp\Factory;

/**
* This class represents connection attributes which will be used to create an instance of WampClient.
*/
class ClientAttributes
{
/** @var string */
private $host;

/** @var int */
private $port;

/** @var string */
private $path;

/**
* Any registered socket transport returned by http://php.net/manual/en/function.stream-get-transports.php
*
* @var string
*/
private $transport;

/**
* Will be passed to a context create function http://php.net/manual/en/function.stream-context-create.php
*
* @var array
*/
private $contextOptions;

/**
* @param string $host
* @param int $port
* @param string $path
* @param string $transport
* @param array $contextOptions
*/
public function __construct(
string $host,
int $port,
string $path,
string $transport,
array $contextOptions
) {
if ($host === '*') {
$host = '127.0.0.1';
}

$this->host = $host;
$this->port = $port;
$this->path = $path;
$this->transport = $transport;
$this->contextOptions = $contextOptions;
}

/**
* @return string
*/
public function getHost(): string
{
return $this->host;
}

/**
* @return int
*/
public function getPort(): int
{
return $this->port;
}

/**
* @return string
*/
public function getPath(): string
{
return $this->path;
}

/**
* @return string
*/
public function getTransport(): string
{
return $this->transport;
}


/**
* @return array
*/
public function getContextOptions(): array
{
return $this->contextOptions;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Oro\Bundle\SyncBundle\Client\Wamp\Factory;

use Oro\Bundle\SyncBundle\Client\Wamp\WampClient;

/**
* Creates websocket server client.
*/
class WampClientFactory implements WampClientFactoryInterface
{
/**
* {@inheritdoc}
*/
public function createClient(ClientAttributes $clientAttributes): WampClient
{
$options = $clientAttributes->getContextOptions();

return new WampClient(
$clientAttributes->getHost(),
$clientAttributes->getPort(),
$clientAttributes->getTransport(),
$options ? ['ssl' => $options] : [],
// We don't have to check origin when connecting from backend.
'127.0.0.1'
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Oro\Bundle\SyncBundle\Client\Wamp\Factory;

use Oro\Bundle\SyncBundle\Client\Wamp\WampClient;

/**
* Interface for websocket server client factories.
*/
interface WampClientFactoryInterface
{
/**
* @param ClientAttributes $clientAttributes
*
* @return WampClient
*/
public function createClient(ClientAttributes $clientAttributes): WampClient;
}
111 changes: 111 additions & 0 deletions src/Oro/Bundle/SyncBundle/Client/Wamp/WampClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace Oro\Bundle\SyncBundle\Client\Wamp;

use Gos\Component\WebSocketClient\Exception\BadResponseException;
use Gos\Component\WebSocketClient\Wamp\Client as GosClient;
use Gos\Component\WebSocketClient\Wamp\Protocol;

/**
* Overrides GosClient to add the ability to set socket transport and context options.
*/
class WampClient extends GosClient
{
/**
* Will be passed to a context create function http://php.net/manual/en/function.stream-context-create.php
*
* @var array
*/
private $contextOptions;

/**
* @param string $host
* @param int $port
* @param string $transport
* @param array $contextOptions
* @param string|null $origin
*/
public function __construct(
string $host,
int $port,
string $transport,
array $contextOptions = [],
?string $origin = null
) {
$secured = $this->isSecured($transport);

parent::__construct($host, $port, $secured, $origin);

$this->contextOptions = $contextOptions;
$this->endpoint = "{$transport}://{$host}:{$port}";
}

/**
* Overrides parent method to add ability to set socket context.
*
* {@inheritdoc}
*/
public function connect($target = '/')
{
$this->target = '/' . ltrim($target, '/');

if ($this->connected) {
return $this->sessionId;
}

$this->socket = $this->openSocket();

$response = $this->upgradeProtocol($this->target);

$this->verifyResponse($response);

$payload = json_decode($this->read());

if ((int)$payload[0] !== Protocol::MSG_WELCOME) {
throw new BadResponseException('WAMP Server did not send welcome message.');
}

$this->sessionId = $payload[1];

$this->connected = true;

return $this->sessionId;
}

/**
* @param string $transport
*
* @return bool
*
* @extensionPoint to change the logic of websocket protocol detection.
*/
protected function isSecured(string $transport): bool
{
return $transport === 'ssl' || stripos($transport, 'tls') === 0;
}

/**
* @return resource
*
* @throws BadResponseException
*
* @extensionPoint to change the logic of socket creation.
*/
protected function openSocket()
{
$socket = @stream_socket_client(
$this->endpoint,
$errno,
$errstr,
1,
STREAM_CLIENT_CONNECT,
stream_context_create($this->contextOptions)
);

if (!$socket) {
throw new BadResponseException('Could not open socket. Reason: ' . $errstr);
}

return $socket;
}
}
Loading

0 comments on commit f5c7ce5

Please sign in to comment.