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
No edit summary
No edit summary
Line 34: Line 34:
** ({{fmt/date|2024|12|15}}) I think the final deciding factor was that we don't have all the pieces we need when the Actor is created at parse-time -- the database object only becomes available sometime ''after'' the command is parsed. So we need an object that can remember what to do without having to do it right away.
** ({{fmt/date|2024|12|15}}) I think the final deciding factor was that we don't have all the pieces we need when the Actor is created at parse-time -- the database object only becomes available sometime ''after'' the command is parsed. So we need an object that can remember what to do without having to do it right away.
==Functions==
==Functions==
This requires the following to be defined by podlings:
{| class="wikitable sortable"
* <code>{{l/ver/fx|Describe}}()</code> - usually defined at the application-input level (e.g. <code>{{l/ver/clade|p=futilities|Sys\dba\InReq|DoExport}}</code>)
! name || type || notes
* <code>{{l/ver/fx|ParseInputArgs}}()</code>
{{!-!}} <code>{{l/ver/fx|Describe}}()</code>         || abstract public || usually defined at the application-input level (e.g. <code>{{l/ver/clade|p=futilities|Sys\dba\InReq|DoExport}}</code>)
** typically defined at the application level (e.g. <code>{{l/ver/clade|p=futilities|Sys\dba|InReq}}</code>)
{{!-!}} <code>{{l/ver/fx|ParseInputArgs}}()</code>   || abstract protected ||
** also defined by {{l/ver/clade|Sys\Events\InputRq|Setting}} for inputs that map directly to value-names
* typically defined at the application level (e.g. <code>{{l/ver/clade|p=futilities|Sys\dba|InReq}}</code>)
* <code>{{l/ver/fx|ParseInputString}}()</code>
* also defined by {{l/ver/clade|Sys\Events\InputRq|Setting}} for inputs that map directly to value-names
** typically defined at the application level (e.g. <code>{{l/ver/clade|p=futilities|Sys\dba|InReq}}</code>)
{{!-!}} <code>{{l/ver/fx|ParseInputString}}()</code> || abstract protected ||
** also defined by <code>{{l/ver/clade|Sys\Events\InputRq|Setting}}</code> for inputs that map directly to value-names
* typically defined at the application level (e.g. <code>{{l/ver/clade|p=futilities|Sys\dba|InReq}}</code>)
* <code>{{l/sub/fx|WithItemPiece}}()</code>
* also defined by <code>{{l/ver/clade|Sys\Events\InputRq|Setting}}</code> for inputs that map directly to value-names
{{!-!}} <code>{{l/sub/fx|WithItemPiece}}()</code>   || protected || calls <code>$this->{{l/ver/fx|ParseInputArgs}}()</code>, <code>$this->{{l/ver/fx|ParseInputString}}()</code>
|}
==Code==
==Code==
* '''Repository''': [https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/src/Sys/Events/InputRq.php v0.6-dev]
* '''Repository''': [https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/src/Sys/Events/InputRq.php v0.6-dev]
* '''[[/@removed/]]'''
* '''[[/@removed/]]'''
* ''as of {{fmt/date|2025|10|16}}:''
* ''as of {{fmt/date|2025|11|19}}:''
{{fmt/php/block|1=
{{fmt/php/block|1=
interface iInputRq extends BaseIface, HasStatusIface {
interface iInputRq extends BaseIface, HasStatusIface {
Line 64: Line 66:


     // 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
    #static protected function RegisterClass() : string { return static::InputClass(); } // 2025-09-14.1 This may be incompatible.
    #static protected function ManifestClass() : string { return static::InputClass(); }
     public function NameOfInput() : string { return $this->Item()->SName(); }
     public function NameOfInput() : string { return $this->Item()->SName(); }


Line 82: Line 86:
     // ++ SETUP: dynamic ++ //
     // ++ SETUP: dynamic ++ //


     protected function WithItemValue(ItemIface $oItem, string $sValue) : void {
    // DOCS: https://wooz.dev/Ferreteria/v0.6/fx/WithItemPiece
     protected function WithItemPiece(ItemIface $oItem, PieceIface $oPiece) : void {
         $this->Item($oItem);
         $this->Item($oItem);
        $this->ParseInputString($sValue);
    }
    protected function WithItemPiece(ItemIface $oItem, PieceIface $oPiece) : void {
         if ($oPiece->HasValue()) {
         if ($oPiece->HasValue()) {
             $sVal = $oPiece->Value();
             $sVal = $oPiece->Value();
            #self::GotToHere();
             $this->ParseInputArgs($oPiece->GetExtras());
             $this->ParseInputArgs($oPiece->GetExtras());
         } else {
         } else {
Line 100: Line 101:
             }
             }
         }
         }
         $this->WithItemValue($oItem,$sVal);
         $this->ParseInputString($sVal);
     }
     }


Line 108: Line 109:
         if (is_object($o)) {
         if (is_object($o)) {
             self::HardAssert(is_null($this->oItem),'changing the item-object on an already-configured Action (should probably never happen)');
             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.
             // If we ever *actually* need to do this, we need to un-register and re-register.
             $this->oItem = $o;
             $this->oItem = $o;
         } else {
         } else {

Revision as of 13:51, 19 November 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
InData* [c,i] Sys\Events\InputRq\aux\InRqData
ItemIface Sys\Events\InputItem
PieceIface Sys\Data\Things\Array\aux\Piece
SelfIface Sys\Events\InputRq
Subpages

About

  • Purpose: set of action-classes for handling user input parameters as a sequence of actions
    • These can then be described, acted on, or both.
  • Note: Not to be confused with:
    • Action: the generic action-result base clades
    • Sys\Data\reqs\Engine\CommRq - Database communication (data-xfer) requests
    • Sys\Data\reqs\Engine\AdminRq - Database administration requests

System

This is part of the system whereby CLI input is parsed into future actions (`caActor` podlings), which at go-time are converted into fully-provisioned requests (e.g. Sys\Data\reqs\Engine\AdminRq podlings).

History

  • 2024-10-27 (re?)started -- I have a distinct memory of writing somethng like this only a few weeks ago, but I cannot find it anywhere.
  • 2024-11-19 renamed/moved from Sys\Routing\ActionSys\Events\Actor.
  • 2025-01-22 I tried to both rename this clade and combine it with the AdminRq/CommRq clades, but the combining part didn't work out.
    • It still needs renaming, though -- so trying the less ambitious measure of renaming Actor -> InputRq.
  • 2025-09-27 added Config\Roster\for\AnObject as trait to provide WithSlug() function, but this is really more of a guess than a "yes, this is appropriate".

Thinking

  • 2024-10-27 Since I remember writing this but can't find it, I have to wonder if I did write it and then decide it was redundant.
    • One reason I might have decided it's redundant is: instead of creating an object for each action parsed out of the input, why not just Do The Thing? Being able to handle the action-plan in different ways, though, is much easier if you're not dealing with that fork at the same time as you're parsing them out of the input. It's easier to juggle ten plates if you do them five at a time.
    • (2024-12-15) I think the final deciding factor was that we don't have all the pieces we need when the Actor is created at parse-time -- the database object only becomes available sometime after the command is parsed. So we need an object that can remember what to do without having to do it right away.

Functions

name type notes
Describe() abstract public usually defined at the application-input level (e.g. DoExport)
ParseInputArgs() abstract protected
  • typically defined at the application level (e.g. InReq)
  • also defined by Setting for inputs that map directly to value-names
ParseInputString() abstract protected
  • typically defined at the application level (e.g. InReq)
  • also defined by Setting for inputs that map directly to value-names
WithItemPiece() protected calls $this->ParseInputArgs(), $this->ParseInputString()

Code

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