diff --git a/src/Binding/Binder/HookBinderBinder.php b/src/Binding/Binder/HookBinderBinder.php deleted file mode 100644 index 888781cc25f0a6a3f57a92a70f14fcf65420b7f6..0000000000000000000000000000000000000000 --- a/src/Binding/Binder/HookBinderBinder.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace WPDesk\Init\Binding\Binder; - -use Psr\Container\ContainerInterface; -use WPDesk\Init\Binding\Binder; -use WPDesk\Init\Binding\Definition; -use WPDesk\Init\Binding\Definition\HookBinderDefinition; -use WPDesk\Init\Binding\Definition\HookableDefinition; - -class HookBinderBinder implements Binder { - - /** @var ContainerInterface */ - private $container; - - public function __construct( ContainerInterface $c ) { - $this->container = $c; - } - - public function can_bind( Definition $def ): bool { - return $def instanceof HookBinderDefinition; - } - - public function bind( Definition $def ): void { - if ( $this->can_bind( $def ) ) { - $this->container->get( $def->value() )->bind(); - } - } -} diff --git a/src/Binding/Definition/HookBinderDefinition.php b/src/Binding/Definition/HookBinderDefinition.php deleted file mode 100644 index 5212ef3a7c8a4033ba0cd4f31840582ed628f984..0000000000000000000000000000000000000000 --- a/src/Binding/Definition/HookBinderDefinition.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace WPDesk\Init\Binding\Definition; - -use WPDesk\Init\Binding\Definition; -use WPDesk\Init\Binding\HookBinder; - -/** @implements Definition<class-string<HookBinder>> */ -class HookBinderDefinition implements Definition { - - /** @var ?string */ - private $hook; - - /** @var class-string<HookBinder> */ - private $hookable; - - public function __construct( - string $hookable, - ?string $hook = null, - ) { - $this->hook = $hook; - $this->hookable = $hookable; - } - - public function hook(): ?string { - return $this->hook; - } - - public function value() { - return $this->hookable; - } -} diff --git a/src/Binding/DefinitionFactory.php b/src/Binding/DefinitionFactory.php index 5827b8950561be486a4ad4cfcc701e68b6529a70..5b66072e90754f9850266fb160bacbab83e5919b 100644 --- a/src/Binding/DefinitionFactory.php +++ b/src/Binding/DefinitionFactory.php @@ -5,22 +5,14 @@ declare(strict_types=1); namespace WPDesk\Init\Binding; use WPDesk\Init\Binding\Definition\CallableDefinition; -use WPDesk\Init\Binding\Definition\HookBinderDefinition; use WPDesk\Init\Binding\Definition\HookableDefinition; use WPDesk\Init\Binding\Definition\UnknownDefinition; -use WPDesk\PluginBuilder\Plugin\Hookable; class DefinitionFactory { public function create( $value, ?string $hook ): Definition { - if ( is_string( $value ) && class_exists( $value ) ) { - if ( is_subclass_of( $value, Hookable::class, true ) ) { - return new HookableDefinition( $value, $hook ); - } - - if ( is_subclass_of( $value, HookBinder::class, true ) ) { - return new HookBinderDefinition( $value, $hook ); - } + if ( is_string( $value ) && class_exists( $value ) && is_subclass_of( $value, Hookable::class, true ) ) { + return new HookableDefinition( $value, $hook ); } if ( is_callable( $value ) ) { diff --git a/src/Binding/HookBinder.php b/src/Binding/HookBinder.php deleted file mode 100644 index 5b6c18438d76a7e2e8cbe3f1d57f7ddfb7a18d50..0000000000000000000000000000000000000000 --- a/src/Binding/HookBinder.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php - -namespace WPDesk\Init\Binding; - -interface HookBinder { - - public function bind(): void; -} diff --git a/src/Binding/Hookable.php b/src/Binding/Hookable.php new file mode 100644 index 0000000000000000000000000000000000000000..3fb1e51b46ee5f6e4a0a9c410e5453bce0acb0eb --- /dev/null +++ b/src/Binding/Hookable.php @@ -0,0 +1,10 @@ +<?php + +declare(strict_types=1); + +namespace WPDesk\Init\Binding; + +interface Hookable extends \WPDesk\PluginBuilder\Plugin\Hookable { + + public function hooks(): void; +} diff --git a/src/Binding/ObservableBinder.php b/src/Binding/ObservableBinder.php deleted file mode 100644 index 942ee2c2bb3050814b5d99c92602a3314449c535..0000000000000000000000000000000000000000 --- a/src/Binding/ObservableBinder.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -declare(strict_types=1); - -namespace WPDesk\Init\Binding; - -final class ObservableBinder implements HookBinder { - - /** @var HookBinder */ - private $binder; - - private $is_bound = false; - - public function __construct( HookBinder $binder ) { - $this->binder = $binder; - } - - public function bind(): void { - $this->binder->bind(); - $this->is_bound = true; - } - - public function is_bound(): bool { - return $this->is_bound; - } -} diff --git a/src/Binding/StoppableBinder.php b/src/Binding/StoppableBinder.php index 99957b95ded2f4351a8cd9a1c22f479e1f954bd6..daf5852fdc2f9905705c60a0a151a96c67e627be 100644 --- a/src/Binding/StoppableBinder.php +++ b/src/Binding/StoppableBinder.php @@ -3,7 +3,7 @@ declare(strict_types=1); namespace WPDesk\Init\Binding; -interface StoppableBinder extends HookBinder { +interface StoppableBinder extends Hookable { public function should_stop(): bool; } diff --git a/src/CommonBinding/I18n.php b/src/CommonBinding/I18n.php index a192df0c3f98b3cca6564d9882794319f3d4f6b4..2ab91db0f6ab29d324ca428ae0bb9e6714ebe218 100644 --- a/src/CommonBinding/I18n.php +++ b/src/CommonBinding/I18n.php @@ -2,10 +2,10 @@ namespace WPDesk\Init\CommonBinding; -use WPDesk\Init\Binding\HookBinder; +use WPDesk\Init\Binding\Hookable; use WPDesk\Init\Plugin\Plugin; -class I18n implements HookBinder { +class I18n implements Hookable { /** @var Plugin */ private $plugin; @@ -14,7 +14,7 @@ class I18n implements HookBinder { $this->plugin = $plugin; } - public function bind(): void { + public function hooks(): void { if ( did_action( 'plugins_loaded' ) ) { $this->load_textdomain(); } else { diff --git a/src/CommonBinding/RequirementsCheck.php b/src/CommonBinding/RequirementsCheck.php index a081459307716f2facb415a650200f5d81627a6f..d50d77b02c92a15ca91c4c984265be008bfd3b08 100644 --- a/src/CommonBinding/RequirementsCheck.php +++ b/src/CommonBinding/RequirementsCheck.php @@ -20,7 +20,7 @@ class RequirementsCheck implements StoppableBinder { ); } - public function bind(): void { + public function hooks(): void { if ( $this->should_stop() ) { $this->checker->render_notices(); } diff --git a/src/Kernel.php b/src/Kernel.php index ac2495cfbdb9f01d25380a49e13fe9f3bc6dab56..dd6097d7b2cd83a9ecc4ef5bf86f04d5f72ddd08 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -8,13 +8,9 @@ use DI\ContainerBuilder as DiBuilder; use Psr\Container\ContainerInterface; use WPDesk\Init\Binding\Binder\CallableBinder; use WPDesk\Init\Binding\Binder\CompositeBinder; -use WPDesk\Init\Binding\Binder\HookBinderBinder; use WPDesk\Init\Binding\Binder\HookableBinder; use WPDesk\Init\Binding\Binder\StoppableBinder; use WPDesk\Init\Binding\Loader\CompositeBindingLoader; -use WPDesk\Init\Binding\DefinitionFactory; -use WPDesk\Init\Binding\Loader\ConfigurationBindingLoader; -use WPDesk\Init\Binding\Loader\DirectoryBasedLoader; use WPDesk\Init\Configuration\Configuration; use WPDesk\Init\DependencyInjection\ContainerBuilder; use WPDesk\Init\Extension\ExtensionsSet; @@ -111,7 +107,7 @@ final class Kernel { private function prepare_driver( ContainerInterface $container ): HookDriver { $loader = new CompositeBindingLoader(); - foreach ( $this->extensions->bindings($container) as $bindings ) { + foreach ( $this->extensions->bindings( $container ) as $bindings ) { $loader->add( $bindings ); } @@ -120,7 +116,6 @@ final class Kernel { new StoppableBinder( new CompositeBinder( new HookableBinder( $container ), - new HookBinderBinder( $container ), new CallableBinder( $container ) ), $container