Ferreteria/v0.6/clade/Aux/StandardBase/Objectory: Difference between revisions

From Woozle Writes Code
Jump to navigation Jump to search
(updates)
Line 4: Line 4:
|-
|-
| align=right | {{l/ver/clade|Aux|StandardBase}}
| align=right | {{l/ver/clade|Aux|StandardBase}}
| → {{l/ver/clade|Aux\StandardBase|Objectorium}}
| → {{l/ver/clade|Aux\StandardBase|Objectory}}
|
|
&rarr; {{l/ver/clade|Sys\Events|InputRq}}<br>
&rarr; {{l/ver/clade|Sys\Events|InputRq}}<br>
Line 10: Line 10:
|}
|}
==Code==
==Code==
''as of 2025-09-26''
''as of 2025-09-29''
{{fmt/php/block|1=
{{fmt/php/block|1=
interface iObjectorium extends BaseIface {
interface iObjectory extends BaseIface {
     // SETUP
     // SETUP
     static function FromSlug(string $sSlug) : self;
     static function FromSlug(string $sSlug) : self; // create a new object with a name-slug
          function ObjectSlug() : string;
    // SETTING
    function ObjectSlug() : string;
}
}
class cObjectorium extends BaseClass implements iObjectorium {
class cObjectory extends BaseClass implements iObjectory {


     // ++ CONFIG ++ //
     static protected function RegisterClass() : string { return RegClass::class; }
    #static protected function ManifestClass() : string { return MfsClass::class; }


     static protected function ClassSlug() : string { echo self::PromptForMethod('Must define ClassSlug() for this class family.').CRLF; die(); }
     static protected function ClassSlug() : string { echo self::PromptForMethod('Must define ClassSlug() for this clade.').CRLF; die(); }
    static protected function RegisterClass() : string { return RegClass::class; }
    static protected function ManifestClass() : string { return MfsClass::class; }


     // -- CONFIG -- //
     // -- CONFIG -- //
     // ++ SETUP ++ //
     // ++ SETUP ++ //
    protected function __construct(){}
    static public function FromSlug(string $sSlug) : iObjectory { ($oThis = new static)->WithSlug($sSlug); return $oThis; }


     private $sSlug;
     private $sSlug;
 
     public function ObjectSlug() : string { return $this->sSlug; }
          protected function __construct(){}
     static public   function FromSlug(string $sSlug) : iObjectorium { ($oThis = new static)->WithSlug($sSlug); return $oThis; }
          public    function ObjectSlug() : string { return $this->sSlug; }


     // ++ SETUP: dynamic ++ //
     // ++ SETUP: dynamic ++ //


    // Remember the slug, and self-register with it.
     protected function WithSlug(string $sSlug) {
     protected function WithSlug(string $sSlug) {
         $this->sSlug = $sSlug;
         $this->sSlug = $sSlug;
         $this->SelfRegister();
         $this->SignThisUp();
     }
     }


     // -- SETUP -- //
     // -- SETUP -- //
    // ++ MANIFEST ++ //
    static private array $arObjMfss = [];
    static protected function Manifest() : MfsIface {
        $sCSlug = static::ClassSlug();
        if (array_key_exists($sCSlug,self::$arObjMfss)) {
            $o = self::$arObjMfss[$sCSlug];
        } else {
            $cs = static::ManifestClass();
            $o = $cs::AsNew();
            self::$arObjMfss[$sCSlug] = $o;
        }
        return $o;
    }
    // -- MANIFEST -- //
     // ++ REGISTRY ++ //
     // ++ REGISTRY ++ //


     static private array $arObjRegs = [];
     static private array $arObjRegs = [];
     static protected function Register() : RegIface {
     static protected function Register() : RegIface { die('Use SignUpList()');
    static protected function Classifest() : ArrayIface { // clade-specific manifest (sub-array)
         $sCSlug = static::ClassSlug();
         $sCSlug = static::ClassSlug();
         if (array_key_exists($sCSlug,self::$arObjRegs)) {
         if (array_key_exists($sCSlug,self::$arObjRegs)) {
Line 73: Line 59:
     }
     }


     protected function SelfRegister() {
     protected function SelfRegister() { die('Use SignThisUp()'); }
    protected function SignThisUp() {
         $sSlug = $this->ObjectSlug();
         $sSlug = $this->ObjectSlug();
         static::Register()->SetIt($sSlug,$this);
         static::Classifest()->SetIt($sSlug,$this);
     }
     }



Revision as of 15:10, 29 September 2025

clade: Aux\StandardBase\Objectory
Clade Family
StandardBase Objectory

InputRq
Player

Code

as of 2025-09-29

interface iObjectory extends BaseIface {
    // SETUP
    static function FromSlug(string $sSlug) : self; // create a new object with a name-slug
    // SETTING
    function ObjectSlug() : string;
}
class cObjectory extends BaseClass implements iObjectory {

    static protected function RegisterClass() : string { return RegClass::class; }
    #static protected function ManifestClass() : string { return MfsClass::class; }

    static protected function ClassSlug() : string { echo self::PromptForMethod('Must define ClassSlug() for this clade.').CRLF; die(); }

    // -- CONFIG -- //
    // ++ SETUP ++ //

    protected function __construct(){}
    static public function FromSlug(string $sSlug) : iObjectory { ($oThis = new static)->WithSlug($sSlug); return $oThis; }

    private $sSlug;
    public function ObjectSlug() : string { return $this->sSlug; }

    // ++ SETUP: dynamic ++ //

    // Remember the slug, and self-register with it.
    protected function WithSlug(string $sSlug) {
        $this->sSlug = $sSlug;
        $this->SignThisUp();
    }

    // -- SETUP -- //
    // ++ REGISTRY ++ //

    static private array $arObjRegs = [];
    static protected function Register() : RegIface { die('Use SignUpList()');
    static protected function Classifest() : ArrayIface { // clade-specific manifest (sub-array)
        $sCSlug = static::ClassSlug();
        if (array_key_exists($sCSlug,self::$arObjRegs)) {
            $oReg = self::$arObjRegs[$sCSlug];
        } else {
            $csReg = static::RegisterClass();
            $oReg = $csReg::AsNew();
            self::$arObjRegs[$sCSlug] = $oReg;
        }
        return $oReg;
    }

    protected function SelfRegister() { die('Use SignThisUp()'); }
    protected function SignThisUp() {
        $sSlug = $this->ObjectSlug();
        static::Classifest()->SetIt($sSlug,$this);
    }

    // -- REGISTRY -- //
}