From cd512a25af2efcc031db42aa7794a0da2e8f401e Mon Sep 17 00:00:00 2001 From: Bruno Meilick Date: Sat, 11 Dec 2021 16:27:16 +0000 Subject: [PATCH] :boom: allowed file with additional dots in blueprints, snippets and translations by default can be configured if needed, see #2 and #3 --- classes/Autoloader.php | 10 ++++++---- composer.json | 2 +- tests/site/plugins/example/index.php | 8 +++++++- vendor/composer/installed.php | 8 ++++---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/classes/Autoloader.php b/classes/Autoloader.php index e59d8eb..79ca1e7 100644 --- a/classes/Autoloader.php +++ b/classes/Autoloader.php @@ -19,7 +19,9 @@ final class Autoloader public const ANY_YML = '/^[\w\d\-\_\.]+\.yml$/'; public const PHP_OR_HTMLPHP = '/^[\w\d\-\_]+(\.html)?\.php$/'; public const PHP_OR_YML = '/^[\w\d\-\_]+\.(php|yml)$/'; + public const ANY_PHP_OR_YML = '/^[\w\d\-\_\.]+\.(php|yml)$/'; public const PHP_OR_YML_OR_JSON = '/^[\w\d\-\_]+\.(php|yml|json)$/'; + public const ANY_PHP_OR_YML_OR_JSON = '/^[\w\d\-\_\.]+\.(php|yml|json)$/'; /** @var self */ private static $singleton; @@ -35,7 +37,7 @@ public function __construct(array $options = []) $this->options = array_merge_recursive([ 'blueprints' => [ 'folder' => 'blueprints', - 'name' => static::PHP_OR_YML, + 'name' => static::ANY_PHP_OR_YML, 'key' => 'relativepath', 'require' => false, 'lowercase' => true, @@ -50,7 +52,7 @@ public function __construct(array $options = []) ], 'collections' => [ 'folder' => 'collections', - 'name' => static::PHP, + 'name' => static::ANY_PHP, 'key' => 'relativepath', 'require' => true, 'lowercase' => false, @@ -88,7 +90,7 @@ public function __construct(array $options = []) ], 'snippets' => [ 'folder' => 'snippets', - 'name' => static::PHP_OR_HTMLPHP, + 'name' => static::ANY_PHP, 'key' => 'relativepath', 'require' => false, 'lowercase' => false, @@ -102,7 +104,7 @@ public function __construct(array $options = []) ], 'translations' => [ 'folder' => 'translations', - 'name' => static::PHP_OR_YML_OR_JSON, + 'name' => static::ANY_PHP_OR_YML_OR_JSON, 'key' => 'filename', 'require' => true, 'lowercase' => true, diff --git a/composer.json b/composer.json index 33508f3..4152b3a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "bnomei/autoloader-for-kirby", "type": "project", - "version": "1.3.1", + "version": "1.4.0", "license": "MIT", "description": "Helper to automatically load various Kirby extensions in a plugin", "authors": [ diff --git a/tests/site/plugins/example/index.php b/tests/site/plugins/example/index.php index 18f89f6..4c39128 100644 --- a/tests/site/plugins/example/index.php +++ b/tests/site/plugins/example/index.php @@ -6,11 +6,17 @@ use \Kirby\Cms\App as Kirby; +// disallow additional dots for testcases +autoloader(__DIR__, [ + 'blueprints' => ['name' => \Bnomei\Autoloader::PHP_OR_YML], + 'snippets' => ['name' => \Bnomei\Autoloader::PHP_OR_HTMLPHP], +]); + autoloader(__DIR__)->classes(); Kirby::plugin('bnomei/example', [ 'options' => [ - + ], 'snippets' => autoloader(__DIR__)->snippets(), 'templates' => autoloader(__DIR__)->templates(), diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index d029bcb..dcb3172 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,7 +1,7 @@ array( - 'pretty_version' => '1.3.1', - 'version' => '1.3.1.0', + 'pretty_version' => '1.4.0', + 'version' => '1.4.0.0', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -11,8 +11,8 @@ ), 'versions' => array( 'bnomei/autoloader-for-kirby' => array( - 'pretty_version' => '1.3.1', - 'version' => '1.3.1.0', + 'pretty_version' => '1.4.0', + 'version' => '1.4.0.0', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),