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

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Events‎ | InputRq
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 15: Line 15:
* '''in repo''': [https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/src/Sys/Events/InputRq/Setting.php code]
* '''in repo''': [https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/src/Sys/Events/InputRq/Setting.php code]
A {{l/ver/clade|Sys\Events\InputRq|Setting}} is an {{l/ver/clade|Sys/Events|InputRq}} whose primary (or only) purpose is to change the value of a setting used by any other {{l/ver/clade|Sys/Events|InputRq}}s that might need it. The value is saved under the Setting's assigned name (NameOfInput()).
A {{l/ver/clade|Sys\Events\InputRq|Setting}} is an {{l/ver/clade|Sys/Events|InputRq}} whose primary (or only) purpose is to change the value of a setting used by any other {{l/ver/clade|Sys/Events|InputRq}}s that might need it. The value is saved under the Setting's assigned name (NameOfInput()).
* '''Purpose''': an Actor object that can modify the value/state of an Option object
** The value can be required or optional, depending on the `valreq` attribute.
===Pages===
* [[/@removed/]]
==={{hashtag|TODO}}===
* '''{{fmt/date|2025|03|08}}''' Should probably be renamed "Simple", ocelot, since all <code>InputRq</code>s will now accept a value (by default, anyway).
* '''{{fmt/date|2024|10|29}}''' We might, at some point, want to generalize this so it's not dependent on a *tag*-Option but instead some more generalized Option State interface (to be written, I guess). For now, Get It Working.
===Pieces===
* <code>{{l/ver/fx|Input}}()</code> is the full/raw/unparsed value-string associated with this item in the command
* <code>{{l/ver/fx|Item}}()</code> is the XML tag (or, eventually, some generic equivalent) which defines the UI details for this subcommand
* <code>{{l/ver/fx|OInput}}()</code> is the InRqData object for interpreting the `Input()` value
==History==
* '''{{fmt/date|2024|10|28}}''' created (for WUIDL)
* '''{{fmt/date|2024|11|19}}''' renamed/moved from [WF]Sys\Routing\Action -> [WF]Sys\Events\Actor
* '''{{fmt/date|2024|12|14}}''' switched to static pseudoconstructor to make tracing easier
* '''{{fmt/date|2024|12|22}}''' created ValReq
* '''{{fmt/date|2024|12|23}}''' decided that value requirements (quantity, list...) should be in the UI XML instead of being defined by the podling class. This simplifies the code-structure.
** Deleting Option/ValReq (after first creating ValOpt, which is now also deleted).
* '''{{fmt/date|2025|01|21}}''' Renaming this clade from Option -> Settable, for clarity
* '''{{fmt/date|2025|01|23}}''' Made `Item()` public so Settings can access it.
* '''{{fmt/date|2025|03|08}}'''
** Moving <code>FromItemValue()</code> to parent (InputRq).
** Renaming <code>WithInput()</code> to `ParseInput()`, because now this (setting by actor key) is just one way of parsing.
* '''{{fmt/date|2025|09|01}}''' renamed from "Settable" to "Setting"
==Functions==
==Functions==
===public===
===public===
* {{fmt/php/inline|function Describe() : string}} (override)
* <code>function {{l/sub/fx|Describe}}() : string</code> (override)
* {{fmt/php/inline|function Go()}} (override)
* <code>function {{l/sub/fx|Go}}()</code> (override)
* {{fmt/php/inline|function NameOfInput() : string}}
* <code>function {{l/ver/fx|NameOfInput}}() : string</code>}}
===internal===
===internal===
* {{fmt/php/inline|function ParseInputString(string $s) : void}}
* <code>function {{l/ver/fx|ParseInputString}}(string $s) : void</code>
** <code>$s</code> = first value given to the subcommand (e.g. for "cmd:stuff:things", $s will be "stuff")
* <code>function {{l/ver/fx|ParseInputArgs}}(array $arArgs) {}</code> (no code here)
** Additional parts (e.g. "things") get sent to ParseInputArgs().
* {{fmt/php/inline|function ParseInputArgs(array $arArgs) {}}} : no code
** <code>$arArgs</code> = number-based array of additional values (if any) (e.g. for "cmd:stuff:things:more", $arArgs will be [0]=>"things", [1]=>"more)
** <code>$arArgs</code> = number-based array of additional values (if any) (e.g. for "cmd:stuff:things:more", $arArgs will be [0]=>"things", [1]=>"more)
** By default, these aren't retained since their meaning is action-dependent. Podlings can override this.
** By default, these aren't retained since their meaning is action-dependent. Podlings can override this.
==Code==
''as of {{fmt/date|2025|11|17}} (including some debug code):''
{{fmt/php/block|1=
interface iSetting extends BaseIface {}
class cSetting extends BaseClass implements SelfIface {
    // ++ SETUP: dynamic ++ //
    // $s = first input to the subcommand
    protected function ParseInputString(string $s) : void {
        $sName = $this->NameOfInput();
        $this->OAUserInput()->SetIt($sName,$s);
        #echo "PARSING INPUT: set [$sName] -> [$s] in id".$this->OAUserInput()->ObjectID().CRLF;
        $qs = $this->OAUserInput()->GetItQ($sName);
        $this->AmHere("USER INPUT: ".$this->OAUserInput()->Inspect()->Render());
    }
    // By defalt, Settables don't expect any extra arguments.
    protected function ParseInputArgs(array $arArgs) {}
    // -- SETUP -- //
    // ++ ACTION ++ //
    // DOCS: https://wooz.dev/Ferreteria/v0.6/clade/Sys/Events/InputRq/Setting/@fx/Go
    public function Go() {
        $sName = $this->NameOfInput();  // the internal key for the subcommand we're processing here
        $oaUIn = $this->OAUserInput();
        $qsVal = $oaUIn->GetItQ($sName);
        echo "GO (id".$oaUIn->ObjectID()."): [$sName] is ";
        if ($qsVal->HasIt()) {
            $sVal = $oaUIn->GetIt($sName);
            echo "set to [$sVal]";
        } else {
            echo "not set";
        }
        echo " in ".get_called_class().CRLF;
    }
    // -- ACTION -- //
    // ++ OUTPUT ++ //
    public function Describe() : string {
        $this->AmHere("USER INPUT: ".$this->OAUserInput()->Inspect()->Render());
        $sName = $this->NameOfInput();  // the internal key for the subcommand we're processing here
        $oItem = $this->Item();
        $ftCues = $oItem->RenderUIName();
        #$sName = $oItem->SName();
        $this->AmHere("CHECKING input [$sName]...");
        $qsVal = $this->OAUserInput()->GetItQ($sName);
        if ($qsVal->HasIt()) {
            $sVal = $qsVal->GetIt();
            return "set the $ftCues value to '$sVal'";
        } else {
            echo "USER INPUT: ".$this->OAUserInput()->Inspect()->Render();
            return "set the $ftCues value -- but no value was given!";
        }
    }
    // -- OUTPUT -- //
}
}}

Latest revision as of 21:18, 17 November 2025

clade: Sys\Events\InputRq\Setting
Clade Family
InputRq Setting [WFu]InSet
Clade Aliases
Alias Clade
Base* [ca,i] Sys\Events\InputRq
InData* [c,i] Sys\Events\InputRq\aux\InRqData
ItemIface Sys\Events\InputItem
SelfIface Sys\Events\InputRq\Setting
Subpages

About

A Setting is an InputRq whose primary (or only) purpose is to change the value of a setting used by any other InputRqs that might need it. The value is saved under the Setting's assigned name (NameOfInput()).

  • Purpose: an Actor object that can modify the value/state of an Option object
    • The value can be required or optional, depending on the `valreq` attribute.

Pages

#TODO

  • 2025-03-08 Should probably be renamed "Simple", ocelot, since all InputRqs will now accept a value (by default, anyway).
  • 2024-10-29 We might, at some point, want to generalize this so it's not dependent on a *tag*-Option but instead some more generalized Option State interface (to be written, I guess). For now, Get It Working.

Pieces

  • Input() is the full/raw/unparsed value-string associated with this item in the command
  • Item() is the XML tag (or, eventually, some generic equivalent) which defines the UI details for this subcommand
  • OInput() is the InRqData object for interpreting the `Input()` value

History

  • 2024-10-28 created (for WUIDL)
  • 2024-11-19 renamed/moved from [WF]Sys\Routing\Action -> [WF]Sys\Events\Actor
  • 2024-12-14 switched to static pseudoconstructor to make tracing easier
  • 2024-12-22 created ValReq
  • 2024-12-23 decided that value requirements (quantity, list...) should be in the UI XML instead of being defined by the podling class. This simplifies the code-structure.
    • Deleting Option/ValReq (after first creating ValOpt, which is now also deleted).
  • 2025-01-21 Renaming this clade from Option -> Settable, for clarity
  • 2025-01-23 Made `Item()` public so Settings can access it.
  • 2025-03-08
    • Moving FromItemValue() to parent (InputRq).
    • Renaming WithInput() to `ParseInput()`, because now this (setting by actor key) is just one way of parsing.
  • 2025-09-01 renamed from "Settable" to "Setting"

Functions

public

internal

  • function ParseInputString(string $s) : void
  • function ParseInputArgs(array $arArgs) {} (no code here)
    • $arArgs = number-based array of additional values (if any) (e.g. for "cmd:stuff:things:more", $arArgs will be [0]=>"things", [1]=>"more)
    • By default, these aren't retained since their meaning is action-dependent. Podlings can override this.

Code

as of 2025-11-17 (including some debug code):

interface iSetting extends BaseIface {}
class cSetting extends BaseClass implements SelfIface {

    // ++ SETUP: dynamic ++ //

    // $s = first input to the subcommand
    protected function ParseInputString(string $s) : void {
        $sName = $this->NameOfInput();
        $this->OAUserInput()->SetIt($sName,$s);
        #echo "PARSING INPUT: set [$sName] -> [$s] in id".$this->OAUserInput()->ObjectID().CRLF;
        $qs = $this->OAUserInput()->GetItQ($sName);
        $this->AmHere("USER INPUT: ".$this->OAUserInput()->Inspect()->Render());
    }
    // By defalt, Settables don't expect any extra arguments.
    protected function ParseInputArgs(array $arArgs) {}

    // -- SETUP -- //
    // ++ ACTION ++ //

    // DOCS: https://wooz.dev/Ferreteria/v0.6/clade/Sys/Events/InputRq/Setting/@fx/Go
    public function Go() {
        $sName = $this->NameOfInput();  // the internal key for the subcommand we're processing here
        $oaUIn = $this->OAUserInput();
        $qsVal = $oaUIn->GetItQ($sName);
        echo "GO (id".$oaUIn->ObjectID()."): [$sName] is ";
        if ($qsVal->HasIt()) {
            $sVal = $oaUIn->GetIt($sName);
            echo "set to [$sVal]";
        } else {
            echo "not set";
        }
        echo " in ".get_called_class().CRLF;
    }

    // -- ACTION -- //
    // ++ OUTPUT ++ //

    public function Describe() : string {
        $this->AmHere("USER INPUT: ".$this->OAUserInput()->Inspect()->Render());
        $sName = $this->NameOfInput();  // the internal key for the subcommand we're processing here
        $oItem = $this->Item();
        $ftCues = $oItem->RenderUIName();
        #$sName = $oItem->SName();
        $this->AmHere("CHECKING input [$sName]...");
        $qsVal = $this->OAUserInput()->GetItQ($sName);
        if ($qsVal->HasIt()) {
            $sVal = $qsVal->GetIt();
            return "set the $ftCues value to '$sVal'";
        } else {
            echo "USER INPUT: ".$this->OAUserInput()->Inspect()->Render();
            return "set the $ftCues value -- but no value was given!";
        }
    }

    // -- OUTPUT -- //
}