Skip to content

RootBuild

Refaltor77 edited this page Mar 29, 2026 · 1 revision

RootBuild

Interface that all screen definitions must implement.

Interface

interface RootBuild
{
    public function root(): Root;
    public function getNamespace(): string;
    public function getPathName(): string;
    public function titleCondition(): string;
}

Methods

Method Returns Description
root() Root Build and return the screen's Root
getNamespace() string Unique namespace (used as filename)
getPathName() string Output directory path
titleCondition() string Title text that triggers visibility

Template

<?php
namespace refaltor\roots;

use refaltor\ui\builders\Root;
use refaltor\ui\builders\RootBuild;

class MyScreen implements RootBuild
{
    public function root(): Root
    {
        $root = Root::create();
        // Build your UI here...
        return $root;
    }

    public function getNamespace(): string
    {
        return "my_screen"; // -> custom_ui/my_screen.json
    }

    public function getPathName(): string
    {
        return "./resources/pack_example/";
    }

    public function titleCondition(): string
    {
        return "MY_SCREEN_TITLE"; // Visible when #title_text matches
    }
}

Registration

Add to Entry.php:

public function startingService(): void {
    $this->register(new MyScreen());
}

Generated Files

For each registered RootBuild, RegisterHelper generates:

  1. ui/_ui_defs.json — Adds ui/custom_ui/my_screen.json to the registry
  2. ui/server_form.json — Adds title condition bindings
  3. ui/custom_ui/my_screen.json — The complete screen definition

See Also

  • Root — The builder returned by root()
  • Home — Getting started guide

Clone this wiki locally