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+
3+ namespace App \Http \Controllers \Backend ;
4+
5+ use App \Http \Controllers \Controller ;
6+ use App \Wiki ;
7+ use Illuminate \Http \Request ;
8+
9+ class WikiReadOnlyController extends Controller {
10+
11+ public function getWikiVersionForDomain (Request $ request ) {
12+
13+ $ domain = $ request ->query ('domain ' );
14+ $ wiki = Wiki::where ('domain ' , $ domain )->first ();
15+
16+ if (!$ wiki ) {
17+ return response ()->json ([
18+ 'error ' => 'Wiki not found for domain: ' . $ domain
19+ ], 404 );
20+ }
21+
22+ $ wiki ->setSetting ('wgReadOnly ' , 'This wiki is currently read-only. ' );
23+ return response ()->json ([
24+ 'success ' => true ,
25+ 'domain ' => $ domain ,
26+ 'message ' => 'Wiki set to read-only successfully. ' ,
27+ ]);
28+ }
29+
30+ }
Original file line number Diff line number Diff line change @@ -159,4 +159,11 @@ public function getDomainDecodedAttribute(): string {
159159 public function wikiLatestProfile () {
160160 return $ this ->hasOne (WikiProfile::class)->latestOfMany ();
161161 }
162+
163+ public function setSetting (string $ name , string $ value ): void {
164+ $ this ->settings ()->updateOrCreate (
165+ ['name ' => $ name ],
166+ ['value ' => $ value ]
167+ );
168+ }
162169}
Original file line number Diff line number Diff line change 1010// GET
1111$ router ->get ('healthz ' , fn () => "It's Alive " );
1212$ router ->get ('getWikiHostsForDomain ' , ['uses ' => 'MediaWikiHostsController@getWikiHostsForDomain ' ]);
13+ $ router ->post ('setWikiReadonly ' , ['uses ' => 'WikiReadOnlyController@setWikiReadonly ' ]);
1314
1415$ router ->group (['prefix ' => 'ingress ' ], function () use ($ router ) {
1516 // GET
You can’t perform that action at this time.
0 commit comments