/** * Handle the command. * * @param Repository $config * @param Resolver $resolver * @param Evaluator $evaluator * @param Value $value * @return string */ public function handle(Repository $config, Resolver $resolver, Evaluator $evaluator, Value $value) { $base = '/' . $config->get('anomaly.module.posts::paths.module'); if (!$this->post->isLive()) { return $base . '/preview/' . $this->post->getStrId(); } return $base . '/' . $value->make($evaluator->evaluate($resolver->resolve($config->get('anomaly.module.posts::paths.permalink'), ['post' => $this->post]), ['post' => $this->post]), $this->post); }
/** * 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); }