adrema/modules/Dashboard/DashboardFactory.php

49 lines
946 B
PHP
Raw Normal View History

2022-11-17 02:15:29 +01:00
<?php
2024-09-23 01:20:04 +02:00
namespace Modules\Dashboard;
2022-11-17 02:15:29 +01:00
use App\Efz\EfzPendingBlock;
2023-12-17 01:49:12 +01:00
use App\Invoice\MemberPaymentBlock;
2022-11-17 20:43:51 +01:00
use App\Member\PsPendingBlock;
2022-11-17 02:15:29 +01:00
use App\Membership\AgeGroupCountBlock;
use App\Membership\TestersBlock;
class DashboardFactory
{
/**
* @var array<int, class-string<Block>>
*/
private array $blocks = [
AgeGroupCountBlock::class,
MemberPaymentBlock::class,
TestersBlock::class,
EfzPendingBlock::class,
2022-11-17 20:43:51 +01:00
PsPendingBlock::class,
2022-11-17 02:15:29 +01:00
];
/**
2024-09-23 01:20:04 +02:00
* @return array<int, Block>
2022-11-17 02:15:29 +01:00
*/
2024-09-23 01:20:04 +02:00
public function load(): array
2022-11-17 02:15:29 +01:00
{
2024-09-23 01:20:04 +02:00
return collect($this->blocks)->map(fn ($block) => app($block))->toArray();
2022-11-17 02:15:29 +01:00
}
/**
* @param class-string<Block> $block
*/
public function register(string $block): self
{
$this->blocks[] = $block;
return $this;
}
public function purge(): self
{
$this->blocks = [];
return $this;
}
}