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
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php namespace System\Helpers;
|
|
|
|
use View as ViewFacade;
|
|
|
|
/**
|
|
* This helper class is used to extract basic variables
|
|
* (scalar or array) from the global `View` Facade.
|
|
*
|
|
* You can register these global variables with `View::share`.
|
|
*
|
|
* View::share('siteName', 'Winter CMS');
|
|
*
|
|
* Then available globally for use in the front-end and mail templates.
|
|
*/
|
|
class View
|
|
{
|
|
/**
|
|
* @var array Cache for global variables.
|
|
*/
|
|
protected static $globalVarCache;
|
|
|
|
/**
|
|
* Returns shared view variables, this should be used for simple rendering cycles.
|
|
* Such as content blocks and mail templates.
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function getGlobalVars()
|
|
{
|
|
if (static::$globalVarCache !== null) {
|
|
return static::$globalVarCache;
|
|
}
|
|
|
|
$vars = array_filter(ViewFacade::getShared(), function ($var) {
|
|
return is_scalar($var) || is_array($var);
|
|
});
|
|
|
|
return static::$globalVarCache = $vars;
|
|
}
|
|
|
|
/**
|
|
* Clears the static cache for global variables.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function clearVarCache()
|
|
{
|
|
static::$globalVarCache = null;
|
|
}
|
|
}
|