Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 29 additions & 39 deletions lib/GaletteHelloasso/PluginGaletteHelloasso.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -35,14 +38,17 @@
* @author Guillaume AGNIERAY <dev@agnieray.net>
*/

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<string, string|array<string,mixed>>
*/
public static function getMenusContents(): array
public function getMenus(): array
{
/**
* @var Login $login
Expand Down Expand Up @@ -76,11 +82,11 @@ public static function getMenusContents(): array
}

/**
* Extra public menus entries
* Get plugins public menus
*
* @return array<int, string|array<string,mixed>>
*/
public static function getPublicMenusItemsList(): array
public function getPublicMenus(): array
{
return [
[
Expand All @@ -94,11 +100,11 @@ public static function getPublicMenusItemsList(): array
}

/**
* Get dashboards contents
* Get plugins dashboards
*
* @return array<int, string|array<string,mixed>>
*/
public static function getDashboardsContents(): array
public function getDashboards(): array
{
/** @var Login $login */
global $login;
Expand All @@ -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<int, string|array<string,mixed>>
*/
public static function getMyDashboardsContents(): array
public function getMyDashboards(): array
{
return [];
}

/**
* Get actions contents
*
* @param Adherent $member Member instance
*
* @return array<int, string|array<string,mixed>>
*/
public static function getListActionsContents(Adherent $member): array
{
return [];
}

/**
* Get detailed actions contents
*
* @param Adherent $member Member instance
*
* @return array<int, string|array<string,mixed>>
*/
public static function getDetailedActionsContents(Adherent $member): array
{
return static::getListActionsContents($member);
}

/**
* Get batch actions contents
*
* @return array<int, string|array<string,mixed>>
* 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;
}
}
Loading