Created
August 23, 2011 12:17
-
-
Save lolautruche/1164970 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function trashSubtree( $locationId ) | |
{ | |
$location = $this->load( $locationId ); | |
// Create new trashed location and remove original location from tree | |
$params = (array)$location; | |
$params['locationId'] = $locationId; | |
// Be sure to not overlap id | |
unset( $params['id'] ); | |
$trashedLocation = $this->backend->create( 'Content\\TrashedLocation', $params ); | |
// Remove location from tree here | |
// Begin recursive call on children, if any | |
$directChildren = $this->backend->find( 'Content\\Location', array( 'parentId' => $locationId ) ); | |
if ( !empty( $directChildren ) ) | |
{ | |
foreach ( $directChildren as $child ) | |
{ | |
$this->trashSubtree( $child->id ); | |
} | |
} | |
return $trashedLocation; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment