[Messenger] Adding exception to amqp transport in case amqp ext is not installed

This commit is contained in:
Christopher Hertel 2019-11-24 19:49:09 +01:00 committed by Fabien Potencier
parent e50d80870e
commit f15e0e6a43
2 changed files with 8 additions and 0 deletions

View File

@ -28,6 +28,9 @@ class AmqpTransportFactoryTest extends TestCase
$this->assertFalse($factory->supports('invalid-dsn', []));
}
/**
* @requires extension amqp
*/
public function testItCreatesTheTransport()
{
$factory = new AmqpTransportFactory();

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Messenger\Transport\AmqpExt;
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
use Symfony\Component\Messenger\Exception\LogicException;
/**
* An AMQP connection.
@ -60,6 +61,10 @@ class Connection
public function __construct(array $connectionOptions, array $exchangeOptions, array $queuesOptions, AmqpFactory $amqpFactory = null)
{
if (!\extension_loaded('amqp')) {
throw new LogicException(sprintf('You cannot use the "%s" as the "amqp" extension is not installed.', __CLASS__));
}
$this->connectionOptions = array_replace_recursive([
'delay' => [
'exchange_name' => 'delays',