Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Factory.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 use PhpAmqpLib\Connection\AbstractConnection;
12 use PhpAmqpLib\Connection\AMQPSSLConnection;
13 use PhpAmqpLib\Connection\AMQPStreamConnection;
14 
18 class Factory
19 {
26  public function create(FactoryOptions $options): AbstractConnection
27  {
28  $connectionType = $options->isSslEnabled() ? AMQPSSLConnection::class : AMQPStreamConnection::class;
29  $parameters = [
30  'host' => $options->getHost(),
31  'port' => $options->getPort(),
32  'user' => $options->getUsername(),
33  'password' => $options->getPassword(),
34  'vhost' => $options->getVirtualHost() !== null ? $options->getVirtualHost() : '/',
35  ];
36 
37  if ($options->isSslEnabled()) {
38  $parameters['ssl_options'] = $options->getSslOptions() !== null
39  ? $options->getSslOptions()
40  : ['verify_peer' => true];
41  }
42 
43  return ObjectManager::getInstance()->create($connectionType, $parameters);
44  }
45 }
create(FactoryOptions $options)
Definition: Factory.php:26