Skip to content

Commit

Permalink
💥 allowed file with additional dots in blueprints, snippets and trans…
Browse files Browse the repository at this point in the history
…lations by default

can be configured if needed, see #2 and #3
  • Loading branch information
bnomei committed Dec 11, 2021
1 parent 8e0bab2 commit cd512a2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
10 changes: 6 additions & 4 deletions classes/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
8 changes: 7 additions & 1 deletion tests/site/plugins/example/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php return array(
'root' => 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(),
Expand All @@ -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(),
Expand Down

0 comments on commit cd512a2

Please sign in to comment.