Download src/Plugin/Application/CommandHandlers/ListPluginsCommandHandler.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 904 Bytes
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Plugin/Application/CommandHandlers/ListPluginsCommandHandler.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Plugin/Application/CommandHandlers/ListPluginsCommandHandler.php
-
curl -L -o ListPluginsCommandHandler.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Plugin/Application/CommandHandlers/ListPluginsCommandHandler.php
904 Bytes
| declare(strict_types=1); | |
| namespace Plugin\Application\CommandHandlers; | |
| use Iterator; | |
| use Plugin\Application\Commands\ListPluginsCommand; | |
| use Plugin\Domain\PluginWrapper; | |
| use Plugin\Domain\Repositories\PluginRepositoryInterface; | |
| class ListPluginsCommandHandler | |
| { | |
| public function __construct( | |
| private PluginRepositoryInterface $repo | |
| ) { | |
| } | |
| /** | |
| * @param ListPluginsCommand $cmd | |
| * @return Iterator<int,PluginWrapper> | |
| */ | |
| public function handle(ListPluginsCommand $cmd): Iterator | |
| { | |
| $plugins = $this->repo; | |
| if ($cmd->type) { | |
| $plugins = $plugins->filterByType($cmd->type); | |
| } | |
| if ($cmd->status) { | |
| $plugins = $plugins->filterByStatus($cmd->status); | |
| } | |
| if ($cmd->query) { | |
| $plugins = $plugins->search($cmd->query); | |
| } | |
| return $plugins->getIterator(); | |
| } | |
| } | |