Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ZookeeperStore.php

function ZookeeperStore::createConnection

1 call to ZookeeperStore::createConnection()
StoreFactory::createStore in vendor/symfony/lock/Store/StoreFactory.php

File

vendor/symfony/lock/Store/ZookeeperStore.php, line 35

Class

ZookeeperStore
ZookeeperStore is a PersistingStoreInterface implementation using Zookeeper as store engine.

Namespace

Symfony\Component\Lock\Store

Code

public static function createConnection(string $dsn) : \Zookeeper {
    if (!str_starts_with($dsn, 'zookeeper:')) {
        throw new InvalidArgumentException('Unsupported DSN for Zookeeper.');
    }
    if (false === ($params = parse_url($dsn))) {
        throw new InvalidArgumentException('Invalid Zookeeper DSN.');
    }
    $host = $params['host'] ?? '';
    $hosts = explode(',', $host);
    foreach ($hosts as $index => $host) {
        if (isset($params['port'])) {
            $hosts[$index] = $host . ':' . $params['port'];
        }
    }
    return new \Zookeeper(implode(',', $hosts));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal