Skip to content

Commit

Permalink
Refactoring app structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Jan 9, 2025
1 parent d7c175a commit 47f236c
Show file tree
Hide file tree
Showing 26 changed files with 132 additions and 237 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function handle()

$this->info("3. Generating .env file...");

$dotenv = new \App\Libs\DotEnvGenerator();
$dotenv = new \App\Services\DotEnvGenerator();
$dotenv->addEnvVar('DB_HOST', '127.0.0.1');
$dotenv->addEnvVar('DB_CONNECTION', $database['driver']);
$dotenv->addEnvVar('DB_USERNAME', $database['username']);
Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function step4()
{

if (!Session::has('error')) {
$dotenv = new \App\Libs\DotEnvGenerator();
$dotenv = new \App\Services\DotEnvGenerator(); //TODO Inject
$dotenv->addEnvVar('DB_HOST', Session::get('step2.server'));
$dotenv->addEnvVar('DB_CONNECTION', Session::get('step2.db_driver'));
$dotenv->addEnvVar('DB_USERNAME', Session::get('step2.username'));
Expand Down
4 changes: 2 additions & 2 deletions app/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function create(Request $request)

return view('pages.form', [
'all_page' => Page::all(),
'page_templates' => (new \App\Libs\Theme($request->settings['theme']))->templates(),
'page_templates' => (new \App\Services\Theme($request->settings['theme']))->templates(),
]);
}

Expand Down Expand Up @@ -112,7 +112,7 @@ public function edit(Request $request, Page $page)
return view('pages.form', [
'page' => $page,
'all_page' => Page::all(),
'page_templates' => (new \App\Libs\Theme($request->settings['theme']))->templates(),
'page_templates' => (new \App\Services\Theme($request->settings['theme']))->templates(),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use App\Libs\SearchEngine;
use App\Services\SearchEngine;

class SearchController extends Controller
{
Expand Down
15 changes: 8 additions & 7 deletions app/Controllers/ThemeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use App\Services\Theme;
use App\Model\Settings;

class ThemeController extends Controller
Expand All @@ -19,9 +20,9 @@ class ThemeController extends Controller
public function index(Request $request)
{
return view("theme.index", [
'active_theme' => new \App\Libs\Theme($request->settings['theme']),
'active_theme' => new Theme($request->settings['theme']),
'all_themes' => collect(array_slice(scandir("themes"), 2))->map(function ($theme) {
return new \App\Libs\Theme($theme);
return new Theme($theme);
})
]);
}
Expand All @@ -48,15 +49,15 @@ public function config($slug)
$websiteController = new \App\Controllers\WebsiteController(request());
$websiteController->before();

$theme_engine = new \App\Libs\ThemeEngine(request());
$theme_engine->setTheme(new \App\Libs\Theme(request()->settings['theme']));
$theme_engine = new \App\Services\ThemeEngine(request());
$theme_engine->setTheme(new Theme(request()->settings['theme']));

$theme_engine->boot();

\Website::initalize($theme_engine);

return view("theme.config", [
'active_theme' => new \App\Libs\Theme(request()->settings['theme']),
'active_theme' => new Theme(request()->settings['theme']),
'website_content' => $websiteController->index(request()->input('page')),
]);
}
Expand All @@ -73,7 +74,7 @@ public function options($theme)
$theme_css->save();
}

$theme = new \App\Libs\Theme($theme == null ? request()->settings['theme'] : $theme);
$theme = new Theme($theme == null ? request()->settings['theme'] : $theme);

$translations = [];

Expand All @@ -90,7 +91,7 @@ public function updateTranslations($theme)
if (request()->isMethod('POST')) {

try {
$theme = new \App\Libs\Theme($theme == null ? request()->settings['theme'] : $theme);
$theme = new Theme($theme == null ? request()->settings['theme'] : $theme);

$translations = [];

Expand Down
10 changes: 5 additions & 5 deletions app/Controllers/WebsiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class WebsiteController extends Controller
private $request;

private $engines = [
'hcms' => \App\Libs\ThemeEngine::class,
'blade' => \App\Libs\BladeThemeEngine::class,
//'twig' => \App\Libs\TwigThemeEngine::class,
'hcms' => \App\Services\ThemeEngine::class,
'blade' => \App\Services\BladeThemeEngine::class,
//'twig' => \App\Services\TwigThemeEngine::class,
];

private $theme;

public function __construct(Request $request, \App\Libs\Theme $theme){
public function __construct(Request $request, \App\Services\Theme $theme){
$this->request = $request;
$this->theme = $theme;
}
Expand Down Expand Up @@ -140,7 +140,7 @@ public function search()
}


$search_engine = new \App\Libs\SearchEngine();
$search_engine = new \App\Services\SearchEngine();

$search_engine->registerModel(\App\Model\Blogpost::class);
$search_engine->registerModel(\App\Model\Page::class);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/WebsiteMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class WebsiteMiddleware

private $widgets;

public function __construct(\App\Libs\ShortCode $shortcode_engine){
public function __construct(\App\Services\ShortCode $shortcode_engine){
$this->widgets = $shortcode_engine;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Libs;
namespace App\Interfaces;

interface PluginInterface {

Expand Down
80 changes: 0 additions & 80 deletions app/Libs/BladeThemeEngine.php

This file was deleted.

52 changes: 0 additions & 52 deletions app/Libs/Controller.php

This file was deleted.

61 changes: 0 additions & 61 deletions app/Libs/ViewResolver.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Model/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function getRegister($register, $default = null)

$instance = new $plugin_namespace();

if ($instance instanceof \App\Libs\PluginInterface) {
if ($instance instanceof \App\Interfaces\PluginInterface) {
return $instance->$register();
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/ThemeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Route;
use \App\Libs\Theme;
use \App\Services\Theme;

class ThemeServiceProvider extends ServiceProvider
{
Expand Down
Loading

0 comments on commit 47f236c

Please sign in to comment.