11
11
use React \Promise ;
12
12
use Clue \React \ViewVcApi \Io \Parser ;
13
13
use Clue \React \ViewVcApi \Io \Loader ;
14
+ use Rize \UriTemplate ;
14
15
15
16
class Client
16
17
{
17
18
private $ brower ;
19
+ private $ parser ;
20
+ private $ loader ;
21
+ private $ uri ;
18
22
19
- public function __construct (Browser $ browser , Parser $ parser = null , Loader $ loader = null )
23
+ public function __construct (Browser $ browser , Parser $ parser = null , Loader $ loader = null , UriTemplate $ uri = null )
20
24
{
21
25
if ($ parser === null ) {
22
26
$ parser = new Parser ();
23
27
}
24
28
if ($ loader === null ) {
25
29
$ loader = new Loader ();
26
30
}
31
+ if ($ uri === null ) {
32
+ $ uri = new UriTemplate ();
33
+ }
27
34
28
35
// TODO: do not follow redirects
29
36
// $browser = $this->browser->withOptions(array(
@@ -33,6 +40,7 @@ public function __construct(Browser $browser, Parser $parser = null, Loader $loa
33
40
$ this ->browser = $ browser ;
34
41
$ this ->parser = $ parser ;
35
42
$ this ->loader = $ loader ;
43
+ $ this ->uri = $ uri ;
36
44
}
37
45
38
46
public function fetchFile ($ path , $ revision = null )
@@ -47,7 +55,7 @@ public function fetchFile($path, $revision = null)
47
55
// TODO: reject all paths with trailing slashes
48
56
49
57
return $ this ->fetch (
50
- $ this ->browser -> resolve (
58
+ $ this ->uri -> expand (
51
59
'{+path}?view=co{&pathrev} ' ,
52
60
array (
53
61
'path ' => $ path ,
@@ -67,7 +75,7 @@ public function fetchDirectory($path, $revision = null, $showAttic = false)
67
75
// TODO: accessing files will redirect to file with relative location URL (not supported by clue/buzz-react)
68
76
69
77
return $ this ->fetchXml (
70
- $ this ->browser -> resolve (
78
+ $ this ->uri -> expand (
71
79
'{+path}{?pathrev,hideattic} ' ,
72
80
array (
73
81
'path ' => $ path ,
@@ -86,7 +94,7 @@ public function fetchDirectory($path, $revision = null, $showAttic = false)
86
94
public function fetchPatch ($ path , $ r1 , $ r2 )
87
95
{
88
96
return $ this ->fetch (
89
- $ this ->browser -> resolve (
97
+ $ this ->uri -> expand (
90
98
'{+path}?view=patch{&r1,r2} ' ,
91
99
array (
92
100
'path ' => $ path ,
@@ -102,7 +110,7 @@ public function fetchLog($path, $revision = null)
102
110
// TODO: invalid revision shows error page, but HTTP 200 OK
103
111
104
112
return $ this ->fetchXml (
105
- $ this ->browser -> resolve (
113
+ $ this ->uri -> expand (
106
114
'{+path}?view=log{&pathrev} ' ,
107
115
array (
108
116
'path ' => $ path ,
@@ -131,7 +139,7 @@ public function fetchAllPreviousRevisions($path)
131
139
private function fetchLogXml ($ path )
132
140
{
133
141
return $ this ->fetchXml (
134
- $ this ->browser -> resolve (
142
+ $ this ->uri -> expand (
135
143
'{+path}?view=log ' ,
136
144
array (
137
145
'path ' => $ path
0 commit comments