diff --git a/.gitignore b/.gitignore index 539bf182..b30b7fb4 100644 --- a/.gitignore +++ b/.gitignore @@ -187,3 +187,7 @@ data castopod/ castopod-*.zip castopod-*.tar.gz + +# Plugins +plugins/* +!plugins/.gitkeep diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index 45072e31..2f48aa63 100644 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -50,10 +50,12 @@ class Autoload extends AutoloadConfig 'Modules\Media' => ROOTPATH . 'modules/Media/', 'Modules\MediaClipper' => ROOTPATH . 'modules/MediaClipper/', 'Modules\Platforms' => ROOTPATH . 'modules/Platforms/', + 'Modules\Plugins' => ROOTPATH . 'modules/Plugins/', 'Modules\PodcastImport' => ROOTPATH . 'modules/PodcastImport/', 'Modules\PremiumPodcasts' => ROOTPATH . 'modules/PremiumPodcasts/', 'Modules\Update' => ROOTPATH . 'modules/Update/', 'Modules\WebSub' => ROOTPATH . 'modules/WebSub/', + 'Plugins' => ROOTPATH . 'plugins', 'Themes' => ROOTPATH . 'themes', 'ViewComponents' => APPPATH . 'Libraries/ViewComponents/', 'ViewThemes' => APPPATH . 'Libraries/ViewThemes/', diff --git a/ecs.php b/ecs.php index 87351225..4d41a5ce 100644 --- a/ecs.php +++ b/ecs.php @@ -15,6 +15,7 @@ return ECSConfig::configure() ->withPaths([ __DIR__ . '/app', __DIR__ . '/modules', + __DIR__ . '/plugins', __DIR__ . '/themes', __DIR__ . '/tests', __DIR__ . '/public', diff --git a/modules/Plugins/BasePlugin.php b/modules/Plugins/BasePlugin.php new file mode 100644 index 00000000..5a61d2b8 --- /dev/null +++ b/modules/Plugins/BasePlugin.php @@ -0,0 +1,33 @@ + $params + */ + public function run(array $params): void + { + // TODO: + } +} diff --git a/modules/Plugins/Config/Plugins.php b/modules/Plugins/Config/Plugins.php new file mode 100644 index 00000000..08cbb8e7 --- /dev/null +++ b/modules/Plugins/Config/Plugins.php @@ -0,0 +1,15 @@ + + */ + public array $repositories = ['https://castopod.org/plugins/repository.json']; +} diff --git a/modules/Plugins/Config/Routes.php b/modules/Plugins/Config/Routes.php new file mode 100644 index 00000000..984bbc5a --- /dev/null +++ b/modules/Plugins/Config/Routes.php @@ -0,0 +1,20 @@ +group( + config('Admin') +->gateway, + [ + 'namespace' => 'Modules\Plugins\Controllers', + ], + static function ($routes): void { + $routes->get('plugins', 'PluginsController', [ + 'as' => 'plugins', + 'filter' => 'permission:podcasts.import', + ]); + } +); diff --git a/modules/Plugins/Config/Services.php b/modules/Plugins/Config/Services.php new file mode 100644 index 00000000..96113ee7 --- /dev/null +++ b/modules/Plugins/Config/Services.php @@ -0,0 +1,20 @@ + $plugins->getInstalled(), + ]); + } +} diff --git a/modules/Plugins/PluginInterface.php b/modules/Plugins/PluginInterface.php new file mode 100644 index 00000000..7c46f18b --- /dev/null +++ b/modules/Plugins/PluginInterface.php @@ -0,0 +1,16 @@ + + */ + protected array $installed = []; + + public function registerPlugin(PluginInterface $plugin): void + { + $this->installed[] = $plugin; + } + + /** + * @return array + */ + public function getInstalled(): array + { + return $this->installed; + } +} diff --git a/phpstan.neon b/phpstan.neon index 9982f691..8b003672 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -27,6 +27,7 @@ parameters: - Modules\Install\Config\ - Modules\Media\Config\ - Modules\MediaClipper\Config\ + - Modules\Plugins\Config\ - Modules\PodcastImport\Config\ - Modules\PremiumPodcasts\Config\ - Modules\WebSub\Config\ @@ -45,6 +46,7 @@ parameters: - Michalsn\Uuid\Config\Services - Modules\Media\Config\Services - Modules\Platforms\Config\Services + - Modules\Plugins\Config\Services - Modules\PremiumPodcasts\Config\Services ignoreErrors: - '#^Call to an undefined method CodeIgniter\\Cache\\CacheInterface\:\:deleteMatching\(\)#' diff --git a/plugins/.gitkeep b/plugins/.gitkeep new file mode 100644 index 00000000..e69de29b