first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
{
"name": "wpdesk\/wpdesk-sessions",
"description": "DHL Express Shipping Service",
"license": "MIT",
"authors": [
{
"name": "Grzegorz",
"email": "grzegorz@wpdesk.pl"
}
],
"prefer-stable": true,
"minimum-stability": "stable",
"require": {
"php": ">=5.6"
},
"require-dev": {
"phpunit\/phpunit": "<7",
"wp-coding-standards\/wpcs": "^0.14.1",
"squizlabs\/php_codesniffer": "^3.0.2",
"mockery\/mockery": "*",
"10up\/wp_mock": "*",
"wimg\/php-compatibility": "^8",
"wpdesk\/wp-wpdesk-tracker": "^2.0",
"wpdesk\/wp-builder": "^1.4"
},
"autoload": {
"psr-4": {
"FSVendor\\WPDesk\\Sessions\\": "src\/WPDesk\/Sessions\/"
}
},
"autoload-dev": {
"classmap": [
"tests\/"
]
},
"extra": {
"text-domain": "wpdesk-sessions",
"translations-folder": "lang",
"po-files": {
"pl_PL": "pl_PL.po"
}
},
"scripts": {
"test": "echo composer is alive",
"phpcs": "phpcs",
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
"phpunit-unit-fast": "phpunit --configuration phpunit-unit.xml --no-coverage",
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
"phpunit-integration-fast": "phpunit --configuration phpunit-integration.xml --no-coverage",
"docs": "apigen generate"
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* WooCommerce Session Adapter.
* @package WPDesk\Session
*/
namespace FSVendor\WPDesk\Session\Adapter;
use FSVendor\WPDesk\Session\Session;
/**
* Can store session data in WooCommerce Session.
*/
class WooCommerceSession implements \FSVendor\WPDesk\Session\Session
{
/**
* @var \WC_Session
*/
private $wc_session_handler;
/**
* WooCommerceSessionHandler constructor.
*
* @param \WC_Session $wc_session_handler
*/
public function __construct(\WC_Session $wc_session_handler)
{
$this->wc_session_handler = $wc_session_handler;
}
/**
* @param string $key
* @param mixed $value
*/
public function set($key, $value)
{
$this->wc_session_handler->set($key, $value);
}
/**
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get($key, $default = null)
{
return $this->wc_session_handler->get($key, $default);
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* Session interface.
* @package WPDesk\Session
*/
namespace FSVendor\WPDesk\Session;
/**
* Session that can store session data.
*/
interface Session
{
/**
* Sets session value with specified key.
*
* @param string $key
* @param mixed $value
*
* @return void
*/
public function set($key, $value);
/**
* Returns session value for specified key.
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get($key, $default = null);
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Session factory.
*
* @package WPDesk\Session
*/
namespace FSVendor\WPDesk\Session;
use FSVendor\WPDesk\Session\Adapter\WooCommerceSession;
/**
* Can create session adapters.
*/
class SessionFactory
{
/**
* @var WooCommerceSession
*/
private $woocommerce_session_adapter;
/**
* Creates WooCommerce session adapter.
*
* @return Session
*/
public function get_woocommerce_session_adapter()
{
if (null === $this->woocommerce_session_adapter) {
\WC()->initialize_session();
$this->woocommerce_session_adapter = new \FSVendor\WPDesk\Session\Adapter\WooCommerceSession(\WC()->session);
}
return $this->woocommerce_session_adapter;
}
}