Difference between revisions of "VbzCart/v1/class/vcCartDataManager"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
m
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{page/code/class}}
 
{{page/code/class}}
 +
==About==
 +
* '''purpose''': essentially a helper class for {{l/version|class|vcrCart}}.
 +
* '''jobs''':
 +
** Gets and sets the serialized blob field from the Cart record (GetBlobString(), SetBlobString())
 +
** Creates the BuyerObject ({{l/version|class|vcCartData_Buyer}}) and SellerObject ({{l/version|class|vcCartData_Recip}})
 
* '''file''': {{l/project|file|cart/cart.data.mgr.php}}
 
* '''file''': {{l/project|file|cart/cart.data.mgr.php}}
 +
==Links==
 +
* This class inherits nothing.
 
* Nothing inherits this class.
 
* Nothing inherits this class.
* '''purpose''': essentially a helper class for {{l/version|class|vcrCart}}.
+
* '''created by''': {{l/version/method|vcrCart|FieldsManager}}()
 
* '''points to''':
 
* '''points to''':
 
** {{l/version|class|vcrCart}} (parent)
 
** {{l/version|class|vcrCart}} (parent)
* '''jobs''':
+
** {{l/version|class|vcCartForm}}
** Gets and sets the serialized blob field from the Cart record (GetBlobString(), SetBlobString())
+
===calls===
** Creates the BuyerObject ({{l/version|class|vcCartData_Buyer}}) and SellerObject ({{l/version|class|vcCartData_Recip}})
+
* {{l/version/method|vcCartDataManager|GetBuyerObject}}() [public] - multiple callers
<source lang=php>
+
* {{l/version/method|vcCartDataManager|GetRecipObject}}() [public] - multiple callers
/*::::
+
* {{l/version/method|vcPageContent_ckout|RenderBillingPage}}() calls...
  PURPOSE: manager class for Cart field groups
+
** {{l/version/method|vcCartDataManager|RenderBillingPage}}()
  HISTORY:
+
* {{l/version/method|vcPageContent_ckout|CapturePage}}() [protected] calls...
    2016-06-16 split off from cart.data.fg.php (formerly cart.xdata.php)
+
** {{l/version/method|vcPageContent_ckout|CaptureCart}}() [protected], which doesn't call anything here
*/
+
** {{l/version/method|vcPageContent_ckout|CaptureShipping}}() [protected], which calls...
class vcCartDataManager {
+
*** {{l/version/method|vcCartDataManager|CaptureShippingPage}}() [public]
 
+
** {{l/version/method|vcPageContent_ckout|CaptureBilling}}() [protected], which calls...
    // ++ SETUP ++ //
+
*** {{l/version/method|vcCartDataManager|CaptureBillingPage}}()
 
 
    public function __construct(vcrCart $rcCart, vcShipCountry $oZone) {
 
$this->SetCartRecord($rcCart);
 
$this->SetShipZone($oZone);
 
    }
 
    private $rcCart;
 
    protected function SetCartRecord(vcrCart $rcCart) {
 
$this->rcCart = $rcCart;
 
    }
 
    protected function GetCartRecord() {
 
return $this->rcCart;
 
    }
 
    private $oZone;
 
    protected function SetShipZone(vcShipCountry $oZone) {
 
$this->oZone = $oZone;
 
    }
 
    protected function GetShipZone() {
 
return $this->oZone;
 
    }
 
    private $oBlob = NULL;
 
    protected function GetBlobObject() {
 
if (is_null($this->oBlob)) {
 
    $oBlob = new fcBlobField();
 
    $oBlob->SetString($this->GetBlobString());
 
    $this->oBlob = $oBlob;
 
}
 
return $this->oBlob;
 
    }
 
    protected function GetBlobString() {
 
return $this->GetCartRecord()->GetSerialBlob();
 
    }
 
    protected function SetBlobString($s) {
 
$this->GetCartRecord()->SetSerialBlob($s);
 
    }
 
    /*----
 
      ACTION: unserialize the blob and store it locally as an array
 
      PUBLIC because... well, maybe there's a better way to do this,
 
but I don't know what it is. Cart objects need to be able to
 
update the blob...
 
      HISTORY:
 
2016-06-06 I have no idea why everything but the first line was commented out. Uncommented.
 
    */
 
    /*
 
    public function FetchBlob() {
 
$sBlob = $this->GetBlobString();
 
if (is_null($sBlob)) {
 
    $this->SetBlobArray(array()); // no data yet
 
} else {
 
    $arBlob = unserialize($sBlob);
 
    $this->SetBlobArray($arBlob);
 
}
 
    }
 
    */
 
    /*----
 
      ACTIONS:
 
* serialize the local array
 
* save serialized array back to the blob object
 
* save serialized array back to recordset field
 
(Don't update recordset; caller should do that.)
 
      PUBLIC because... see FetchBlob()
 
    */
 
    public function StoreBlob() {
 
$sBlob = serialize($this->GetBlobArray());
 
$this->SetBlobString($sBlob);
 
    }
 
//   private $arBlob;
 
 
 
    protected function GetBlobArray() {
 
return $this->GetBlobObject()->GetArray();
 
    }
 
    /*----
 
      USED BY: $this->FetchBlob()
 
    */
 
    /*
 
    protected function SetBlobArray(array $ar) {
 
$this->arBlob = $ar;
 
    } */
 
   
 
    // -- SETUP -- //
 
    // ++ SUBSETS ++ //
 
   
 
    private $oBuyer;
 
    public function BuyerObject(vcShipCountry $oZone=NULL) {
 
if (is_object($oZone)) { throw new exception('Stop passing oZone.'); }
 
if (empty($this->oBuyer)) {
 
    $this->oBuyer = new vcCartData_Buyer($this->GetBlobObject(),$this->GetShipZone());
 
}
 
return $this->oBuyer;
 
    }
 
    private $oRecip;
 
    public function RecipObject(vcShipCountry $oZone=NULL) {
 
if (is_object($oZone)) { throw new exception('Stop passing oZone.'); }
 
if (empty($this->oRecip)) {
 
    $this->oRecip = new vcCartData_Recip($this->GetBlobObject(),$this->GetShipZone());
 
}
 
return $this->oRecip;
 
    }
 
 
 
    // -- SUBSETS -- //
 
    // ++ FORM I/O ++ //
 
   
 
    /*----
 
      ACTION:
 
      NOTE: Call FetchBlob() before calling this, and StoreBlob() when done with all updates.
 
    */
 
    public function UpdateBlob(vcCartDataFieldGroup $oData) {
 
$arForm = $oData->GetFormArray();
 
if (is_array($arForm)) {
 
//     $this->SetBlobArray(array_merge($this->GetBlobArray(),$ar));
 
    $oBlob = $this->GetBlobObject();
 
    $oBlob->MergeArray($arForm);
 
}
 
    }
 
   
 
    // -- FORM I/O -- //
 
    // ++ DEBUGGING ++ //
 
   
 
    public function RenderBlob() {
 
return $this->GetBlobObject()->Render();
 
    }
 
 
 
}
 
</source>
 

Latest revision as of 11:31, 4 May 2019

About

Links

calls