Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
45ea34da94 | ||
|
56eb7e7571 | ||
|
51b51e3de8 |
12
README.md
Normal file
12
README.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# baikal-storage-plugin
|
||||||
|
|
||||||
|
## Install
|
||||||
|
```
|
||||||
|
composer require aerex/baikal-storage-plugin
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
- Add the plugin to `Core/Frameworks/Baikal/Core/Server.php`
|
||||||
|
```
|
||||||
|
$this->server->addPlugin(new \Aerex\BaikalStorage\Plugin())
|
||||||
|
```
|
@@ -24,7 +24,7 @@
|
|||||||
"laminas/laminas-validator": "^2.13",
|
"laminas/laminas-validator": "^2.13",
|
||||||
"laminas/laminas-stdlib": "^3.2",
|
"laminas/laminas-stdlib": "^3.2",
|
||||||
"psr/container": "^1.0",
|
"psr/container": "^1.0",
|
||||||
"symfony/config": "^5.0",
|
"symfony/config": "3.4",
|
||||||
"symfony/process": "^3.4"
|
"symfony/process": "^3.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
@@ -9,13 +9,27 @@ use Symfony\Component\Yaml\Yaml;
|
|||||||
|
|
||||||
class ConfigBuilder implements ConfigurationInterface {
|
class ConfigBuilder implements ConfigurationInterface {
|
||||||
private $configs = [];
|
private $configs = [];
|
||||||
private $configFile;
|
private $configDir;
|
||||||
|
|
||||||
public function __construct($configFile = '~/.config/baikal') {
|
public function __construct($configDir = null) {
|
||||||
$this->configFile = $configFile;
|
if (!isset($configDir)) {
|
||||||
|
$this->configDir = $this->getHomeDir() . '~/.config/baikal';
|
||||||
|
} else {
|
||||||
|
$this->configDir = $configDir;
|
||||||
|
}
|
||||||
$this->processor = new Processor();
|
$this->processor = new Processor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getHomeDir() {
|
||||||
|
if (stristr(PHP_OS, 'WIN')) {
|
||||||
|
return rtrim($_SERVER['HOMEDRIVE'] . $_SERVER['HOMEPATH'], '\\/');
|
||||||
|
} else {
|
||||||
|
return rtrim($_SERVER['HOME'], '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function add($config) {
|
public function add($config) {
|
||||||
$this->configs[] = $config;
|
$this->configs[] = $config;
|
||||||
}
|
}
|
||||||
@@ -32,10 +46,10 @@ class ConfigBuilder implements ConfigurationInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function readContent() {
|
public function readContent() {
|
||||||
if (!is_dir($this->configFile)) {
|
if (!is_dir($this->configDir)) {
|
||||||
mkdir($this->configFile);
|
mkdir($this->configDir, 0755, true);
|
||||||
}
|
}
|
||||||
$contents = sprintf('%s/storage.yml', $this->configFile);
|
$contents = sprintf('%s/storage.yml', $this->configDir);
|
||||||
return file_get_contents($contents);
|
return file_get_contents($contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,5 +8,5 @@ interface IStorage {
|
|||||||
public function save(Calendar $c);
|
public function save(Calendar $c);
|
||||||
public function refresh();
|
public function refresh();
|
||||||
public function getConfig();
|
public function getConfig();
|
||||||
public function setRawConfigs();
|
public function setRawConfigs($rawConfigs);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user