From 57cff2ed21e74b7c7ca076b5945cec55aeac32a2 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Mon, 9 Mar 2026 15:14:43 +0100 Subject: [PATCH] Use new Galette interfaces --- lib/GalettePaypal/PluginGalettePaypal.php | 48 ++++++++++++----------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/lib/GalettePaypal/PluginGalettePaypal.php b/lib/GalettePaypal/PluginGalettePaypal.php index 995080e..588affb 100644 --- a/lib/GalettePaypal/PluginGalettePaypal.php +++ b/lib/GalettePaypal/PluginGalettePaypal.php @@ -23,7 +23,11 @@ namespace GalettePaypal; +use DI\Attribute\Inject; +use Galette\Core\Db; use Galette\Core\Login; +use Galette\Core\Plugins\DashboardProviderInterface; +use Galette\Core\Plugins\MenuProviderInterface; use Galette\Core\Preferences; use Galette\Entity\Adherent; use Galette\Core\GalettePlugin; @@ -34,14 +38,17 @@ * @author Johan Cwiklinski */ -class PluginGalettePaypal extends GalettePlugin +class PluginGalettePaypal extends GalettePlugin implements MenuProviderInterface, DashboardProviderInterface { + #[Inject] + private readonly Db $zdb; //@phpstan-ignore-line injected from DI + /** * Extra menus entries * * @return array> */ - public static function getMenusContents(): array + public function getMenus(): array { /** @var Login $login */ global $login; @@ -76,7 +83,7 @@ public static function getMenusContents(): array * * @return array> */ - public static function getPublicMenusItemsList(): array + public function getPublicMenus(): array { return [ [ @@ -94,7 +101,7 @@ public static function getPublicMenusItemsList(): array * * @return array> */ - public static function getDashboardsContents(): array + public function getDashboards(): array { /** @var Login $login */ global $login; @@ -127,34 +134,29 @@ public static function getListActionsContents(Adherent $member): array } /** - * Get detailed actions contents - * - * @param Adherent $member Member instance - * - * @return array> - */ - public static function getDetailedActionsContents(Adherent $member): array - { - return static::getListActionsContents($member); - } - - /** - * Get batch actions contents + * Get current logged-in user dashboards contents * * @return array> */ - public static function getBatchActionsContents(): array + public function getMyDashboards(): array { return []; } /** - * Get current logged-in user dashboards contents - * - * @return array> + * Is the plugin fully installed (including database, extra configuration, etc.)? */ - public static function getMyDashboardsContents(): array + public function isInstalled(): bool { - return []; + try { + $this->zdb->execute($this->zdb->select(PAYPAL_PREFIX . Paypal::TABLE)->limit(1)); + $this->zdb->execute($this->zdb->select(PAYPAL_PREFIX . PaypalHistory::TABLE)->limit(1)); + return true; + } catch (\Throwable $e) { + if (!$this->zdb->isMissingTableException($e)) { + throw $e; + } + } + return false; } }