diff --git a/classes/Autoloader.php b/classes/Autoloader.php index 3151e37..cfc91d5 100644 --- a/classes/Autoloader.php +++ b/classes/Autoloader.php @@ -73,7 +73,7 @@ public function __construct(array $options = []) 'require' => true, 'transform' => fn ($key) => static::pascalToKebabCase($key), ], - 'blockmodels' => [ + 'blockModels' => [ 'folder' => 'models', 'name' => static::BLOCK_PHP, 'key' => 'classname', @@ -81,7 +81,7 @@ public function __construct(array $options = []) 'transform' => fn ($key) => static::pascalToKebabCase($key), 'map' => [], ], - 'pagemodels' => [ + 'pageModels' => [ 'folder' => 'models', 'name' => static::PAGE_PHP, 'key' => 'classname', @@ -103,7 +103,7 @@ public function __construct(array $options = []) 'require' => true, 'transform' => false, ], - 'usermodels' => [ + 'userModels' => [ 'folder' => 'models', 'name' => static::USER_PHP, 'key' => 'classname', @@ -231,6 +231,9 @@ private function registry(string $type): array } elseif ($options['require'] && $extension && strtolower($extension) === 'php') { $path = $file->getPathname(); $this->registry[$type][$key] = require_once $path; + } elseif ($options['folder'] === 'blueprints' && $extension && strtolower($extension) === 'php') { + $path = $file->getPathname(); + $this->registry[$type][$key] = require_once $path; } elseif ($options['require'] && $extension && strtolower($extension) === 'json') { $path = $file->getPathname(); $this->registry[$type][$key] = json_decode(file_get_contents($path), true); @@ -274,7 +277,7 @@ private function registry(string $type): array // if blueprint is not empty if (!empty($blueprint)) { // merge with existing blueprint - $this->registry['blueprints'] = array_merge_recursive($this->registry['blueprints'], $blueprint); + $this->registry['blueprints'] = array_merge($this->registry['blueprints'], $blueprint); } } } @@ -315,12 +318,12 @@ public function controllers(): array public function blockModels(): array { - return $this->registry('blockmodels'); + return $this->registry('blockModels'); } public function pageModels(): array { - return $this->registry('pagemodels'); + return $this->registry('pageModels'); } public function routes(): array @@ -335,7 +338,7 @@ public function apiRoutes(): array public function userModels(): array { - return $this->registry('usermodels'); + return $this->registry('userModels'); } public function snippets(): array @@ -376,9 +379,7 @@ public function toArray(array $merge = []): array foreach ($types as $callback) { $c = (array) $callback(); $r = (array) $this->registry; - $this->registry = array_merge_recursive($r, $c); - // NOTE: if done like this PHP does not merge correctly for whatever reason - // $this->registry = array_merge_recursive($this->registry, $callback()); + $this->registry = array_merge($r, $c); } // merge on top but do not store in the registry diff --git a/composer.json b/composer.json index 0d87557..1189e22 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "bnomei/autoloader-for-kirby", "type": "project", - "version": "1.10.4", + "version": "1.11.0", "license": "MIT", "description": "Helper to automatically load various Kirby extensions in a plugin", "authors": [ diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index ee07c91..3e13dba 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,8 +1,8 @@ array( 'name' => 'bnomei/autoloader-for-kirby', - 'pretty_version' => '1.10.4', - 'version' => '1.10.4.0', + 'pretty_version' => '1.11.0', + 'version' => '1.11.0.0', 'reference' => NULL, 'type' => 'project', 'install_path' => __DIR__ . '/../../', @@ -11,8 +11,8 @@ ), 'versions' => array( 'bnomei/autoloader-for-kirby' => array( - 'pretty_version' => '1.10.4', - 'version' => '1.10.4.0', + 'pretty_version' => '1.11.0', + 'version' => '1.11.0.0', 'reference' => NULL, 'type' => 'project', 'install_path' => __DIR__ . '/../../',