Ferreteria/v0.6/clade/Aux/StandardBase/Objectory
< Ferreteria | v0.6 | clade | Aux/StandardBase
Jump to navigation
Jump to search
| Clade Family | ||
|---|---|---|
| StandardBase | → Objectorium | |
Code
as of 2025-09-26
interface iObjectorium extends BaseIface {
// SETUP
static function FromSlug(string $sSlug) : self;
function ObjectSlug() : string;
}
class cObjectorium extends BaseClass implements iObjectorium {
// ++ CONFIG ++ //
static protected function ClassSlug() : string { echo self::PromptForMethod('Must define ClassSlug() for this class family.').CRLF; die(); }
static protected function RegisterClass() : string { return RegClass::class; }
static protected function ManifestClass() : string { return MfsClass::class; }
// -- CONFIG -- //
// ++ SETUP ++ //
private $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 ++ //
protected function WithSlug(string $sSlug) {
$this->sSlug = $sSlug;
$this->SelfRegister();
}
// -- 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 ++ //
static private array $arObjRegs = [];
static protected function Register() : RegIface {
$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() {
$sSlug = $this->ObjectSlug();
static::Register()->SetIt($sSlug,$this);
}
// -- REGISTRY -- //
}