Skip to content
Snippets Groups Projects
Verified Commit 5b64e13e authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

refactor: hookable driver should belong to separate package

parent 7d8fa3ad
Branches
Tags
3 merge requests!3improve into wp-hook and some additional unfinished things,!21.x,!1Draft: Basic implementation of plugin initializer
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
<?php
declare( strict_types=1 );
namespace WPDesk\Init\HookDriver;
interface HookableBundle extends \WPDesk\Init\Bundle\Bundle {
public static function hookable(): array;
}
\ No newline at end of file
<?php
declare( strict_types=1 );
namespace WPDesk\Init\HookDriver;
use Psr\Container\ContainerInterface;
use WPDesk\Init\Configuration\ReadableConfig;
class HookableDriver implements HookDriver {
public function register_hooks( ReadableConfig $config, array $bundles, ContainerInterface $container ): void {
$subscribers = $config->get( 'hookables', [] );
foreach ( $bundles as $bundle ) {
$subscribers = \array_merge( $subscribers, $bundle::hookable() );
}
foreach ( $subscribers as $subscriber ) {
$container->get( $subscriber )->hooks();
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment