當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataObject::duplicate方法代碼示例

本文整理匯總了PHP中DataObject::duplicate方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObject::duplicate方法的具體用法?PHP DataObject::duplicate怎麽用?PHP DataObject::duplicate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataObject的用法示例。


在下文中一共展示了DataObject::duplicate方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: duplicate

 /**
  * Create a duplicate of this node. Doesn't affect joined data - create a
  * custom overloading of this if you need such behaviour.
  *
  * @return SiteTree The duplicated object.
  */
 public function duplicate($doWrite = true)
 {
     $page = parent::duplicate(false);
     $page->Sort = 0;
     $this->extend('onBeforeDuplicate', $page);
     if ($doWrite) {
         $page->write();
     }
     $this->extend('onAfterDuplicate', $page);
     return $page;
 }
開發者ID:eLBirador,項目名稱:AllAboutCity,代碼行數:17,代碼來源:SiteTree.php

示例2: duplicate

 /**
  * Create a duplicate of this order/estimate as well as duplicating
  * associated items
  *
  * @param $doWrite Perform a write() operation before returning the object.  If this is true, it will create the
  *                 duplicate in the database.
  * @return DataObject A duplicate of this node. The exact type will be the type of this node.
  */
 public function duplicate($doWrite = true)
 {
     $clone = parent::duplicate($doWrite);
     // Set up items
     if ($doWrite) {
         foreach ($this->Items() as $item) {
             $item_class = $item->class;
             $clone_item = new $item_class($item->toMap(), false, $this->model);
             $clone_item->ID = 0;
             $clone_item->ParentID = $clone->ID;
             $clone_item->write();
         }
     }
     $clone->invokeWithExtensions('onAfterDuplicate', $this, $doWrite);
     return $clone;
 }
開發者ID:i-lateral,項目名稱:silverstripe-orders,代碼行數:24,代碼來源:Order.php

示例3: duplicate

 /**
  * Create a duplicate of this node. Doesn't affect joined data - create a custom overloading of this if you need
  * such behaviour.
  *
  * @param bool $doWrite Whether to write the new object before returning it
  * @return self The duplicated object
  */
 public function duplicate($doWrite = true)
 {
     $page = parent::duplicate(false);
     $page->Sort = 0;
     $this->invokeWithExtensions('onBeforeDuplicate', $page);
     if ($doWrite) {
         $page->write();
         $page = $this->duplicateManyManyRelations($this, $page);
     }
     $this->invokeWithExtensions('onAfterDuplicate', $page);
     return $page;
 }
開發者ID:maent45,項目名稱:redefine_renos,代碼行數:19,代碼來源:SiteTree.php

示例4: duplicate

 /**
  * Create a duplicate of this node. Doesn't affect joined data - create a
  * custom overloading of this if you need such behaviour.
  *
  * @return SiteTree The duplicated object.
  */
 public function duplicate($doWrite = true)
 {
     $page = parent::duplicate($doWrite);
     $page->CheckedPublicationDifferences = $page->AddedToStage = true;
     return $page;
 }
開發者ID:ramziammar,項目名稱:websites,代碼行數:12,代碼來源:SiteTree.php

示例5: duplicate

 /**
  * Duplicates this panel. Drills down into the has_many relations
  *
  * @return DashboardPanel
  */
 public function duplicate($dowrite = true)
 {
     $clone = parent::duplicate(true);
     foreach ($this->has_many() as $relationName => $relationClass) {
         foreach ($this->{$relationName}() as $relObject) {
             $relClone = $relObject->duplicate(false);
             $relClone->DashboardPanelID = $clone->ID;
             $relClone->write();
         }
     }
     return $clone;
 }
開發者ID:helpfulrobot,項目名稱:unclecheese-dashboard,代碼行數:17,代碼來源:DashboardPanel.php

示例6: duplicate

 /**
  * Duplicate this subsite
  */
 function duplicate()
 {
     $newTemplate = parent::duplicate();
     $oldSubsiteID = Session::get('SubsiteID');
     self::changeSubsite($this->ID);
     /*
      * Copy data from this template to the given subsite. Does this using an iterative depth-first search.
      * This will make sure that the new parents on the new subsite are correct, and there are no funny
      * issues with having to check whether or not the new parents have been added to the site tree
      * when a page, etc, is duplicated
      */
     $stack = array(array(0, 0));
     while (count($stack) > 0) {
         list($sourceParentID, $destParentID) = array_pop($stack);
         $children = Versioned::get_by_stage('Page', 'Live', "\"ParentID\" = {$sourceParentID}", '');
         if ($children) {
             foreach ($children as $child) {
                 $childClone = $child->duplicateToSubsite($newTemplate, false);
                 $childClone->ParentID = $destParentID;
                 $childClone->writeToStage('Stage');
                 $childClone->publish('Stage', 'Live');
                 array_push($stack, array($child->ID, $childClone->ID));
             }
         }
     }
     self::changeSubsite($oldSubsiteID);
     return $newTemplate;
 }
開發者ID:hafriedlander,項目名稱:silverstripe-config-experiment,代碼行數:31,代碼來源:Subsite.php

示例7: duplicate

	/**
	 * Create a duplicate of this node. Doesn't affect joined data - create a
	 * custom overloading of this if you need such behaviour.
	 *
	 * @return SiteTree The duplicated object.
	 */
	 public function duplicate($doWrite = true) {
		$page = parent::duplicate($doWrite);
		return $page;
	}
開發者ID:neopba,項目名稱:silverstripe-book,代碼行數:10,代碼來源:SiteTree.php


注:本文中的DataObject::duplicate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。