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
48 changes: 25 additions & 23 deletions lib/GalettePaypal/PluginGalettePaypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,14 +38,17 @@
* @author Johan Cwiklinski <johan@x-tnd.be>
*/

class PluginGalettePaypal extends GalettePlugin
class PluginGalettePaypal extends GalettePlugin implements MenuProviderInterface, DashboardProviderInterface
{
#[Inject]
private readonly Db $zdb; //@phpstan-ignore-line injected from DI

Comment thread
trasher marked this conversation as resolved.
/**
* Extra menus entries
*
* @return array<string, string|array<string,mixed>>
*/
public static function getMenusContents(): array
public function getMenus(): array
{
/** @var Login $login */
global $login;
Expand Down Expand Up @@ -76,7 +83,7 @@ public static function getMenusContents(): array
*
* @return array<int, string|array<string,mixed>>
*/
public static function getPublicMenusItemsList(): array
public function getPublicMenus(): array
{
return [
[
Expand All @@ -94,7 +101,7 @@ public static function getPublicMenusItemsList(): array
*
* @return array<int, string|array<string,mixed>>
*/
public static function getDashboardsContents(): array
public function getDashboards(): array
{
/** @var Login $login */
global $login;
Expand Down Expand Up @@ -127,34 +134,29 @@ public static function getListActionsContents(Adherent $member): array
}

/**
* 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
* Get current logged-in user dashboards contents
*
* @return array<int, string|array<string,mixed>>
*/
public static function getBatchActionsContents(): array
public function getMyDashboards(): array
{
return [];
}

/**
* Get current logged-in user dashboards contents
*
* @return array<int, string|array<string,mixed>>
* 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));
Comment thread
trasher marked this conversation as resolved.
$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;
}
}