Skip to content

Commit

Permalink
all for all plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Nov 22, 2024
1 parent 2d15b0e commit 6d544e0
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/Shell/AnnotationsShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function startup(): void {
* @return int
*/
public function callbacks() {
$paths = $this->getPaths();
$paths = $this->getPaths('classes');
foreach ($paths as $path) {
if (!is_dir($path)) {
continue;
Expand Down Expand Up @@ -809,6 +809,10 @@ protected function getPaths(?string $type = null): array {
$plugin = (string)$this->param('plugin') ?: null;
if (!$plugin) {
if (!$type) {
return [ROOT . DS];
}

if ($type === 'classes') {
return [ROOT . DS . APP_DIR . DS];
}

Expand All @@ -820,9 +824,13 @@ protected function getPaths(?string $type = null): array {
$paths = [];
foreach ($plugins as $plugin) {
if (!$type) {
$pluginPaths = [PluginPath::classPath($plugin)];
$pluginPaths = [Plugin::path($plugin)];
} else {
$pluginPaths = $type === 'templates' ? App::path('templates', $plugin) : AppPath::get($type, $plugin);
if ($type === 'classes') {
$pluginPaths = [PluginPath::classPath($plugin)];
} else {
$pluginPaths = $type === 'templates' ? App::path('templates', $plugin) : AppPath::get($type, $plugin);
}
}
foreach ($pluginPaths as $pluginPath) {
$paths[] = $pluginPath;
Expand All @@ -839,10 +847,25 @@ protected function getPaths(?string $type = null): array {
*/
protected function getPlugins(string $plugin): array {
if (strpos($plugin, '*') === false) {
return [$plugin];
return [Plugin::path($plugin) => $plugin];
}

$loaded = Plugin::loaded();
$plugins = [];
foreach ($loaded as $name) {
$path = Plugin::path($name);
$rootPath = str_replace(ROOT . DS, '', $path);
if (strpos($rootPath, 'vendor' . DS) === 0) {
continue;
}
$plugins[$path] = $name;
}

if ($plugin === 'all') {
return $plugins;
}

return $this->filterPlugins(Plugin::loaded(), $plugin);
return $this->filterPlugins($loaded, $plugin);
}

/**
Expand Down

0 comments on commit 6d544e0

Please sign in to comment.