/** * Save wiki page. */ public function saveAction() { $this->addCrumb($this->translate('edit_page'), $this->generateUrl('wiki_edit')); $revision = new WikiRevision($this->revisionParams() + ['wiki_page_id' => $this->page['id'], 'revision' => $this->page->revision()['revision'] + 1]); $this->page->set($this->pageParams()); // Validate page and revision $this->page->validate(); $revision->validate(); if (!$this->page->hasErrors() && !$revision->hasErrors()) { // Check if the content is different and create the revision if it is if ($revision['content'] !== $this->page->revision()['content']) { $revision->save(); $this->page['revision_id'] = $revision['id']; } $this->page->save(); return $this->redirectTo('wiki_page', ['slug' => $this->page['slug']]); } return $this->render('wiki/edit.phtml', ['page' => $this->page, 'revision' => $revision]); }