revision() public method

public revision ( )
Ejemplo n.º 1
0
 /**
  * Create page.
  */
 public function createAction()
 {
     $page = new WikiPage($this->pageParams());
     if ($page->save()) {
         $page->revision()->set(['user_id' => $this->currentUser->id, 'wiki_page_id' => $page->id]);
         $page->revision()->save();
         $page->revision_id = $page->revision()->id;
         $page->save();
         $page->revision()->save();
         // Create timeline event
         Timeline::wikiPageCreatedEvent($this->currentUser, $page)->save();
         return $this->redirectTo('wiki_page', ['slug' => $page['slug']]);
     } else {
         return $this->render('wiki/new.phtml', ['page' => $page]);
     }
 }
Ejemplo n.º 2
0
Archivo: Wiki.php Proyecto: nirix/traq
 /**
  * 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]);
 }