当前位置: 首页>>代码示例>>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;未经允许,请勿转载。