File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Pdsinterop \PhpSolid \Routes ;
3+
4+ use Pdsinterop \PhpSolid \StorageServer ;
5+
6+ class SolidStorageProvider {
7+ public static function respondToStorageNew () {
8+ try {
9+ $ webId = StorageServer::getWebId ($ rawRequest );
10+
11+ if (!isset ($ webId )) {
12+ $ response = $ resourceServer ->getResponse ()
13+ ->withStatus (409 , "Invalid token " );
14+ StorageServer::respond ($ response );
15+ exit ();
16+ }
17+ } catch (\Throwable $ e ) {
18+ $ webId = $ _POST ['webId ' ];
19+ // FIXME: Check against a trusted remote party;
20+ }
21+
22+ if (!isset ($ webId )) {
23+ header ("HTTP/1.1 400 Bad Request " );
24+ exit ();
25+ }
26+
27+ $ createdStorage = StorageServer::createStorage ($ webId );
28+ if (!$ createdStorage ) {
29+ error_log ("Failed to create storage " );
30+ header ("HTTP/1.1 400 Bad Request " );
31+ exit ();
32+ }
33+
34+ //Mailer::sendStorageCreated($createdStoage);
35+
36+ $ responseData = array (
37+ "storageId " => $ createdStorage ['storageId ' ]
38+ );
39+ header ("HTTP/1.1 201 Created " );
40+ header ("Content-type: application/json " );
41+ echo json_encode ($ responseData , JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR );
42+ }
43+ }
44+
You can’t perform that action at this time.
0 commit comments