Ferreteria/v0.6/clade/Sys/Events/InputRq: Difference between revisions
< 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== | ||
{| class="wikitable sortable" | |||
! name || type || notes | |||
{{!-!}} <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>) | |||
{{!-!}} <code>{{l/ver/fx|ParseInputArgs}}()</code> || abstract protected || | |||
* typically defined at the application level (e.g. <code>{{l/ver/clade|p=futilities|Sys\dba|InReq}}</code>) | |||
* also defined by {{l/ver/clade|Sys\Events\InputRq|Setting}} for inputs that map directly to value-names | |||
{{!-!}} <code>{{l/ver/fx|ParseInputString}}()</code> || abstract protected || | |||
* typically defined at the application level (e.g. <code>{{l/ver/clade|p=futilities|Sys\dba|InReq}}</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| | * ''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 | 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 | // DOCS: https://wooz.dev/Ferreteria/v0.6/fx/WithItemPiece | ||
protected function WithItemPiece(ItemIface $oItem, PieceIface $oPiece) : void { | |||
$this->Item($oItem); | $this->Item($oItem); | ||
if ($oPiece->HasValue()) { | if ($oPiece->HasValue()) { | ||
$sVal = $oPiece->Value(); | $sVal = $oPiece->Value(); | ||
$this->ParseInputArgs($oPiece->GetExtras()); | $this->ParseInputArgs($oPiece->GetExtras()); | ||
} else { | } else { | ||
| Line 100: | Line 101: | ||
} | } | ||
} | } | ||
$this-> | $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
| ||||||||||||||||||||||||
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:
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\Action⇒Sys\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\AnObjectas trait to provideWithSlug()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 | |
ParseInputString() |
abstract protected | |
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