Ejemplo n.º 1
0
 /**
  * @param EditPage $command
  *
  * @return \Sijad\Pages\Page
  *
  * @throws \Flarum\Core\Exception\PermissionDeniedException
  */
 public function handle(EditPage $command)
 {
     $actor = $command->actor;
     $data = $command->data;
     $page = $this->pages->findOrFail($command->pageId, $actor);
     $this->assertAdmin($actor);
     $attributes = array_get($data, 'attributes', []);
     if (isset($attributes['title'])) {
         $page->title = $attributes['title'];
     }
     if (isset($attributes['slug'])) {
         $page->slug = $attributes['slug'];
     }
     if (isset($attributes['content'])) {
         $page->content = $attributes['content'];
     }
     if (isset($attributes['isHidden'])) {
         $page->is_hidden = (bool) $attributes['isHidden'];
     }
     if (isset($attributes['isHtml'])) {
         $page->is_html = (bool) $attributes['isHtml'];
     }
     $page->edit_time = time();
     $this->validator->assertValid($page->getDirty());
     $page->save();
     return $page;
 }
Ejemplo n.º 2
0
 /**
  * @param DeletePage $command
  *
  * @return \Sijad\Pages\Page
  *
  * @throws \Flarum\Core\Exception\PermissionDeniedException
  */
 public function handle(DeletePage $command)
 {
     $actor = $command->actor;
     $page = $this->pages->findOrFail($command->pageId, $actor);
     $this->assertAdmin($actor);
     $page->delete();
     return $page;
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $id = array_get($request->getQueryParams(), 'id');
     $actor = $request->getAttribute('actor');
     return $this->pages->findOrFail($id, $actor);
 }