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:
91
modules/backend/traits/SessionMaker.php
Normal file
91
modules/backend/traits/SessionMaker.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Backend\Traits;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Winter\Storm\Support\Str;
|
||||
|
||||
/**
|
||||
* Session Maker Trait
|
||||
*
|
||||
* Adds session management based methods to a controller class, or a class
|
||||
* that contains a `$controller` property referencing a controller.
|
||||
*
|
||||
* @package winter\wn-backend-module
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
trait SessionMaker
|
||||
{
|
||||
/**
|
||||
* Saves a widget related key/value pair in to session data.
|
||||
* @param string $key Unique key for the data store.
|
||||
* @param mixed $value The value to store.
|
||||
* @return void
|
||||
*/
|
||||
protected function putSession($key, $value)
|
||||
{
|
||||
$sessionId = $this->makeSessionId();
|
||||
|
||||
$currentStore = $this->getSession();
|
||||
|
||||
$currentStore[$key] = $value;
|
||||
|
||||
Session::put($sessionId, base64_encode(serialize($currentStore)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a widget related key/value pair from session data.
|
||||
* @param string $key Unique key for the data store.
|
||||
* @param string $default A default value to use when value is not found.
|
||||
* @return string
|
||||
*/
|
||||
protected function getSession($key = null, $default = null)
|
||||
{
|
||||
$sessionId = $this->makeSessionId();
|
||||
|
||||
$currentStore = [];
|
||||
|
||||
if (
|
||||
Session::has($sessionId) &&
|
||||
($cached = @unserialize(@base64_decode(Session::get($sessionId)))) !== false
|
||||
) {
|
||||
$currentStore = $cached;
|
||||
}
|
||||
|
||||
if ($key === null) {
|
||||
return $currentStore;
|
||||
}
|
||||
|
||||
return $currentStore[$key] ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique session identifier for this widget and controller action.
|
||||
* @return string
|
||||
*/
|
||||
protected function makeSessionId()
|
||||
{
|
||||
$controller = property_exists($this, 'controller') && $this->controller
|
||||
? $this->controller
|
||||
: $this;
|
||||
|
||||
$uniqueId = method_exists($this, 'getId') ? $this->getId() : $controller->getId();
|
||||
|
||||
// Removes Class name and "Controllers" directory
|
||||
$rootNamespace = Str::getClassId(Str::getClassNamespace(Str::getClassNamespace($controller)));
|
||||
|
||||
// The controller action is intentionally omitted, session should be shared for all actions
|
||||
return 'widget.' . $rootNamespace . '-' . class_basename($controller) . '-' . $uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all session data related to this widget.
|
||||
* @return void
|
||||
*/
|
||||
public function resetSession()
|
||||
{
|
||||
$sessionId = $this->makeSessionId();
|
||||
|
||||
Session::forget($sessionId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user