feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
This commit is contained in:
103
modules/system/twig/Loader.php
Normal file
103
modules/system/twig/Loader.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php namespace System\Twig;
|
||||
|
||||
use App;
|
||||
use Exception;
|
||||
use File;
|
||||
use InvalidArgumentException;
|
||||
use Twig\Source as TwigSource;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Loader\LoaderInterface as TwigLoaderInterface;
|
||||
use Winter\Storm\Support\Str;
|
||||
|
||||
/**
|
||||
* This class implements a Twig template loader for the core system and backend.
|
||||
*
|
||||
* @package winter\wn-system-module
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class Loader implements TwigLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var bool Allow any local file
|
||||
*/
|
||||
public static $allowInclude = false;
|
||||
|
||||
/**
|
||||
* @var array Cache
|
||||
*/
|
||||
protected $cache = [];
|
||||
|
||||
/**
|
||||
* Gets the path of a view file.
|
||||
*/
|
||||
protected function findTemplate(string $name): string
|
||||
{
|
||||
$finder = App::make('view')->getFinder();
|
||||
|
||||
if (isset($this->cache[$name])) {
|
||||
return $this->cache[$name];
|
||||
}
|
||||
|
||||
if (static::$allowInclude === true && File::isFile($name)) {
|
||||
return $this->cache[$name] = $name;
|
||||
}
|
||||
|
||||
try {
|
||||
$path = $finder->find($name);
|
||||
} catch (InvalidArgumentException $ex) {
|
||||
if (Str::contains($ex->getMessage(), 'not found')) {
|
||||
throw new LoaderError($ex->getMessage());
|
||||
}
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $this->cache[$name] = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Twig content string.
|
||||
* This step is cached internally by Twig.
|
||||
*/
|
||||
public function getSourceContext(string $name): TwigSource
|
||||
{
|
||||
return new TwigSource(File::get($this->findTemplate($name)), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Twig cache key.
|
||||
*/
|
||||
public function getCacheKey(string $name): string
|
||||
{
|
||||
return $this->findTemplate($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the content is fresh.
|
||||
*/
|
||||
public function isFresh(string $name, int $time): bool
|
||||
{
|
||||
return File::lastModified($this->findTemplate($name)) <= $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file name of the loaded template.
|
||||
*/
|
||||
public function getFilename(string $name): string
|
||||
{
|
||||
return $this->findTemplate($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the template exists.
|
||||
*/
|
||||
public function exists(string $name): bool
|
||||
{
|
||||
try {
|
||||
$this->findTemplate($name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception $exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user