This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/user/events.php
2024-01-20 19:47:27 +00:00

85 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace Shimmie2;
use MicroHTML\HTMLElement;
class UserBlockBuildingEvent extends Event
{
/** @var array<int, array{name: string|HTMLElement, link: string}> */
public array $parts = [];
public function add_link(string|HTMLElement $name, string $link, int $position = 50): void
{
while (isset($this->parts[$position])) {
$position++;
}
$this->parts[$position] = ["name" => $name, "link" => $link];
}
}
class UserOperationsBuildingEvent extends Event
{
/** @var string[] */
public array $parts = [];
public function __construct(public User $user, public BaseConfig $user_config)
{
parent::__construct();
}
public function add_html(string $html): void
{
$this->parts[] = $html;
}
}
class UserPageBuildingEvent extends Event
{
/** @var array<int, string> */
public array $stats = [];
public function __construct(public User $display_user)
{
parent::__construct();
}
public function add_stats(string $html, int $position = 50): void
{
while (isset($this->stats[$position])) {
$position++;
}
$this->stats[$position] = $html;
}
}
class UserCreationEvent extends Event
{
public function __construct(
public string $username,
public string $password,
public string $password2,
public string $email,
public bool $login
) {
parent::__construct();
}
}
class UserLoginEvent extends Event
{
public function __construct(public User $user)
{
parent::__construct();
}
}
class UserDeletionEvent extends Event
{
public function __construct(public int $id)
{
parent::__construct();
}
}