コード例 #1
0
 /**
  * Handle the command.
  *
  * @param SettingRepositoryInterface $settings
  * @param Parser                     $parser
  * @return string
  */
 public function handle(SettingRepositoryInterface $settings, Parser $parser)
 {
     $base = $settings->get('anomaly.module.posts::module_segment', 'posts');
     $structure = $settings->get('anomaly.module.posts::permalink_structure', '{year}/{month}/{day}/{post}');
     $data = ['year' => $this->post->created_at->format('Y'), 'month' => $this->post->created_at->format('m'), 'day' => $this->post->created_at->format('d'), 'post' => $this->post->getSlug()];
     return $parser->parse($base . '/' . $structure, $data);
 }
コード例 #2
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);
 }