bug #26947 [Messenger] Support nested configuration on adapters (sroze)
This PR was merged into the 4.1-dev branch.
Discussion
----------
[Messenger] Support nested configuration on adapters
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #26936
| License | MIT
| Doc PR | ø
The configuration of options did not support "in-depth" configuration. This adds it.
Commits
-------
177cea0ee1
Support nested configuration on adapters
This commit is contained in:
commit
507989db87
@ -1030,9 +1030,8 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('dsn')->end()
|
||||
->arrayNode('options')
|
||||
->normalizeKeys(false)
|
||||
->useAttributeAsKey('name')
|
||||
->defaultValue(array())
|
||||
->prototype('variable')
|
||||
->defaultValue(array())
|
||||
->prototype('variable')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -371,17 +371,12 @@
|
||||
|
||||
<xsd:complexType name="messenger_adapter">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="option" type="messenger_adapter_option" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="options" type="metadata" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="dsn" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="messenger_adapter_option">
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="value" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="messenger_middleware">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="validation" type="messenger_validation" minOccurs="0" maxOccurs="1" />
|
||||
|
@ -6,7 +6,7 @@ $container->loadFromExtension('framework', array(
|
||||
'default' => 'amqp://localhost/%2f/messages',
|
||||
'customised' => array(
|
||||
'dsn' => 'amqp://localhost/%2f/messages?exchange_name=exchange_name',
|
||||
'options' => array('queue_name' => 'Queue'),
|
||||
'options' => array('queue' => array('name' => 'Queue')),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -9,7 +9,11 @@
|
||||
<framework:messenger>
|
||||
<framework:adapter name="default" dsn="amqp://localhost/%2f/messages" />
|
||||
<framework:adapter name="customised" dsn="amqp://localhost/%2f/messages?exchange_name=exchange_name">
|
||||
<framework:option name="queue_name" value="Queue" />
|
||||
<framework:options>
|
||||
<framework:queue>
|
||||
<framework:name>Queue</framework:name>
|
||||
</framework:queue>
|
||||
</framework:options>
|
||||
</framework:adapter>
|
||||
</framework:messenger>
|
||||
</framework:config>
|
||||
|
@ -5,4 +5,5 @@ framework:
|
||||
customised:
|
||||
dsn: 'amqp://localhost/%2f/messages?exchange_name=exchange_name'
|
||||
options:
|
||||
queue_name: Queue
|
||||
queue:
|
||||
name: Queue
|
||||
|
@ -557,7 +557,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertEquals(array(new Reference('messenger.adapter_factory'), 'createSender'), $senderFactory);
|
||||
$this->assertCount(2, $senderArguments);
|
||||
$this->assertSame('amqp://localhost/%2f/messages?exchange_name=exchange_name', $senderArguments[0]);
|
||||
$this->assertSame(array('queue_name' => 'Queue'), $senderArguments[1]);
|
||||
$this->assertSame(array('queue' => array('name' => 'Queue')), $senderArguments[1]);
|
||||
|
||||
$this->assertTrue($container->hasDefinition('messenger.receiver.customised'));
|
||||
$receiverFactory = $container->getDefinition('messenger.receiver.customised')->getFactory();
|
||||
@ -566,7 +566,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$this->assertEquals(array(new Reference('messenger.adapter_factory'), 'createReceiver'), $receiverFactory);
|
||||
$this->assertCount(2, $receiverArguments);
|
||||
$this->assertSame('amqp://localhost/%2f/messages?exchange_name=exchange_name', $receiverArguments[0]);
|
||||
$this->assertSame(array('queue_name' => 'Queue'), $receiverArguments[1]);
|
||||
$this->assertSame(array('queue' => array('name' => 'Queue')), $receiverArguments[1]);
|
||||
}
|
||||
|
||||
public function testTranslator()
|
||||
|
Reference in New Issue
Block a user