diff --git a/lib/GaletteHelloasso/PluginGaletteHelloasso.php b/lib/GaletteHelloasso/PluginGaletteHelloasso.php index 12872b0..fcbd872 100644 --- a/lib/GaletteHelloasso/PluginGaletteHelloasso.php +++ b/lib/GaletteHelloasso/PluginGaletteHelloasso.php @@ -23,9 +23,12 @@ 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; /** @@ -35,14 +38,17 @@ * @author Guillaume AGNIERAY */ -class PluginGaletteHelloasso extends GalettePlugin +class PluginGaletteHelloasso extends GalettePlugin implements MenuProviderInterface, DashboardProviderInterface { + #[Inject] + private readonly Db $zdb; //@phpstan-ignore-line injected from DI + /** - * Extra menus entries + * Get plugins menus * * @return array> */ - public static function getMenusContents(): array + public function getMenus(): array { /** * @var Login $login @@ -76,11 +82,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 +100,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 +125,30 @@ 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> - */ - public static function getListActionsContents(Adherent $member): array - { - 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> + * Is the plugin fully installed (including database, extra configuration, etc.)? */ - public static function getBatchActionsContents(): array + public function isInstalled(): bool { - return []; + 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; } }