Skip to content

Commit

Permalink
Kernek:plugins implements
Browse files Browse the repository at this point in the history
  • Loading branch information
Asisyas committed Feb 9, 2022
1 parent 80e05b7 commit e32423d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Configuration/PluginConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(protected ApplicationConfigurationInterface $configu
/**
* @param string $list
* @param string $separator
* @return array
* @return string[]
*/
protected function explodeStringToArray(string $list, string $separator = ','): array
{
Expand Down
8 changes: 6 additions & 2 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ protected function loadPlugin(string $applicationPluginClass): void
/**
* {@inheritDoc}
*/
public function plugins(): array
public function plugins(string $interfaceInherited = null): iterable
{
return $this->plugins;
foreach ($this->plugins as $plugin) {
if(!$interfaceInherited || ($plugin instanceof $interfaceInherited)) {
yield $plugin;
}
}
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/KernelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public function run(): void;
public function terminate(): void;

/**
* @return ApplicationPluginInterface[]
* @param string|null $interfaceInherited
*
* @return iterable
*/
public function plugins(): array;
public function plugins(string $interfaceInherited = null): iterable;
}

0 comments on commit e32423d

Please sign in to comment.