Skip to content

Commit c905b0d

Browse files
committed
Implement plugins interfaces
1 parent 1bfc19b commit c905b0d

File tree

1 file changed

+22
-64
lines changed

1 file changed

+22
-64
lines changed

lib/GaletteLegalNotices/PluginGaletteLegalnotices.php

Lines changed: 22 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323

2424
namespace GaletteLegalNotices;
2525

26+
use DI\Attribute\Inject;
2627
use Galette\Core\Db;
2728
use Galette\Core\Login;
29+
use Galette\Core\Plugins\DashboardProviderInterface;
30+
use Galette\Core\Plugins\MenuProviderInterface;
2831
use Galette\Entity\Adherent;
2932
use Galette\Core\GalettePlugin;
33+
use GaletteLegalNotices\Entity\Pages;
3034
use GaletteLegalNotices\Entity\Settings;
3135

3236
/**
@@ -36,19 +40,20 @@
3640
* @author Guillaume AGNIERAY <dev@agnieray.net>
3741
*/
3842

39-
class PluginGaletteLegalnotices extends GalettePlugin
43+
class PluginGaletteLegalnotices extends GalettePlugin implements MenuProviderInterface
4044
{
45+
#[Inject]
46+
private readonly Db $zdb;
47+
4148
/**
42-
* Extra menus entries
49+
* Get plugins menus
4350
*
4451
* @return array<string, string|array<string,mixed>>
4552
*/
46-
public static function getMenusContents(): array
53+
public function getMenus(): array
4754
{
4855
/** @var Login $login */
4956
global $login;
50-
/** @var Db $zdb */
51-
global $zdb;
5257
$menus = [];
5358
$items = [];
5459

@@ -82,15 +87,13 @@ public static function getMenusContents(): array
8287
}
8388

8489
/**
85-
* Extra public menus entries
90+
* Get plugins public menus
8691
*
8792
* @return array<int, string|array<string,mixed>>
8893
*/
89-
public static function getPublicMenusItemsList(): array
94+
public function getPublicMenus(): array
9095
{
91-
/** @var Db $zdb */
92-
global $zdb;
93-
$settings = new Settings($zdb);
96+
$settings = new Settings($this->zdb);
9497
$items = [];
9598
$children = [];
9699

@@ -141,60 +144,6 @@ public static function getPublicMenusItemsList(): array
141144
return $items;
142145
}
143146

144-
/**
145-
* Get dashboards contents
146-
*
147-
* @return array<int, string|array<string,mixed>>
148-
*/
149-
public static function getDashboardsContents(): array
150-
{
151-
return [];
152-
}
153-
154-
/**
155-
* Get current logged-in user dashboards contents
156-
*
157-
* @return array<int, string|array<string,mixed>>
158-
*/
159-
public static function getMyDashboardsContents(): array
160-
{
161-
return [];
162-
}
163-
164-
/**
165-
* Get actions contents
166-
*
167-
* @param Adherent $member Member instance
168-
*
169-
* @return array<int, string|array<string,mixed>>
170-
*/
171-
public static function getListActionsContents(Adherent $member): array
172-
{
173-
return [];
174-
}
175-
176-
/**
177-
* Get detailed actions contents
178-
*
179-
* @param Adherent $member Member instance
180-
*
181-
* @return array<int, string|array<string,mixed>>
182-
*/
183-
public static function getDetailedActionsContents(Adherent $member): array
184-
{
185-
return static::getListActionsContents($member);
186-
}
187-
188-
/**
189-
* Get batch actions contents
190-
*
191-
* @return array<int, string|array<string,mixed>>
192-
*/
193-
public static function getBatchActionsContents(): array
194-
{
195-
return [];
196-
}
197-
198147
/**
199148
* Get plugin settings
200149
*
@@ -207,4 +156,13 @@ public static function getPluginSettings(): array
207156
$settings = new Settings($zdb);
208157
return $settings->getSettings();
209158
}
159+
160+
/**
161+
* Is the plugin fully installed (including database, extra configuration, etc.)?
162+
*/
163+
public function isInstalled(): bool
164+
{
165+
return $this->zdb->tableExists(LEGALNOTICES_PREFIX . Pages::TABLE)
166+
&& $this->zdb->tableExists(LEGALNOTICES_PREFIX . Settings::TABLE);
167+
}
210168
}

0 commit comments

Comments
 (0)