Skip to content

Commit

Permalink
✨ added support for kirby cli commands
Browse files Browse the repository at this point in the history
Signed-off-by: bnomei <[email protected]>
  • Loading branch information
bnomei committed Nov 8, 2022
1 parent 0171476 commit 5015810
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 69 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The following extensions can be autoloaded:
- [x] blueprints (php or yml)
- [x] classes (php)
- [x] collections (php)
- [x] commands (php)
- [x] controllers (php)
- [x] blockModels (php)
- [x] pageModels (php)
Expand Down Expand Up @@ -106,6 +107,7 @@ Kirby::plugin('bnomei/example', [
],
'blueprints' => autoloader(__DIR__)->blueprints(),
'collections' => autoloader(__DIR__)->collections(),
'commands' => autoloader(__DIR__)->commands(),
'controllers' => autoloader(__DIR__)->controllers(),
'blockModels' => autoloader(__DIR__)->blockModels(),
'pageModels' => autoloader(__DIR__)->pageModels(),
Expand Down
13 changes: 13 additions & 0 deletions classes/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public function __construct(array $options = [])
'require' => true,
'transform' => false,
],
'commands' => [
'folder' => 'commands',
'name' => static::ANY_PHP,
'key' => 'relativepath',
'require' => true,
'transform' => false,
],
'controllers' => [
'folder' => 'controllers',
'name' => static::ANY_PHP,
Expand Down Expand Up @@ -274,6 +281,11 @@ public function collections(): array
return $this->registry('collections');
}

public function commands(): array
{
return $this->registry('commands');
}

public function controllers(): array
{
return $this->registry('controllers');
Expand Down Expand Up @@ -326,6 +338,7 @@ public function toArray(array $merge = []): array
return array_merge_recursive([
'blueprints' => $this->blueprints(),
'collections' => $this->collections(),
'commands' => $this->commands(),
'controllers' => $this->controllers(),
'blockModels' => $this->blockModels(),
'pageModels' => $this->pageModels(),
Expand Down
5 changes: 3 additions & 2 deletions 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.7.0",
"version": "1.8.0",
"license": "MIT",
"description": "Helper to automatically load various Kirby extensions in a plugin",
"authors": [
Expand All @@ -20,6 +20,7 @@
"register",
"registry",
"blueprints",
"commands",
"classes",
"collections",
"controllers",
Expand Down Expand Up @@ -48,7 +49,7 @@
}
},
"require": {
"php": ">=7.4.0",
"php": ">=8.0",
"mustangostang/spyc": "^0.6.3",
"symfony/finder": "^5.4"
},
Expand Down
Loading

0 comments on commit 5015810

Please sign in to comment.