From 8ca6aa5da542035bda023c2c44ad0ced00031e17 Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Sun, 20 Oct 2024 13:53:25 +0200 Subject: [PATCH] Buy plugin: Safer PHP namespace --- site/controllers/buy.php | 11 ++++--- site/controllers/partners-signup.php | 6 ++-- site/plugins/buy/composer.json | 2 +- site/plugins/buy/index.php | 2 +- site/plugins/buy/src/Paddle.php | 2 +- site/plugins/buy/src/Passthrough.php | 2 +- site/plugins/buy/src/Price.php | 2 +- site/plugins/buy/src/Product.php | 2 +- site/plugins/buy/src/RevenueLimit.php | 2 +- site/plugins/buy/src/Sale.php | 2 +- site/plugins/buy/src/Upgrade.php | 2 +- site/plugins/buy/src/Visitor.php | 2 +- .../buy/vendor/composer/autoload_classmap.php | 20 +++++------ .../buy/vendor/composer/autoload_psr4.php | 2 +- .../buy/vendor/composer/autoload_static.php | 33 ++++++++----------- .../plugins/buy/vendor/composer/installed.php | 4 +-- site/routes/buy.php | 6 ++-- site/routes/partners.php | 4 +-- site/snippets/layouts/sale.php | 2 +- site/snippets/templates/buy/product.php | 2 +- 20 files changed, 51 insertions(+), 59 deletions(-) diff --git a/site/controllers/buy.php b/site/controllers/buy.php index d0f7dc8421..4705d5d1aa 100644 --- a/site/controllers/buy.php +++ b/site/controllers/buy.php @@ -1,9 +1,12 @@ expires(); @@ -13,14 +16,14 @@ krsort($discountsReversed); return [ - 'basic' => Buy\Product::Basic, + 'basic' => Product::Basic, 'countries' => option('countries'), 'discounts' => $discounts, 'discountsReversed' => $discountsReversed, 'donation' => option('buy.donation'), - 'enterprise' => Buy\Product::Enterprise, + 'enterprise' => Product::Enterprise, 'sale' => $sale, 'questions' => $page->find('answers')->children(), - 'revenueLimit' => Buy\RevenueLimit::approximation(verbose: true), + 'revenueLimit' => RevenueLimit::approximation(verbose: true), ]; }; diff --git a/site/controllers/partners-signup.php b/site/controllers/partners-signup.php index 26925ed799..a96fe1208a 100644 --- a/site/controllers/partners-signup.php +++ b/site/controllers/partners-signup.php @@ -1,8 +1,8 @@ $baseDir . '/src/Paddle.php', - 'Buy\\Passthrough' => $baseDir . '/src/Passthrough.php', - 'Buy\\Price' => $baseDir . '/src/Price.php', - 'Buy\\Product' => $baseDir . '/src/Product.php', - 'Buy\\RevenueLimit' => $baseDir . '/src/RevenueLimit.php', - 'Buy\\Sale' => $baseDir . '/src/Sale.php', - 'Buy\\Upgrade' => $baseDir . '/src/Upgrade.php', - 'Buy\\Visitor' => $baseDir . '/src/Visitor.php', 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', - 'Kirby\\ComposerInstaller\\CmsInstaller' => $vendorDir . '/getkirby/composer-installer/src/ComposerInstaller/CmsInstaller.php', - 'Kirby\\ComposerInstaller\\Installer' => $vendorDir . '/getkirby/composer-installer/src/ComposerInstaller/Installer.php', - 'Kirby\\ComposerInstaller\\Plugin' => $vendorDir . '/getkirby/composer-installer/src/ComposerInstaller/Plugin.php', - 'Kirby\\ComposerInstaller\\PluginInstaller' => $vendorDir . '/getkirby/composer-installer/src/ComposerInstaller/PluginInstaller.php', + 'Kirby\\Buy\\Paddle' => $baseDir . '/src/Paddle.php', + 'Kirby\\Buy\\Passthrough' => $baseDir . '/src/Passthrough.php', + 'Kirby\\Buy\\Price' => $baseDir . '/src/Price.php', + 'Kirby\\Buy\\Product' => $baseDir . '/src/Product.php', + 'Kirby\\Buy\\RevenueLimit' => $baseDir . '/src/RevenueLimit.php', + 'Kirby\\Buy\\Sale' => $baseDir . '/src/Sale.php', + 'Kirby\\Buy\\Upgrade' => $baseDir . '/src/Upgrade.php', + 'Kirby\\Buy\\Visitor' => $baseDir . '/src/Visitor.php', 'MaxMind\\Db\\Reader' => $vendorDir . '/maxmind-db/reader/src/MaxMind/Db/Reader.php', 'MaxMind\\Db\\Reader\\Decoder' => $vendorDir . '/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php', 'MaxMind\\Db\\Reader\\InvalidDatabaseException' => $vendorDir . '/maxmind-db/reader/src/MaxMind/Db/Reader/InvalidDatabaseException.php', diff --git a/site/plugins/buy/vendor/composer/autoload_psr4.php b/site/plugins/buy/vendor/composer/autoload_psr4.php index 0fa647c731..60571f1b6e 100644 --- a/site/plugins/buy/vendor/composer/autoload_psr4.php +++ b/site/plugins/buy/vendor/composer/autoload_psr4.php @@ -7,6 +7,6 @@ return array( 'MaxMind\\Db\\' => array($vendorDir . '/maxmind-db/reader/src/MaxMind/Db'), + 'Kirby\\Buy\\' => array($baseDir . '/src'), 'Kirby\\' => array($vendorDir . '/getkirby/composer-installer/src'), - 'Buy\\' => array($baseDir . '/src'), ); diff --git a/site/plugins/buy/vendor/composer/autoload_static.php b/site/plugins/buy/vendor/composer/autoload_static.php index cb32cf97de..232df79285 100644 --- a/site/plugins/buy/vendor/composer/autoload_static.php +++ b/site/plugins/buy/vendor/composer/autoload_static.php @@ -13,12 +13,9 @@ class ComposerStaticInita859f2d2dfe8ca8f08832a211f59fd27 ), 'K' => array ( + 'Kirby\\Buy\\' => 10, 'Kirby\\' => 6, ), - 'B' => - array ( - 'Buy\\' => 4, - ), ); public static $prefixDirsPsr4 = array ( @@ -26,30 +23,26 @@ class ComposerStaticInita859f2d2dfe8ca8f08832a211f59fd27 array ( 0 => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db', ), - 'Kirby\\' => + 'Kirby\\Buy\\' => array ( - 0 => __DIR__ . '/..' . '/getkirby/composer-installer/src', + 0 => __DIR__ . '/../..' . '/src', ), - 'Buy\\' => + 'Kirby\\' => array ( - 0 => __DIR__ . '/../..' . '/src', + 0 => __DIR__ . '/..' . '/getkirby/composer-installer/src', ), ); public static $classMap = array ( - 'Buy\\Paddle' => __DIR__ . '/../..' . '/src/Paddle.php', - 'Buy\\Passthrough' => __DIR__ . '/../..' . '/src/Passthrough.php', - 'Buy\\Price' => __DIR__ . '/../..' . '/src/Price.php', - 'Buy\\Product' => __DIR__ . '/../..' . '/src/Product.php', - 'Buy\\RevenueLimit' => __DIR__ . '/../..' . '/src/RevenueLimit.php', - 'Buy\\Sale' => __DIR__ . '/../..' . '/src/Sale.php', - 'Buy\\Upgrade' => __DIR__ . '/../..' . '/src/Upgrade.php', - 'Buy\\Visitor' => __DIR__ . '/../..' . '/src/Visitor.php', 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'Kirby\\ComposerInstaller\\CmsInstaller' => __DIR__ . '/..' . '/getkirby/composer-installer/src/ComposerInstaller/CmsInstaller.php', - 'Kirby\\ComposerInstaller\\Installer' => __DIR__ . '/..' . '/getkirby/composer-installer/src/ComposerInstaller/Installer.php', - 'Kirby\\ComposerInstaller\\Plugin' => __DIR__ . '/..' . '/getkirby/composer-installer/src/ComposerInstaller/Plugin.php', - 'Kirby\\ComposerInstaller\\PluginInstaller' => __DIR__ . '/..' . '/getkirby/composer-installer/src/ComposerInstaller/PluginInstaller.php', + 'Kirby\\Buy\\Paddle' => __DIR__ . '/../..' . '/src/Paddle.php', + 'Kirby\\Buy\\Passthrough' => __DIR__ . '/../..' . '/src/Passthrough.php', + 'Kirby\\Buy\\Price' => __DIR__ . '/../..' . '/src/Price.php', + 'Kirby\\Buy\\Product' => __DIR__ . '/../..' . '/src/Product.php', + 'Kirby\\Buy\\RevenueLimit' => __DIR__ . '/../..' . '/src/RevenueLimit.php', + 'Kirby\\Buy\\Sale' => __DIR__ . '/../..' . '/src/Sale.php', + 'Kirby\\Buy\\Upgrade' => __DIR__ . '/../..' . '/src/Upgrade.php', + 'Kirby\\Buy\\Visitor' => __DIR__ . '/../..' . '/src/Visitor.php', 'MaxMind\\Db\\Reader' => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db/Reader.php', 'MaxMind\\Db\\Reader\\Decoder' => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php', 'MaxMind\\Db\\Reader\\InvalidDatabaseException' => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db/Reader/InvalidDatabaseException.php', diff --git a/site/plugins/buy/vendor/composer/installed.php b/site/plugins/buy/vendor/composer/installed.php index 3060f46609..87c7d5a56c 100644 --- a/site/plugins/buy/vendor/composer/installed.php +++ b/site/plugins/buy/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'getkirby/buy', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '4f3641a2bd4d4f422f464e9cb7797114877abf5d', + 'reference' => '5e80eb4dd91ec531a6d9373a74fe4da28c2738d1', 'type' => 'kirby-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ 'getkirby/buy' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '4f3641a2bd4d4f422f464e9cb7797114877abf5d', + 'reference' => '5e80eb4dd91ec531a6d9373a74fe4da28c2738d1', 'type' => 'kirby-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/site/routes/buy.php b/site/routes/buy.php index b6518d473e..523fa2bea0 100644 --- a/site/routes/buy.php +++ b/site/routes/buy.php @@ -1,8 +1,8 @@ id() !== 'buy' && $sale->isActive() === true): ?> diff --git a/site/snippets/templates/buy/product.php b/site/snippets/templates/buy/product.php index 89c0ac9294..79d866dd93 100644 --- a/site/snippets/templates/buy/product.php +++ b/site/snippets/templates/buy/product.php @@ -19,7 +19,7 @@ per site - +