Skip to content

Commit 60ac514

Browse files
authored
Create Codebase.php
1 parent 763c1bf commit 60ac514

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/frdl/Codebase.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace frdl{
4+
5+
if (!\class_exists(Codebase::class, false)) {
6+
abstract class Codebase
7+
{
8+
protected $channels = null;
9+
protected $channel = null;
10+
public function __construct(string $channel = null){
11+
$this->channels = [];
12+
13+
$this->channels[self::CHANNEL_LATEST] = [
14+
'RemotePsr4UrlTemplate' => 'https://webfan.de/install/latest/?source=${class}&salt=${salt}&source-encoding=b64',
15+
'RemoteModulesBaseUrl' => 'https://webfan.de/install/latest',
16+
17+
];
18+
19+
$this->channels[self::CHANNEL_STABLE] = [
20+
'RemotePsr4UrlTemplate' => 'https://webfan.de/install/stable/?source=${class}&salt=${salt}&source-encoding=b64',
21+
'RemoteModulesBaseUrl' => 'https://webfan.de/install/stable',
22+
23+
];
24+
25+
$this->channels[self::CHANNEL_FALLBACK] = [
26+
'RemotePsr4UrlTemplate' => 'https://webfan.de/install/?source=${class}&salt=${salt}&source-encoding=b64',
27+
'RemoteModulesBaseUrl' => 'https://webfan.de/install/modules',
28+
];
29+
30+
if(null !== $channel && isset(static::CHANNELS[$channel])){
31+
$this->setUpdateChannel(static::CHANNELS[$channel]);
32+
}else{
33+
$this->setUpdateChannel(static::CHANNELS[self::CHANNEL_LATEST]);
34+
}
35+
}
36+
37+
38+
public function setUpdateChannel(string $channel){
39+
$this->channel = $channel;
40+
return $this;
41+
}
42+
43+
public function getUpdateChannel() : string{
44+
return $this->channel;
45+
}
46+
47+
public function getRemotePsr4UrlTemplate() : string{
48+
return $this->channels[$this->getUpdateChannel()]['RemotePsr4UrlTemplate'];
49+
}
50+
51+
public function getRemoteModulesBaseUrl() : string{
52+
return $this->channels[$this->getUpdateChannel()]['RemoteModulesBaseUrl'];
53+
}
54+
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)