当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveRecordModel::__clone方法代码示例

本文整理汇总了PHP中ActiveRecordModel::__clone方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::__clone方法的具体用法?PHP ActiveRecordModel::__clone怎么用?PHP ActiveRecordModel::__clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActiveRecordModel的用法示例。


在下文中一共展示了ActiveRecordModel::__clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __clone

 public function __clone()
 {
     parent::__clone();
     $this->isFinalized->set(false);
     $this->isPaid->set(false);
     $this->isCancelled->set(false);
     $this->dateCompleted->set(null);
     $this->invoiceNumber->set(null);
     $original = $this->originalRecord;
     $this->shipments = new ARSet();
     $this->orderedItems = array();
     if ($original->isFinalized->get()) {
         foreach ($original->getShipments() as $shipment) {
             $cloned = clone $shipment;
             $cloned->order->set($this);
             if ($this->isMultiAddress->get()) {
                 $this->addShipment($cloned);
             } else {
                 foreach ($cloned->getItems() as $item) {
                     $this->addItem($item);
                 }
             }
         }
     } else {
         foreach ($original->getOrderedItems() as $item) {
             $this->addItem(clone $item);
         }
     }
     if ($this->isMultiAddress->get()) {
         $this->save(true);
         foreach ($this->getShipments() as $shipment) {
             if ($shipment->shippingAddress->get()) {
                 $shipment->shippingAddress->set($this->getClonedAddress($shipment->shippingAddress->get(), false));
             }
             $shipment->save();
             foreach ($shipment->getItems() as $item) {
                 $item->shipment->set($shipment);
                 $item->save();
             }
         }
     }
     // addresses
     if ($this->billingAddress->get()) {
         $this->billingAddress->set($this->getClonedAddress($this->billingAddress->get(), true));
     }
     if ($this->shippingAddress->get()) {
         $this->shippingAddress->set($this->getClonedAddress($this->shippingAddress->get(), false));
     }
     $this->save();
 }
开发者ID:saiber,项目名称:www,代码行数:50,代码来源:CustomerOrder.php

示例2: __clone

 public function __clone()
 {
     parent::__clone();
     $original = $this->originalRecord;
     $this->items = array();
     foreach ($original->getItems() as $item) {
         $this->addItem(clone $item);
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:9,代码来源:Shipment.php


注:本文中的ActiveRecordModel::__clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。