public function rename($name, $safeName = true) { // keep the old state of the file object $old = clone $this; if ($name == $this->name()) { return true; } // check if the name should be sanitized $safeName = $this->page()->blueprint()->files()->sanitize(); // rename and get the new filename $filename = parent::rename($name, $safeName); // trigger the rename hook kirby()->trigger('panel.file.rename', array($this, $old)); }