Fixed: basePath self→static binding, namespace detection, event wiring,
SQLite cache, file cache driver. All Mod Boot classes converted to
$listens pattern for lifecycle event discovery.
Working endpoints:
- /v1/explorer/info — live chain height, difficulty, aliases
- /v1/explorer/stats — formatted chain statistics
- /v1/names/directory — alias directory grouped by type
- /v1/names/available/{name} — name availability check
- /v1/names/lookup/{name} — name details
Co-Authored-By: Charon <charon@lethean.io>
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Actions;
|
|
|
|
/**
|
|
* Base Action trait for single-purpose business logic classes.
|
|
*
|
|
* Actions are small, focused classes that do one thing well.
|
|
* They extract complex logic from controllers and Livewire components.
|
|
*
|
|
* Convention:
|
|
* - One action per file
|
|
* - Named after what it does: CreatePage, PublishPost, SendInvoice
|
|
* - Single public method: handle() or __invoke()
|
|
* - Dependencies injected via constructor
|
|
* - Static run() helper for convenience
|
|
*
|
|
* Usage:
|
|
* // Via dependency injection
|
|
* public function __construct(private CreatePage $createPage) {}
|
|
* $page = $this->createPage->handle($user, $data);
|
|
*
|
|
* // Via static helper
|
|
* $page = CreatePage::run($user, $data);
|
|
*
|
|
* // Via app container
|
|
* $page = app(CreatePage::class)->handle($user, $data);
|
|
*
|
|
* Directory structure:
|
|
* app/Mod/{Module}/Actions/
|
|
* ├── CreateThing.php
|
|
* ├── UpdateThing.php
|
|
* ├── DeleteThing.php
|
|
* └── Thing/
|
|
* ├── PublishThing.php
|
|
* └── ArchiveThing.php
|
|
*/
|
|
trait Action
|
|
{
|
|
/**
|
|
* Run the action via the container.
|
|
*
|
|
* Resolves the action from the container (with dependencies)
|
|
* and calls handle() with the provided arguments.
|
|
*/
|
|
public static function run(mixed ...$args): mixed
|
|
{
|
|
return app(static::class)->handle(...$args);
|
|
}
|
|
}
|