本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}