Skip to content

Instantly share code, notes, and snippets.

@sb-relaxt-at
Created February 1, 2016 23:01
Show Gist options
  • Save sb-relaxt-at/20b834ab89e8fd18e4f7 to your computer and use it in GitHub Desktop.
Save sb-relaxt-at/20b834ab89e8fd18e4f7 to your computer and use it in GitHub Desktop.
public function updateFilesystem() {
$filenameBeforeUpdate = $this->Filename;
parent::updateFilesystem();
if($filenameBeforeUpdate != $this->Filename){
// in this case the filename has changed due to a changed parent
// we need to write the change to the db, otherwise the children won't see it
$this->write();
// no need to proceed as this method has already been called again by the write above
return;
}
// unmodified from here on
if($this->ID && ($children = $this->AllChildren())) {
foreach($children as $child) {
$child->updateFilesystem();
$child->write(); // might be only necessary if it is a file?
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment