Ferreteria/v0.6/clade/Sys/Events/InputRq/@code
Jump to navigation
Jump to search
|
Code Snapshots & Removals
|
- Official: v0.6-dev
- removed
- 2025/11/19
- 2026/04/26 removal
interface iInputRq extends BaseIface, HasStatusIface {
// CONFIG
function NameOfInput() : string;
// SETUP
function Item(ItemIface $o=NULL) : ItemIface;
// ACTION
function Go();
// INFO
function Describe() : string;
}
abstract class caInputRq extends BaseClass implements SelfIface {
use HasStatusTrait;
// ++ CONFIG ++ //
// OVERRIDE
protected function QVarClass(int|string $snKey) : string { return InDataClass::class; }
// This tells the clade where to store the Singleton object for this podling-class-family.
static protected function InputClass() : string { die(self::PromptForMethod('Define this in the root InputRq for the command.')); } // DEFAULT
public function NameOfInput() : string { return $this->Item()->SName(); }
// -- CONFIG -- //
// ++ SETUP ++ //
protected function __construct(){}
static public function FromItemPiece(ItemIface $oItem, PieceIface $oPiece) : SelfIface {
$oThis = new static;
$oThis->WithItemPiece($oItem,$oPiece);
return $oThis;
}
// ++ SETUP: dynamic ++ //
// DOCS: https://wooz.dev/Ferreteria/v0.6/fx/WithItemPiece
protected function WithItemPiece(ItemIface $oItem, PieceIface $oPiece) : void {
$this->Item($oItem);
if ($oPiece->HasValue()) {
$sVal = $oPiece->Value();
$this->ParseInputArgs($oPiece->GetExtras());
} else {
// check for default (used if request is present but with no value):
$osDef = $oItem->SDefault(); // TODO: Implement as $this->Attrs()->QryIt('valdef');
if ($osDef->HasIt()) {
$sVal = $osDef->GetIt();
} else {
$sVal = '';
}
}
$this->ParseInputString($sVal);
}
// NOTE: Basically identical to Events/Actor/Option::Item()
private $oItem = NULL;
public function Item(ItemIface $o=NULL) : ItemIface {
if (is_object($o)) {
self::HardAssert(is_null($this->oItem),'changing the item-object on an already-configured Action (should probably never happen)');
// If we ever *actually* need to do this, we need to un-register and re-register.
$this->oItem = $o;
} else {
$o = $this->oItem; // return previously-set object
}
return $o;
}
// -- SETUP -- //
// ++ DATA ++ //
static private $oaInThis = NULL;
protected function OAUserInput() : InDataIface { return self::$oaInThis ?? (self::$oaInThis = $this->NewUserInput()); }
protected function NewUserInput() : InDataIface {
$oa = (static::InputClass())::AsNew();
return $oa;
}
abstract protected function ParseInputString(string $s) : void;
abstract protected function ParseInputArgs(array $ar);
// -- DATA -- //
}