@@ -47,113 +47,113 @@ |
||
47 | 47 | * @package OCA\DAV\Connector\Sabre |
48 | 48 | */ |
49 | 49 | class FakeLockerPlugin extends ServerPlugin { |
50 | - /** @var \Sabre\DAV\Server */ |
|
51 | - private $server; |
|
50 | + /** @var \Sabre\DAV\Server */ |
|
51 | + private $server; |
|
52 | 52 | |
53 | - /** {@inheritDoc} */ |
|
54 | - public function initialize(\Sabre\DAV\Server $server) { |
|
55 | - $this->server = $server; |
|
56 | - $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); |
|
57 | - $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); |
|
58 | - $server->on('propFind', [$this, 'propFind']); |
|
59 | - $server->on('validateTokens', [$this, 'validateTokens']); |
|
60 | - } |
|
53 | + /** {@inheritDoc} */ |
|
54 | + public function initialize(\Sabre\DAV\Server $server) { |
|
55 | + $this->server = $server; |
|
56 | + $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); |
|
57 | + $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); |
|
58 | + $server->on('propFind', [$this, 'propFind']); |
|
59 | + $server->on('validateTokens', [$this, 'validateTokens']); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Indicate that we support LOCK and UNLOCK |
|
64 | - * |
|
65 | - * @param string $path |
|
66 | - * @return string[] |
|
67 | - */ |
|
68 | - public function getHTTPMethods($path) { |
|
69 | - return [ |
|
70 | - 'LOCK', |
|
71 | - 'UNLOCK', |
|
72 | - ]; |
|
73 | - } |
|
62 | + /** |
|
63 | + * Indicate that we support LOCK and UNLOCK |
|
64 | + * |
|
65 | + * @param string $path |
|
66 | + * @return string[] |
|
67 | + */ |
|
68 | + public function getHTTPMethods($path) { |
|
69 | + return [ |
|
70 | + 'LOCK', |
|
71 | + 'UNLOCK', |
|
72 | + ]; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Indicate that we support locking |
|
77 | - * |
|
78 | - * @return integer[] |
|
79 | - */ |
|
80 | - public function getFeatures() { |
|
81 | - return [2]; |
|
82 | - } |
|
75 | + /** |
|
76 | + * Indicate that we support locking |
|
77 | + * |
|
78 | + * @return integer[] |
|
79 | + */ |
|
80 | + public function getFeatures() { |
|
81 | + return [2]; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Return some dummy response for PROPFIND requests with regard to locking |
|
86 | - * |
|
87 | - * @param PropFind $propFind |
|
88 | - * @param INode $node |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - public function propFind(PropFind $propFind, INode $node) { |
|
92 | - $propFind->handle('{DAV:}supportedlock', function () { |
|
93 | - return new SupportedLock(); |
|
94 | - }); |
|
95 | - $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { |
|
96 | - return new LockDiscovery([]); |
|
97 | - }); |
|
98 | - } |
|
84 | + /** |
|
85 | + * Return some dummy response for PROPFIND requests with regard to locking |
|
86 | + * |
|
87 | + * @param PropFind $propFind |
|
88 | + * @param INode $node |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + public function propFind(PropFind $propFind, INode $node) { |
|
92 | + $propFind->handle('{DAV:}supportedlock', function () { |
|
93 | + return new SupportedLock(); |
|
94 | + }); |
|
95 | + $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { |
|
96 | + return new LockDiscovery([]); |
|
97 | + }); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * Mark a locking token always as valid |
|
102 | - * |
|
103 | - * @param RequestInterface $request |
|
104 | - * @param array $conditions |
|
105 | - */ |
|
106 | - public function validateTokens(RequestInterface $request, &$conditions) { |
|
107 | - foreach ($conditions as &$fileCondition) { |
|
108 | - if (isset($fileCondition['tokens'])) { |
|
109 | - foreach ($fileCondition['tokens'] as &$token) { |
|
110 | - if (isset($token['token'])) { |
|
111 | - if (substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
112 | - $token['validToken'] = true; |
|
113 | - } |
|
114 | - } |
|
115 | - } |
|
116 | - } |
|
117 | - } |
|
118 | - } |
|
100 | + /** |
|
101 | + * Mark a locking token always as valid |
|
102 | + * |
|
103 | + * @param RequestInterface $request |
|
104 | + * @param array $conditions |
|
105 | + */ |
|
106 | + public function validateTokens(RequestInterface $request, &$conditions) { |
|
107 | + foreach ($conditions as &$fileCondition) { |
|
108 | + if (isset($fileCondition['tokens'])) { |
|
109 | + foreach ($fileCondition['tokens'] as &$token) { |
|
110 | + if (isset($token['token'])) { |
|
111 | + if (substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
112 | + $token['validToken'] = true; |
|
113 | + } |
|
114 | + } |
|
115 | + } |
|
116 | + } |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Fakes a successful LOCK |
|
122 | - * |
|
123 | - * @param RequestInterface $request |
|
124 | - * @param ResponseInterface $response |
|
125 | - * @return bool |
|
126 | - */ |
|
127 | - public function fakeLockProvider(RequestInterface $request, |
|
128 | - ResponseInterface $response) { |
|
129 | - $lockInfo = new LockInfo(); |
|
130 | - $lockInfo->token = md5($request->getPath()); |
|
131 | - $lockInfo->uri = $request->getPath(); |
|
132 | - $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
133 | - $lockInfo->timeout = 1800; |
|
120 | + /** |
|
121 | + * Fakes a successful LOCK |
|
122 | + * |
|
123 | + * @param RequestInterface $request |
|
124 | + * @param ResponseInterface $response |
|
125 | + * @return bool |
|
126 | + */ |
|
127 | + public function fakeLockProvider(RequestInterface $request, |
|
128 | + ResponseInterface $response) { |
|
129 | + $lockInfo = new LockInfo(); |
|
130 | + $lockInfo->token = md5($request->getPath()); |
|
131 | + $lockInfo->uri = $request->getPath(); |
|
132 | + $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
133 | + $lockInfo->timeout = 1800; |
|
134 | 134 | |
135 | - $body = $this->server->xml->write('{DAV:}prop', [ |
|
136 | - '{DAV:}lockdiscovery' => |
|
137 | - new LockDiscovery([$lockInfo]) |
|
138 | - ]); |
|
135 | + $body = $this->server->xml->write('{DAV:}prop', [ |
|
136 | + '{DAV:}lockdiscovery' => |
|
137 | + new LockDiscovery([$lockInfo]) |
|
138 | + ]); |
|
139 | 139 | |
140 | - $response->setStatus(200); |
|
141 | - $response->setBody($body); |
|
140 | + $response->setStatus(200); |
|
141 | + $response->setBody($body); |
|
142 | 142 | |
143 | - return false; |
|
144 | - } |
|
143 | + return false; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * Fakes a successful LOCK |
|
148 | - * |
|
149 | - * @param RequestInterface $request |
|
150 | - * @param ResponseInterface $response |
|
151 | - * @return bool |
|
152 | - */ |
|
153 | - public function fakeUnlockProvider(RequestInterface $request, |
|
154 | - ResponseInterface $response) { |
|
155 | - $response->setStatus(204); |
|
156 | - $response->setHeader('Content-Length', '0'); |
|
157 | - return false; |
|
158 | - } |
|
146 | + /** |
|
147 | + * Fakes a successful LOCK |
|
148 | + * |
|
149 | + * @param RequestInterface $request |
|
150 | + * @param ResponseInterface $response |
|
151 | + * @return bool |
|
152 | + */ |
|
153 | + public function fakeUnlockProvider(RequestInterface $request, |
|
154 | + ResponseInterface $response) { |
|
155 | + $response->setStatus(204); |
|
156 | + $response->setHeader('Content-Length', '0'); |
|
157 | + return false; |
|
158 | + } |
|
159 | 159 | } |
@@ -89,10 +89,10 @@ |
||
89 | 89 | * @return void |
90 | 90 | */ |
91 | 91 | public function propFind(PropFind $propFind, INode $node) { |
92 | - $propFind->handle('{DAV:}supportedlock', function () { |
|
92 | + $propFind->handle('{DAV:}supportedlock', function() { |
|
93 | 93 | return new SupportedLock(); |
94 | 94 | }); |
95 | - $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { |
|
95 | + $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { |
|
96 | 96 | return new LockDiscovery([]); |
97 | 97 | }); |
98 | 98 | } |