22
22
use Laudis \Neo4j \Contracts \SessionInterface ;
23
23
use Laudis \Neo4j \Contracts \TransactionInterface ;
24
24
use Laudis \Neo4j \Contracts \UnmanagedTransactionInterface ;
25
+ use Laudis \Neo4j \Databags \Bookmark ;
26
+ use Laudis \Neo4j \Databags \BookmarkHolder ;
25
27
use Laudis \Neo4j \Databags \SessionConfiguration ;
26
28
use Laudis \Neo4j \Databags \Statement ;
27
29
use Laudis \Neo4j \Databags \TransactionConfiguration ;
@@ -58,6 +60,7 @@ final class Session implements SessionInterface
58
60
private UriInterface $ uri ;
59
61
/** @psalm-readonly */
60
62
private AuthenticateInterface $ auth ;
63
+ private BookmarkHolder $ bookmarkHolder ;
61
64
62
65
/**
63
66
* @param FormatterInterface<ResultFormat> $formatter
@@ -77,6 +80,7 @@ public function __construct(
77
80
$ this ->formatter = $ formatter ;
78
81
$ this ->uri = $ uri ;
79
82
$ this ->auth = $ auth ;
83
+ $ this ->bookmarkHolder = new BookmarkHolder (Bookmark::from ($ config ->getBookmarks ()));
80
84
}
81
85
82
86
public function runStatements (iterable $ statements , ?TransactionConfiguration $ config = null ): CypherList
@@ -150,7 +154,7 @@ private function beginInstantTransaction(
150
154
): TransactionInterface {
151
155
$ connection = $ this ->acquireConnection ($ tsxConfig , $ config );
152
156
153
- return new BoltUnmanagedTransaction ($ this ->config ->getDatabase (), $ this ->formatter , $ connection , $ this ->config , $ tsxConfig );
157
+ return new BoltUnmanagedTransaction ($ this ->config ->getDatabase (), $ this ->formatter , $ connection , $ this ->config , $ tsxConfig, $ this -> bookmarkHolder );
154
158
}
155
159
156
160
/**
@@ -184,11 +188,16 @@ private function startTransaction(TransactionConfiguration $config, SessionConfi
184
188
throw Neo4jException::fromMessageException ($ e );
185
189
}
186
190
187
- return new BoltUnmanagedTransaction ($ this ->config ->getDatabase (), $ this ->formatter , $ connection , $ this ->config , $ config );
191
+ return new BoltUnmanagedTransaction ($ this ->config ->getDatabase (), $ this ->formatter , $ connection , $ this ->config , $ config, $ this -> bookmarkHolder );
188
192
}
189
193
190
194
private function mergeTsxConfig (?TransactionConfiguration $ config ): TransactionConfiguration
191
195
{
192
196
return TransactionConfiguration::default ()->merge ($ config );
193
197
}
198
+
199
+ public function getLastBookmark (): Bookmark
200
+ {
201
+ return $ this ->bookmarkHolder ->getBookmark ();
202
+ }
194
203
}
0 commit comments