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:
130
modules/system/classes/ComposerManager.php
Normal file
130
modules/system/classes/ComposerManager.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php namespace System\Classes;
|
||||
|
||||
/**
|
||||
* Composer manager
|
||||
*
|
||||
* This class manages composer packages introduced by plugins. Each loaded
|
||||
* package is added to a global pool to ensure a package is not loaded
|
||||
* twice by the composer instance introduced by a plugin. This class
|
||||
* is used as a substitute for the vendor/autoload.php file.
|
||||
*
|
||||
* @package winter\wn-system-module
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class ComposerManager
|
||||
{
|
||||
use \Winter\Storm\Support\Traits\Singleton;
|
||||
|
||||
protected $namespacePool = [];
|
||||
|
||||
protected $psr4Pool = [];
|
||||
|
||||
protected $classMapPool = [];
|
||||
|
||||
protected $includeFilesPool = [];
|
||||
|
||||
/**
|
||||
* @var Composer\Autoload\ClassLoader The primary composer instance.
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->loader = include base_path() .'/vendor/autoload.php';
|
||||
$this->preloadPools();
|
||||
}
|
||||
|
||||
protected function preloadPools()
|
||||
{
|
||||
$this->classMapPool = array_fill_keys(array_keys($this->loader->getClassMap()), true);
|
||||
$this->namespacePool = array_fill_keys(array_keys($this->loader->getPrefixes()), true);
|
||||
$this->psr4Pool = array_fill_keys(array_keys($this->loader->getPrefixesPsr4()), true);
|
||||
$this->includeFilesPool = $this->preloadIncludeFilesPool();
|
||||
}
|
||||
|
||||
protected function preloadIncludeFilesPool()
|
||||
{
|
||||
$result = [];
|
||||
$vendorPath = base_path() .'/vendor';
|
||||
|
||||
if (file_exists($file = $vendorPath . '/composer/autoload_files.php')) {
|
||||
$includeFiles = require $file;
|
||||
foreach ($includeFiles as $includeFile) {
|
||||
$relativeFile = $this->stripVendorDir($includeFile, $vendorPath);
|
||||
$result[$relativeFile] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar function to including vendor/autoload.php.
|
||||
* @param string $vendorPath Absoulte path to the vendor directory.
|
||||
* @return void
|
||||
*/
|
||||
public function autoload($vendorPath)
|
||||
{
|
||||
$dir = $vendorPath . '/composer';
|
||||
|
||||
if (file_exists($file = $dir . '/autoload_namespaces.php')) {
|
||||
$map = require $file;
|
||||
foreach ($map as $namespace => $path) {
|
||||
if (isset($this->namespacePool[$namespace])) {
|
||||
continue;
|
||||
}
|
||||
$this->loader->set($namespace, $path);
|
||||
$this->namespacePool[$namespace] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($file = $dir . '/autoload_psr4.php')) {
|
||||
$map = require $file;
|
||||
foreach ($map as $namespace => $path) {
|
||||
if (isset($this->psr4Pool[$namespace])) {
|
||||
continue;
|
||||
}
|
||||
$this->loader->setPsr4($namespace, $path);
|
||||
$this->psr4Pool[$namespace] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($file = $dir . '/autoload_classmap.php')) {
|
||||
$classMap = require $file;
|
||||
if ($classMap) {
|
||||
$classMapDiff = array_diff_key($classMap, $this->classMapPool);
|
||||
$this->loader->addClassMap($classMapDiff);
|
||||
$this->classMapPool += array_fill_keys(array_keys($classMapDiff), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($file = $dir . '/autoload_files.php')) {
|
||||
$includeFiles = require $file;
|
||||
foreach ($includeFiles as $includeFile) {
|
||||
$relativeFile = $this->stripVendorDir($includeFile, $vendorPath);
|
||||
if (isset($this->includeFilesPool[$relativeFile])) {
|
||||
continue;
|
||||
}
|
||||
require $includeFile;
|
||||
$this->includeFilesPool[$relativeFile] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the vendor directory from a path.
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
protected function stripVendorDir($path, $vendorDir)
|
||||
{
|
||||
$path = realpath($path);
|
||||
$vendorDir = realpath($vendorDir);
|
||||
|
||||
if (strpos($path, $vendorDir) === 0) {
|
||||
$path = substr($path, strlen($vendorDir));
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user