ro
1f62e6f816
decided to keep the sorting service class as is and remix how it works to return data objects rather than just settings information to render pages. the overall size of the class is still large but now there are some opportunites to move around some methodolgy to reduce it. also made the necessary changes in the render service class and the theme controller to use the new methodology
63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?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');
|
|
}
|
|
}
|
|
}
|