Ferreteria/v0.6/clade/Sys/Events/ItWent/CommOp/MsgsOp

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Events‎ | ItWent‎ | CommOp
Revision as of 23:39, 31 October 2025 by Woozle (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
clade: Sys\Events\ItWent\CommOp\MsgsOp
Clade Family
CommOp MsgsOp (Maria) ItWent
Clade Aliases
Alias Clade
Base* [c,i] Sys\Events\ItWent\CommOp
Subpages

Code

as of 2025-10-31

interface iMsgsOp extends BaseIface {
    // ACTION
    function HandleResults() : void;
}
abstract class caMsgsOp extends BaseClass implements iMsgsOp {
    // ++ CONFIG ++ //

    abstract protected function ErrorsAdminClass() : string;

    // -- CONFIG -- //
    // ++ ACTION ++ //

    // PURPOSE: do any result-checking that is common to most data ops, and display appropriate messages
    public function HandleResults() : void {
        $oAct = $this;
        $ok = $oAct->GetOkay();
        if (!$ok) {
            $oScrn = self::Screen();

            // Successful connection will sometimes give warnings (mainly the one about putting a password on the command-line),
            //  which the Shell object will interpret as failure, so we need to see if this is a warning or an error:
            if ($oAct->AnyMessages()) {
                $arMsg = $oAct->AllMessages();
                $nMsg = count($arMsg);
                foreach ($arMsg as $oMsg) {
                    $sMsg = $oMsg->Text();
                    $this->CheckMessage($sMsg);
                }
            }
        }
    }
    protected function CheckMessage(string $sMsg) {
        $oScrn = self::Screen();
        $oMsg = ($this->ErrorsAdminClass())::FromMessage($sMsg);
        if (is_object($oMsg)) {
            // For now, all the recognized errors aren't serious problems -- so we'll call this a warning message.
            #$isWarning = TRUE;
            $sShow = $oMsg->Full();
        } else {
            #$isWarning = FALSE;
            $sShow = $oScrn->ErrorIt('Error').': '.$sMsg;
        }

        /*
        if ($isWarning) {
            $this->SetOkay(TRUE); // not an actual error
            $sPre = $oScrn->YellowIt('Warning');
        } else {
            $sPre = $oScrn->ErrorIt('Error');
        }
        echo CRLF.$sPre.': '.$sShow.CRLF;
        */
        echo CRLF.$sShow.CRLF;  // not sure why "bytes saved" isn't doing a CRLF
    }

    // -- ACTION -- //
}