fipamo/app/Http/Controllers/Theming/ThemeController.php

63 lines
1.9 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\Theming;
use App\Http\Controllers\Controller;
use App\Interfaces\PageRepositoryInterface;
use App\Services\AuthService;
use App\Services\SortingService;
use App\Services\AssetService;
class ThemeController extends Controller
{
protected PageRepositoryInterface $pages;
protected AuthService $auth;
protected AssetService $assets;
protected SortingService $sort;
public function __construct(
PageRepositoryInterface $pageRepository,
AuthService $authService,
AssetService $assetService,
SortingService $sortService,
) {
$this->pages = $pageRepository;
$this->auth = $authService;
$this->assets = $assetService;
$this->sort = $sortService;
}
public function getView($view = 'index')
{
//move assets to theme testing dir
$this->assets->moveToTheme();
$currentTheme = $this->assets->getCurrentTheme();
$template;
$pageData = [];
switch ($view) {
case "index":
case "page":
$view == 'index' ?
$template = $currentTheme . '.index' :
$template = $currentTheme . '.page';
$page = $this->pages->getById('532E2250-F8CB-4E87-9782-8AFBEE88DD5E');
$pageData = $this->sort->page($page);
break;
case "tags":
$template = $currentTheme . '.tags';
$pageData = $this->sort->tags();
break;
case "archives":
case "archive":
$template = $currentTheme . '.archive';
$pageData = $this->sort->archive();
break;
}
if ($this->auth::status()) {
return view($template, $pageData);
} else {
return redirect('dashboard/start');
}
}
}