Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 47b9b97

Browse files
committed
temp fix for drupal + ssl
1 parent 1cd4a41 commit 47b9b97

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

src/ClientBuilder.php

+20
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,27 @@ public static function create($config = [])
6666
*/
6767
public function addConnection($alias, $uri, ConfigInterface $config = null)
6868
{
69+
//small hack for drupal
70+
if (substr($uri, 0, 7) === 'bolt://') {
71+
$parts = explode('bolt://', $uri );
72+
if (count($parts) === 2) {
73+
$splits = explode('@', $parts[1]);
74+
$split = $splits[count($splits)-1];
75+
if (substr($split, 0, 4) === 'ssl+') {
76+
$up = count($splits) > 1 ? $splits[0] : '';
77+
$ups = explode(':', $up);
78+
$u = $ups[0];
79+
$p = $ups[1];
80+
$uri = 'bolt://'.str_replace('ssl+', '', $split);
81+
$config = \GraphAware\Bolt\Configuration::newInstance()
82+
->withCredentials($u, $p)
83+
->withTLSMode(\GraphAware\Bolt\Configuration::TLSMODE_REQUIRED);
84+
}
85+
}
86+
}
87+
6988
$this->config['connections'][$alias]['uri'] = $uri;
89+
7090
if (null !== $config) {
7191
if ($this->config['connections'][$alias]['config'] = $config);
7292
}

tests/Issues/DrupalIssueTest.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace GraphAware\Neo4j\Client\Tests;
4+
5+
/**
6+
* Class DrupalIssueTest
7+
* @package GraphAware\Neo4j\Client\Tests
8+
*
9+
* @group drupal
10+
*/
11+
class DrupalIssueTest extends \PHPUnit_Framework_TestCase
12+
{
13+
public function testDrupalConversion()
14+
{
15+
$this->addConnection('default', 'bolt://neo4j:sfadfewfn;kewvljnfd@ssl+graphene.com', null);
16+
}
17+
18+
private function addConnection($alias, $uri, $config)
19+
{
20+
if (substr($uri, 0, 7) === 'bolt://') {
21+
$parts = explode('bolt://', $uri );
22+
if (count($parts) === 2) {
23+
$splits = explode('@', $parts[1]);
24+
$split = $splits[count($splits)-1];
25+
if (substr($split, 0, 4) === 'ssl+') {
26+
$up = count($splits) > 1 ? $splits[0] : '';
27+
$ups = explode(':', $up);
28+
$u = $ups[0];
29+
$p = $ups[1];
30+
$uri = 'bolt://'.str_replace('ssl+', '', $split);
31+
$config = \GraphAware\Bolt\Configuration::newInstance()
32+
->withCredentials($u, $p)
33+
->withTLSMode(\GraphAware\Bolt\Configuration::TLSMODE_REQUIRED);
34+
}
35+
}
36+
}
37+
38+
var_dump($uri);
39+
var_dump($config);
40+
}
41+
}

0 commit comments

Comments
 (0)