Compare commits
14 Commits
74f6779c63
...
feature/co
Author | SHA1 | Date | |
---|---|---|---|
a7380841cf | |||
28dd69e3a5 | |||
f21293bc01 | |||
bf79e9cee7 | |||
cf30a1280d | |||
e11023d1c9 | |||
cfcfefefd8 | |||
09d78192b6 | |||
158220700b | |||
|
76e036181a | ||
|
39f44c8d03 | ||
|
ee0ebff76a | ||
42443c8b58 | |||
e95435a707 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -15,3 +15,6 @@ _nemazat/css/font-awesome.min.css
|
|||||||
app/updater/*.bin
|
app/updater/*.bin
|
||||||
app/logs/*.log
|
app/logs/*.log
|
||||||
backup/*.zip
|
backup/*.zip
|
||||||
|
|
||||||
|
|
||||||
|
vendor/
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule ".docker"]
|
||||||
|
path = .docker
|
||||||
|
url = https://github.com/GamerClassN7/Docker-Xamp-Server.git
|
@@ -5,11 +5,20 @@ ini_set( 'display_errors','1');
|
|||||||
|
|
||||||
//setup
|
//setup
|
||||||
parse_str($_SERVER['QUERY_STRING'], $params);
|
parse_str($_SERVER['QUERY_STRING'], $params);
|
||||||
$urlSes = str_replace((!empty ($params['url']) ? $params['url'] : ""), "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI']));
|
if (defined ("BASEDIR")) {
|
||||||
|
$urlSes = BASEDIR;
|
||||||
|
} else {
|
||||||
|
$urlSes = str_replace((!empty ($params['url']) ? $params['url'] : ""), "", str_replace('https://' . $_SERVER['HTTP_HOST'], "", $_SERVER['REQUEST_URI']));
|
||||||
|
}
|
||||||
|
if (defined ("BASEDIR") && defined ("BASEURL")) {
|
||||||
|
$domain = str_replace("http://", "", str_replace("https://", "", str_replace(BASEDIR, "", BASEURL)));
|
||||||
|
} else {
|
||||||
|
$domain = str_replace("/var/www/", "", $_SERVER['DOCUMENT_ROOT']);
|
||||||
|
}
|
||||||
session_set_cookie_params(
|
session_set_cookie_params(
|
||||||
1209600,
|
1209600,
|
||||||
$urlSes,
|
$urlSes,
|
||||||
str_replace("/var/www/", "", $_SERVER['DOCUMENT_ROOT']),
|
$domain,
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@@ -24,53 +24,43 @@ class RoomsApi extends ApiController
|
|||||||
$type = $subDevicesData[$subDeviceKey][$key]['type'];
|
$type = $subDevicesData[$subDeviceKey][$key]['type'];
|
||||||
} else if (strpos(SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'], '-') !== false) {
|
} else if (strpos(SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'], '-') !== false) {
|
||||||
$type = SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'];
|
$type = SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'];
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Connection Error Creation
|
||||||
|
$connectionError = true;
|
||||||
|
$LastRecordTime = new DateTime($subDevicesData[$subDeviceKey][$key]['time']);
|
||||||
|
$interval = $LastRecordTime->diff(new DateTime());
|
||||||
|
$lastSeen = ($interval->format('%h') * 60 + $interval->format('%i'));
|
||||||
|
|
||||||
|
if ($subDevicesData[$subDeviceKey][$key]['sleep_time'] == NULL || $subDevicesData[$subDeviceKey][$key]['sleep_time'] == 0 || $lastSeen < $subDevicesData[$subDeviceKey][$key]['sleep_time']) {
|
||||||
|
$connectionError = false;
|
||||||
|
}
|
||||||
|
$subDevicesData[$subDeviceKey][$key]['connection_error'] = $connectionError;
|
||||||
|
|
||||||
//Record Translation
|
//Record Translation
|
||||||
$cammelCaseClass = "";
|
$cammelCaseClass = "";
|
||||||
foreach (explode('-', $type) as $word) {
|
foreach (explode('-', $type) as $word) {
|
||||||
$cammelCaseClass .= ucfirst($word);
|
$cammelCaseClass .= ucfirst($word);
|
||||||
}
|
}
|
||||||
if (!class_exists($cammelCaseClass)) {
|
if (class_exists($cammelCaseClass)) {
|
||||||
continue;
|
$deviceClass = new $cammelCaseClass;
|
||||||
|
if (method_exists($deviceClass, 'translate')) {
|
||||||
|
$subDevicesData[$subDeviceKey][$key]['value'] = $deviceClass->translate($subDevicesData[$subDeviceKey][$key]['value']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$deviceClass = new $cammelCaseClass;
|
|
||||||
if (!method_exists($deviceClass, 'translate')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$subDevicesData[$subDeviceKey][$key]['value'] = $deviceClass->translate($subDevicesData[$subDeviceKey][$key]['value']);
|
|
||||||
|
|
||||||
//Connection Error Creation
|
|
||||||
$niceTime = Utilities::ago($LastRecordTime);
|
|
||||||
|
|
||||||
$interval = $LastRecordTime->diff(new DateTime());
|
|
||||||
$hours = $interval->format('%h');
|
|
||||||
$minutes = $interval->format('%i');
|
|
||||||
$lastSeen = ($hours * 60 + $minutes);
|
|
||||||
|
|
||||||
if (
|
|
||||||
$lastSeen < $subDevicesData[$subDeviceKey][$key]['sleep_time'] ||
|
|
||||||
$subDevicesData[$subDeviceKey][$key]['type'] == "on/off" ||
|
|
||||||
$subDevicesData[$subDeviceKey][$key]['type'] == "door" ||
|
|
||||||
$subDevicesData[$subDeviceKey][$key]['type'] == "wather"
|
|
||||||
) {
|
|
||||||
$connectionError = false;
|
|
||||||
}
|
|
||||||
$subDevicesData[$subDeviceKey][$key]['connection_error'] = $connectionError
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($roomsData as $roomKey => $roomData) {
|
foreach ($roomsData as $roomKey => $roomData) {
|
||||||
if ($roomData['device_count'] == 0) continue;
|
if ($roomData['device_count'] == 0) continue;
|
||||||
|
$subDevicesSorted = isset($subDevicesData[$roomData['room_id']]) ? Utilities::sortArrayByKey($subDevicesData[$roomData['room_id']], 'connection_error', 'asc') : [];
|
||||||
$response[] = [
|
$response[] = [
|
||||||
'room_id' => $roomData['room_id'],
|
'room_id' => $roomData['room_id'],
|
||||||
'name' => $roomData['name'],
|
'name' => $roomData['name'],
|
||||||
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
|
'widgets' => $subDevicesSorted,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response($response);
|
$this->response($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,8 +44,6 @@ class WidgetApi extends ApiController
|
|||||||
];
|
];
|
||||||
|
|
||||||
$response = null;
|
$response = null;
|
||||||
$connectionError = true;
|
|
||||||
|
|
||||||
$subDeviceData = SubDeviceManager::getSubdeviceDetailById($subDeviceId);
|
$subDeviceData = SubDeviceManager::getSubdeviceDetailById($subDeviceId);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,14 +4,20 @@ class SettingsManager{
|
|||||||
return Db::loadAll ("SELECT * FROM settings");
|
return Db::loadAll ("SELECT * FROM settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getByName($settingName) {
|
static function getByName($settingName, $type = '') {
|
||||||
|
if ($type != '') return Db::loadOne("SELECT * FROM settings WHERE name = ? AND type = ?", array($settingName, $type));
|
||||||
return Db::loadOne("SELECT * FROM settings WHERE name = ?", array($settingName));
|
return Db::loadOne("SELECT * FROM settings WHERE name = ?", array($settingName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create ($name, $value) {
|
static function getSettingGroup($type) {
|
||||||
|
return Db::loadAll("SELECT * FROM settings WHERE type=?", array($type));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create ($name, $value, $type = '') {
|
||||||
$setting = array (
|
$setting = array (
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
|
'type' => $type,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
Db::add ('settings', $setting);
|
Db::add ('settings', $setting);
|
||||||
@@ -21,12 +27,14 @@ class SettingsManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update ($name, $value) {
|
public static function update ($name, $value, $type = '') {
|
||||||
if ($this.getByName($name)){
|
if (self::getByName($name)){
|
||||||
$this->create($name, $value);
|
self::create($name, $value, $type);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Db::edit ('settings', ['value' => $value], 'WHERE name = ?', array($name));
|
Db::edit ('settings', [
|
||||||
|
'value' => $value
|
||||||
|
], 'WHERE name = ?', array($name));
|
||||||
} catch(PDOException $error) {
|
} catch(PDOException $error) {
|
||||||
echo $error->getMessage();
|
echo $error->getMessage();
|
||||||
die();
|
die();
|
||||||
|
@@ -78,7 +78,7 @@ class SubDeviceManager
|
|||||||
|
|
||||||
//TODO: @Patrik Check line 89
|
//TODO: @Patrik Check line 89
|
||||||
$rows = Db::loadAll("
|
$rows = Db::loadAll("
|
||||||
SELECT d.room_id, d.sleep_time, sd.subdevice_id, sd.device_id, d.icon, d.name, sd.type, sd.unit, r.value FROM subdevices sd
|
SELECT d.room_id, d.sleep_time, sd.subdevice_id, sd.device_id, d.icon, d.name, sd.type, sd.unit, r.value, r.time FROM subdevices sd
|
||||||
JOIN devices d ON sd.device_id = d.device_id
|
JOIN devices d ON sd.device_id = d.device_id
|
||||||
JOIN records r ON r.subdevice_id = sd.subdevice_id
|
JOIN records r ON r.subdevice_id = sd.subdevice_id
|
||||||
WHERE d.room_id IN (" . str_repeat("?,", count($roomIds) - 1) . "?)
|
WHERE d.room_id IN (" . str_repeat("?,", count($roomIds) - 1) . "?)
|
||||||
|
@@ -56,7 +56,27 @@ class Setting extends Template
|
|||||||
$rooms = RoomManager::getAllRooms();
|
$rooms = RoomManager::getAllRooms();
|
||||||
$template->prepare('rooms', $rooms);
|
$template->prepare('rooms', $rooms);
|
||||||
|
|
||||||
|
$settingsManager = new SettingsManager();
|
||||||
|
$dir = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/';
|
||||||
|
$pluginsFiles = array_diff (scandir ($dir), ['..', '.']);
|
||||||
|
|
||||||
|
$plugins = array ();
|
||||||
|
|
||||||
|
foreach ($pluginsFiles as $key => $pluginFile) {
|
||||||
|
$status = (strpos ($pluginFile, "!") !== false ? false : true);
|
||||||
|
if ($status) {
|
||||||
|
$plugins[$key]['name'] = str_replace ("!", "", str_replace (".php", "", $pluginFile));
|
||||||
|
$plugins[$key]['slug'] = strtolower ($plugins[$key]['name']);
|
||||||
|
$result = $settingsManager->getSettingGroup($plugins[$key]['slug']);
|
||||||
|
if (count ($result) > 0) {
|
||||||
|
$plugins[$key]['settings'] = $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$plugins = Utilities::sortArrayByKey($plugins, 'slug', "desc");
|
||||||
|
|
||||||
|
$template->prepare('pluginsSettings', $plugins);
|
||||||
|
|
||||||
$template->render();
|
$template->render();
|
||||||
}
|
}
|
||||||
|
10
composer.json
Normal file
10
composer.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Core\\": "core/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/container": "^8.18"
|
||||||
|
}
|
||||||
|
}
|
207
composer.lock
generated
Normal file
207
composer.lock
generated
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "c3305b3f3f6089062c2031140866dab7",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "illuminate/container",
|
||||||
|
"version": "v8.18.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/illuminate/container.git",
|
||||||
|
"reference": "657cac2aa601aa0223afe0ed8627d0cb443f6a22"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/illuminate/container/zipball/657cac2aa601aa0223afe0ed8627d0cb443f6a22",
|
||||||
|
"reference": "657cac2aa601aa0223afe0ed8627d0cb443f6a22",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/contracts": "^8.0",
|
||||||
|
"php": "^7.3|^8.0",
|
||||||
|
"psr/container": "^1.0"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"psr/container-implementation": "1.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "8.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Illuminate\\Container\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Taylor Otwell",
|
||||||
|
"email": "taylor@laravel.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "The Illuminate Container package.",
|
||||||
|
"homepage": "https://laravel.com",
|
||||||
|
"time": "2020-12-01T14:31:29+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "illuminate/contracts",
|
||||||
|
"version": "v8.18.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/illuminate/contracts.git",
|
||||||
|
"reference": "a73835aad399da42e88217bdbb5e1e4c1e668807"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/illuminate/contracts/zipball/a73835aad399da42e88217bdbb5e1e4c1e668807",
|
||||||
|
"reference": "a73835aad399da42e88217bdbb5e1e4c1e668807",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.3|^8.0",
|
||||||
|
"psr/container": "^1.0",
|
||||||
|
"psr/simple-cache": "^1.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "8.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Illuminate\\Contracts\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Taylor Otwell",
|
||||||
|
"email": "taylor@laravel.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "The Illuminate Contracts package.",
|
||||||
|
"homepage": "https://laravel.com",
|
||||||
|
"time": "2020-11-18T13:57:08+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/container",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/container.git",
|
||||||
|
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
|
||||||
|
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\Container\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "http://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common Container Interface (PHP FIG PSR-11)",
|
||||||
|
"homepage": "https://github.com/php-fig/container",
|
||||||
|
"keywords": [
|
||||||
|
"PSR-11",
|
||||||
|
"container",
|
||||||
|
"container-interface",
|
||||||
|
"container-interop",
|
||||||
|
"psr"
|
||||||
|
],
|
||||||
|
"time": "2017-02-14T16:28:37+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/simple-cache",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/simple-cache.git",
|
||||||
|
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||||
|
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\SimpleCache\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "http://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common interfaces for simple caching",
|
||||||
|
"keywords": [
|
||||||
|
"cache",
|
||||||
|
"caching",
|
||||||
|
"psr",
|
||||||
|
"psr-16",
|
||||||
|
"simple-cache"
|
||||||
|
],
|
||||||
|
"time": "2017-10-23T01:57:42+00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": [],
|
||||||
|
"plugin-api-version": "1.1.0"
|
||||||
|
}
|
5
config/application.php
Normal file
5
config/application.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'providers' => []
|
||||||
|
];
|
26
core/Application/Application.php
Normal file
26
core/Application/Application.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Core\Application;
|
||||||
|
|
||||||
|
use Core\Configuration\Configurations;
|
||||||
|
use Illuminate\Container\Container;
|
||||||
|
|
||||||
|
class Application
|
||||||
|
{
|
||||||
|
/** @var Container $container */
|
||||||
|
private $container;
|
||||||
|
|
||||||
|
/** @var Configurations */
|
||||||
|
private $configurations;
|
||||||
|
|
||||||
|
public function __construct(Container $container, Configurations $configurations)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
$this->configurations = $configurations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
//todo: implement run logic.
|
||||||
|
}
|
||||||
|
}
|
24
core/Configuration/ConfigurationLoader.php
Normal file
24
core/Configuration/ConfigurationLoader.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Core\Configuration;
|
||||||
|
|
||||||
|
class ConfigurationLoader
|
||||||
|
{
|
||||||
|
private const CONFIGURATIONS_DIRECTORY = __DIR__ . DIRECTORY_SEPARATOR
|
||||||
|
. '..' . DIRECTORY_SEPARATOR
|
||||||
|
. '..' . DIRECTORY_SEPARATOR . 'config'
|
||||||
|
. DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
|
public function load(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Concerns
|
||||||
|
* -> Loading configuration files
|
||||||
|
* - Scan directory for files.
|
||||||
|
* - Filtering none config / php files.
|
||||||
|
* - Creating assoc array.
|
||||||
|
*/
|
||||||
|
}
|
25
core/Configuration/Configurations.php
Normal file
25
core/Configuration/Configurations.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Core\Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Configurations
|
||||||
|
* @package Core\Configuration
|
||||||
|
* @author Romano Schoonheim https://github.com/romano1996
|
||||||
|
*/
|
||||||
|
class Configurations
|
||||||
|
{
|
||||||
|
/** @var array */
|
||||||
|
private $configurations;
|
||||||
|
|
||||||
|
public function __construct(ConfigurationLoader $configurationLoader)
|
||||||
|
{
|
||||||
|
// Concern: Storing assoc array to this object.
|
||||||
|
$this->configurations = $configurationLoader->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(string $path)
|
||||||
|
{
|
||||||
|
// Concern: Accessing configurations based on "paths" application.something For example.
|
||||||
|
}
|
||||||
|
}
|
@@ -1,3 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Composer autoload
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Core\Application\Application;
|
||||||
|
use Core\Configuration\Configurations;
|
||||||
|
use Illuminate\Container\Container;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
$container = new Container();
|
||||||
|
|
||||||
|
$container->singleton(
|
||||||
|
Configurations::class,
|
||||||
|
Configurations::class
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create application & run
|
||||||
|
*/
|
||||||
|
$application = new Application(
|
||||||
|
$container,
|
||||||
|
$container->make(Configurations::class)
|
||||||
|
);
|
||||||
|
$application->run();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap v1.0
|
||||||
|
*/
|
||||||
require_once __DIR__ . '/../app/Bootstrap.php';
|
require_once __DIR__ . '/../app/Bootstrap.php';
|
Reference in New Issue
Block a user