FEATURE: make shortcut for getting currently installed template
This commit is contained in:
@@ -1,6 +1,44 @@
|
||||
<?php
|
||||
namespace App\Helpers;
|
||||
|
||||
class CurrentTemplate {
|
||||
|
||||
use App\Models\Module;
|
||||
|
||||
class CurrentTemplate
|
||||
{
|
||||
protected static $template;
|
||||
protected static $initialized = false;
|
||||
|
||||
/**
|
||||
* Getter for currently set template
|
||||
*
|
||||
* @return Module
|
||||
*/
|
||||
public static function get()
|
||||
{
|
||||
if (!self::$initialized) {
|
||||
self::$template = Module::where('is_template', true)
|
||||
->where('enabled', true)
|
||||
->first();
|
||||
}
|
||||
|
||||
return self::$template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for getting template handler
|
||||
*
|
||||
* @return string
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public static function handler()
|
||||
{
|
||||
$template = self::get();
|
||||
|
||||
if (!$template) {
|
||||
throw new \ErrorException('No template selected, no handler available!');
|
||||
}
|
||||
|
||||
return $template->handler;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user