From b77de5195f1b3f86020311da6aebfa63cc920ffe Mon Sep 17 00:00:00 2001
From: Bart Jaskulski <bjaskulski@protonmail.com>
Date: Fri, 17 Nov 2023 15:20:01 +0100
Subject: [PATCH] feat: add check for optional package

Signed-off-by: Bart Jaskulski <bjaskulski@protonmail.com>
---
 src/HookDriver/LegacyHookableDriver.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/HookDriver/LegacyHookableDriver.php b/src/HookDriver/LegacyHookableDriver.php
index 20df1d0..d9481c9 100644
--- a/src/HookDriver/LegacyHookableDriver.php
+++ b/src/HookDriver/LegacyHookableDriver.php
@@ -10,6 +10,12 @@ use WPDesk\Init\Plugin;
 
 class LegacyHookableDriver implements HookDriver {
 
+	public function __construct() {
+		if (!class_exists(\WPDesk_Plugin_Info::class)) {
+			throw new \LogicException('Legacy driver cannot be used as the plugin builder component is unavailable. Try running "composer require wpdesk/wp-builder".');
+		}
+	}
+
 	public function register_hooks( ReadableConfig $config, array $bundles, ContainerInterface $container ): void {
 		$info = $this->as_plugin_info($container->get(Plugin::class), $config);
 
-- 
GitLab