コード例 #1
0
ファイル: GetPostPath.php プロジェクト: ramcda/posts-module
 /**
  * Handle the command.
  *
  * @param SettingRepositoryInterface $settings
  * @param Parser                     $parser
  * @return string
  */
 public function handle(SettingRepositoryInterface $settings, Parser $parser)
 {
     $base = $settings->value('anomaly.module.posts::module_segment', 'posts');
     if (!$this->post->isEnabled()) {
         return $base . '/preview/' . $this->post->getStrId();
     }
     $permalink = $settings->value('anomaly.module.posts::permalink_structure', ['year', 'month', 'day', 'post']);
     $permalink = implode('}/{', $permalink);
     $data = ['year' => $this->post->publish_at->format('Y'), 'month' => $this->post->publish_at->format('m'), 'day' => $this->post->publish_at->format('d'), 'post' => $this->post->getSlug()];
     return $parser->parse($base . '/' . "{{$permalink}}", $data);
 }
コード例 #2
0
 /**
  * Authorize the post.
  *
  * @param PostInterface $post
  */
 public function authorize(PostInterface $post)
 {
     if (!$post->isEnabled() && !$this->guard->user()) {
         abort(404);
     }
     $this->authorizer->authorize('anomaly.module.posts::view_drafts');
 }
コード例 #3
0
 /**
  * Return the status key.
  *
  * @return null|string
  */
 public function status()
 {
     if (!$this->object->isEnabled()) {
         return 'draft';
     }
     if ($this->object->isEnabled() && !$this->object->isLive()) {
         return 'scheduled';
     }
     if ($this->object->isEnabled() && $this->object->isLive()) {
         return 'live';
     }
     return null;
 }