Ferreteria/v0.6/clade/Config/Roster/for/AClass

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Config
Revision as of 18:20, 28 September 2025 by Woozle (talk | contribs) (Created page with "{{page/clade}} {| style="border: solid 1px black; float: right;" ! colspan=3 | Clade Family |- | align=right | ''(root)'' | → {{l/ver/clade|Config\Roster\for|AClass}} [i,t] | → {{l/ver/clade|Sys\Data\Engine|Ops}} |} ==About== Trait/interface to get a class included in the Class Registry. (Need to explain how this works...) See also: {{l/ver/clade|Config\Roster\for|AnObject}} - for getting an ''object'' included in the ''Object'' Registry. ==Code== ''as of 2025...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
clade: Config\Roster\for\AClass
Clade Family
(root) AClass [i,t]

Ops

About

Trait/interface to get a class included in the Class Registry. (Need to explain how this works...)

See also: AnObject - for getting an object included in the Object Registry.

Code

as of 2025-09-28

interface iAClass {
    // CONFIG
    static function ClassSlug() : string; // 2025-06-08 not sure this needs to be public
    // SETUP
    static function RegisterSelf() : void;
    static function FromClassSlug(string $sSlug) : QStrIface;
    static function AccessSelf() : self;
}
trait tAClass { // IMPLEMENTS iAClass
    // ++ SETUP ++ //

    public static function RegisterSelf() : void {
        static::ClassRoster()->SetIt(static::ClassSlug(),get_called_class());
    }
    public static function FromClassSlug(string $sSlug) : QStrIface {
        return static::ClassRoster()->QryIt($sSlug);
    }
    public static function AccessSelf() : iAClass {
        $sc = static::ClassRoster()->GetIt(static::ClassSlug());
        $oThis = new ($sc);
        return $oThis;
    }

    // -- SETUP -- //
    // ++ OBJECT ++ //

    static private $oaClsRost=NULL;
    static public function ClassRoster() : RostIface { return self::$oaClsRost ?? (self::$oaClsRost = RostClass::AsNew()); }

    // -- OBJECT -- //
}