46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
namespace App\Helpers;
|
|
|
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
|
|
|
class Template
|
|
{
|
|
/**
|
|
* Getter for real template name
|
|
*
|
|
* @param $template
|
|
*
|
|
* @return null|string
|
|
*/
|
|
public static function name($template)
|
|
{
|
|
$namespace = null;
|
|
if (strpos($template, '::')) {
|
|
list($namespace, $template) = explode('::', $template);
|
|
$namespace .= '::';
|
|
}
|
|
|
|
$theme = config('app.theme');
|
|
|
|
// list of prefixes
|
|
$prefixes = [$theme . '.custom.', $theme . '.', ''];
|
|
|
|
$view = null;
|
|
foreach ($prefixes as $prefix) {
|
|
if (view()->exists($namespace . 'visitor.' . $prefix . $template)) {
|
|
$view = $namespace . 'visitor.' . $prefix . $template;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (is_null($view)) {
|
|
throw new InvalidArgumentException('Cannot find template for ' . $namespace . $template);
|
|
}
|
|
|
|
return $view;
|
|
}
|
|
|
|
public static function asset($path) {
|
|
return env('SITE_URL').'/assets/'.config('app.theme').'/'.$path;
|
|
}
|
|
} |