From f5cde52926d38fc09f17ba23c10c565e66e33f34 Mon Sep 17 00:00:00 2001 From: Guillaume AGNIERAY Date: Thu, 26 Feb 2026 12:24:57 +0100 Subject: [PATCH 1/4] Implement plugins interfaces --- .../PluginGaletteHelloasso.php | 61 +++++++------------ 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/lib/GaletteHelloasso/PluginGaletteHelloasso.php b/lib/GaletteHelloasso/PluginGaletteHelloasso.php index 12872b0..ed2340f 100644 --- a/lib/GaletteHelloasso/PluginGaletteHelloasso.php +++ b/lib/GaletteHelloasso/PluginGaletteHelloasso.php @@ -23,10 +23,16 @@ namespace GaletteHelloasso; +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; +use GaletteHelloasso\Helloasso; +use GaletteHelloasso\HelloassoHistory; /** * Galette HelloAsso plugin @@ -35,14 +41,17 @@ * @author Guillaume AGNIERAY */ -class PluginGaletteHelloasso extends GalettePlugin +class PluginGaletteHelloasso extends GalettePlugin implements MenuProviderInterface, DashboardProviderInterface { + #[Inject] + private readonly Db $zdb; + /** - * Extra menus entries + * Get plugins menus * * @return array> */ - public static function getMenusContents(): array + public function getMenus(): array { /** * @var Login $login @@ -76,11 +85,11 @@ public static function getMenusContents(): array } /** - * Extra public menus entries + * Get plugins public menus * * @return array> */ - public static function getPublicMenusItemsList(): array + public function getPublicMenus(): array { return [ [ @@ -94,11 +103,11 @@ public static function getPublicMenusItemsList(): array } /** - * Get dashboards contents + * Get plugins dashboards * * @return array> */ - public static function getDashboardsContents(): array + public function getDashboards(): array { /** @var Login $login */ global $login; @@ -119,46 +128,22 @@ public static function getDashboardsContents(): array } /** - * Get current logged-in user dashboards contents + * Get current logged-in user plugins dashboards * * @return array> */ - public static function getMyDashboardsContents(): array + public function getMyDashboards(): array { return []; } /** - * Get actions contents - * - * @param Adherent $member Member instance - * - * @return array> + * Is the plugin fully installed (including database, extra configuration, etc.)? */ - public static function getListActionsContents(Adherent $member): array + public function isInstalled(): bool { - return []; - } - - /** - * 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 - * - * @return array> - */ - public static function getBatchActionsContents(): array - { - return []; + return $this->zdb->tableExists(HELLOASSO_PREFIX . Helloasso::TABLE) + && $this->zdb->tableExists(HELLOASSO_PREFIX . Helloasso::TABLE_TOKENS) + && $this->zdb->tableExists(HELLOASSO_PREFIX . HelloassoHistory::TABLE); } } From 80544b68d46db689d60dcc927966a0544fe287a7 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Wed, 4 Mar 2026 17:33:39 +0100 Subject: [PATCH 2/4] New way to go :) --- lib/GaletteHelloasso/PluginGaletteHelloasso.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/GaletteHelloasso/PluginGaletteHelloasso.php b/lib/GaletteHelloasso/PluginGaletteHelloasso.php index ed2340f..13c710f 100644 --- a/lib/GaletteHelloasso/PluginGaletteHelloasso.php +++ b/lib/GaletteHelloasso/PluginGaletteHelloasso.php @@ -142,8 +142,17 @@ public function getMyDashboards(): array */ public function isInstalled(): bool { - return $this->zdb->tableExists(HELLOASSO_PREFIX . Helloasso::TABLE) - && $this->zdb->tableExists(HELLOASSO_PREFIX . Helloasso::TABLE_TOKENS) - && $this->zdb->tableExists(HELLOASSO_PREFIX . HelloassoHistory::TABLE); + try { + $this->zdb->execute($this->zdb->select(HELLOASSO_PREFIX . Helloasso::TABLE)->limit(1)); + $this->zdb->execute($this->zdb->select(HELLOASSO_PREFIX . Helloasso::TABLE_TOKENS)->limit(1)); + $this->zdb->execute($this->zdb->select(HELLOASSO_PREFIX . HelloassoHistory::TABLE)->limit(1)); + return true; + } + catch (\Throwable $e) { + if (!$this->zdb->isMissingTableException($e)) { + throw $e; + } + } + return false; } } From 92604e3ab5022b5aaad012520a069cd3742adacc Mon Sep 17 00:00:00 2001 From: Guillaume AGNIERAY Date: Wed, 11 Mar 2026 09:12:44 +0100 Subject: [PATCH 3/4] Fix CS --- lib/GaletteHelloasso/PluginGaletteHelloasso.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/GaletteHelloasso/PluginGaletteHelloasso.php b/lib/GaletteHelloasso/PluginGaletteHelloasso.php index 13c710f..739879f 100644 --- a/lib/GaletteHelloasso/PluginGaletteHelloasso.php +++ b/lib/GaletteHelloasso/PluginGaletteHelloasso.php @@ -147,8 +147,7 @@ public function isInstalled(): bool $this->zdb->execute($this->zdb->select(HELLOASSO_PREFIX . Helloasso::TABLE_TOKENS)->limit(1)); $this->zdb->execute($this->zdb->select(HELLOASSO_PREFIX . HelloassoHistory::TABLE)->limit(1)); return true; - } - catch (\Throwable $e) { + } catch (\Throwable $e) { if (!$this->zdb->isMissingTableException($e)) { throw $e; } From 5cf54d950b001d0300212a161328c9359a9342e9 Mon Sep 17 00:00:00 2001 From: Guillaume AGNIERAY Date: Wed, 11 Mar 2026 10:12:14 +0100 Subject: [PATCH 4/4] Fix CS --- lib/GaletteHelloasso/PluginGaletteHelloasso.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/GaletteHelloasso/PluginGaletteHelloasso.php b/lib/GaletteHelloasso/PluginGaletteHelloasso.php index 739879f..fcbd872 100644 --- a/lib/GaletteHelloasso/PluginGaletteHelloasso.php +++ b/lib/GaletteHelloasso/PluginGaletteHelloasso.php @@ -29,10 +29,7 @@ use Galette\Core\Plugins\DashboardProviderInterface; use Galette\Core\Plugins\MenuProviderInterface; use Galette\Core\Preferences; -use Galette\Entity\Adherent; use Galette\Core\GalettePlugin; -use GaletteHelloasso\Helloasso; -use GaletteHelloasso\HelloassoHistory; /** * Galette HelloAsso plugin @@ -44,7 +41,7 @@ class PluginGaletteHelloasso extends GalettePlugin implements MenuProviderInterface, DashboardProviderInterface { #[Inject] - private readonly Db $zdb; + private readonly Db $zdb; //@phpstan-ignore-line injected from DI /** * Get plugins menus