Ferreteria/v0.6/clade/Sys/Events/InputRq: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Events
Jump to navigation Jump to search
(Nope -- "Objectory" is not (no longer?) being used here.)
No edit summary
Line 18: Line 18:


}}
}}
 
'''in repo''': [https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/src/Sys/Events/InputRq.md doc][https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/src/Sys/Events/InputRq.php code]
==Functions==
==Functions==
This requires the following to be defined by podlings:
This requires the following to be defined by podlings:
Line 47: Line 47:


     // OVERRIDE
     // OVERRIDE
     protected function QVarClass(int|string $snKey) : string { return InDataClass::class; }
     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.
     // 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
     static protected function InputClass() : string { die(self::PromptForMethod('Define this in the root InputRq for the command.')); } // DEFAULT

Revision as of 15:48, 17 October 2025

clade: Sys\Events\InputRq
Clade Family
ItWent[i,t] InputRq Setting
Clade Aliases
Alias Clade
Base* [c,i] Aux\StandardBase
HasStatus* [i,t] Sys\Events\has\ItWent
InRqData* [c,i] Sys\Events\InputRq\aux\InRqData
Item* [i] Sys\Events\InputItem
Piece* [i] Sys\Data\Things\Array\aux\Piece
Subpages

in repo: doccode

Functions

This requires the following to be defined by podlings:

  • Describe() - usually defined at the application-input level (e.g. DoExportDb)
  • ParseInputArgs()
    • typically defined at the application level (e.g. InReq)
    • also defined by Setting for inputs that map directly to value-names
  • ParseInputString()
    • typically defined at the application level (e.g. InReq)
    • also defined by Setting for inputs that map directly to value-names

Code

as of 2025-10-16

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 ++ //

    protected function WithItemValue(ItemIface $oItem, string $sValue) : void {
        $this->Item($oItem);
        $this->ParseInputString($sValue);
    }
    protected function WithItemPiece(ItemIface $oItem, PieceIface $oPiece) : void {
        if ($oPiece->HasValue()) {
            $sVal = $oPiece->Value();
            #self::GotToHere();
            $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->WithItemValue($oItem,$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 -- //
}