VbzCart/docs/v1/class/vcCartDataManager: Difference between revisions

From Woozle Writes Code
< VbzCart‎ | docs‎ | v1/class
Jump to navigation Jump to search
imported>Woozle
(Created page with "{{page/code/class}} * '''file''': {{l/project|file|cart/cart.data.mgr.php}} * Nothing inherits this class. * '''jobs''': ** Gets and sets the serialized blob field from the Ca...")
 
m (Woozle moved page VbzCart/VbzCart/v1/class/vcCartDataManager to VbzCart/docs/v1/class/vcCartDataManager without leaving a redirect: part 5/5)
 
(11 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{page/code/class}}
{{page/code/class}}
* '''file''': {{l/project|file|cart/cart.data.mgr.php}}
==About==
* Nothing inherits this class.
* '''purpose''': essentially a helper class for {{l/version|class|vcrCart}}.
* '''jobs''':
* '''jobs''':
** Gets and sets the serialized blob field from the Cart record (GetBlobString(), SetBlobString())
** 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}})
** Creates the BuyerObject ({{l/version|class|vcCartData_Buyer}}) and SellerObject ({{l/version|class|vcCartData_Recip}})
<source lang=php>
* '''file''': {{l/project|file|cart/cart.data.mgr.php}}
/*::::
==Links==
  PURPOSE: manager class for Cart field groups
* This class inherits nothing.
  HISTORY:
* Nothing inherits this class.
    2016-06-16 split off from cart.data.fg.php (formerly cart.xdata.php)
* '''created by''': {{l/version/method|vcrCart|FieldsManager}}()
*/
* '''points to''':
class vcCartDataManager {
** {{l/version|class|vcrCart}} (parent)
 
** {{l/version|class|vcCartForm}}
    // ++ SETUP ++ //
===calls===
 
* {{l/version/method|vcCartDataManager|GetBuyerObject}}() [public] - multiple callers
    public function __construct(vcrCart $rcCart, vcShipCountry $oZone) {
* {{l/version/method|vcCartDataManager|GetRecipObject}}() [public] - multiple callers
$this->SetCartRecord($rcCart);
* {{l/version/method|vcPageContent_ckout|RenderBillingPage}}() calls...
$this->SetShipZone($oZone);
** {{l/version/method|vcCartDataManager|RenderBillingPage}}()
    }
* {{l/version/method|vcPageContent_ckout|CapturePage}}() [protected] calls...
    private $rcCart;
** {{l/version/method|vcPageContent_ckout|CaptureCart}}() [protected], which doesn't call anything here
    protected function SetCartRecord(vcrCart $rcCart) {
** {{l/version/method|vcPageContent_ckout|CaptureShipping}}() [protected], which calls...
$this->rcCart = $rcCart;
*** {{l/version/method|vcCartDataManager|CaptureShippingPage}}() [public]
    }
** {{l/version/method|vcPageContent_ckout|CaptureBilling}}() [protected], which calls...
    protected function GetCartRecord() {
*** {{l/version/method|vcCartDataManager|CaptureBillingPage}}()
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 01:57, 25 February 2024

Template:Page/code/class

About

Links

calls