/** * 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); }
/** * Load post data to the template. * * @param PostInterface $post */ public function load(PostInterface $post) { $this->template->set('title', $post->getTitle()); $this->template->set('meta_title', $post->metaTitle()); $this->template->set('meta_keywords', $post->metaKeywords()); $this->template->set('meta_description', $post->metaDescription()); }
/** * Handle the command. * * @param EntryFormBuilder $builder */ public function handle(EntryFormBuilder $builder) { $type = $this->post->getType(); $builder->setModel($type->getEntryModelName()); $builder->setEntry($this->post->getEntryId()); $this->builder->addForm('entry', $builder); }
/** * 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'); }
/** * Catch calls to fields on * the page's related entry. * * @param string $key * @return mixed */ public function __get($key) { $entry = $this->object->getEntry(); if ($entry && $entry->hasField($key)) { return (new Decorator())->decorate($entry)->{$key}; } return parent::__get($key); }
/** * 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); }
/** * Add the page and page type assets. * * @param PostInterface $post * @throws \Exception */ public function add(PostInterface $post) { /* @var EditorFieldTypePresenter $js */ /* @var EditorFieldTypePresenter $css */ $js = $post->getFieldTypePresenter('js'); $css = $post->getFieldTypePresenter('css'); $this->asset->add('styles.css', $css->path()); $this->asset->add('scripts.js', $js->path()); $type = $post->getType(); $js = $type->getFieldTypePresenter('js'); $css = $type->getFieldTypePresenter('css'); $this->asset->add('styles.css', $css->path()); $this->asset->add('scripts.js', $js->path()); }
/** * Cache the post's HTTP response. * * @param PostInterface $post */ public function cache(PostInterface $post) { $response = $post->getResponse(); $response->setTtl($this->settings->get('anomaly.module.posts::ttl')); }
/** * Handle the command. * * @param PostFormBuilder $builder */ public function handle(PostFormBuilder $builder) { $builder->setEntry($this->post->getId()); $this->builder->addForm('post', $builder); }
/** * Handle the command. * * @param Request $request * @param BreadcrumbCollection $breadcrumbs */ public function handle(Request $request, BreadcrumbCollection $breadcrumbs) { $breadcrumbs->add($this->post->getTitle(), $request->fullUrl()); }
/** * Make the post response. * * @param PostInterface $post */ public function make(PostInterface $post) { $post->setResponse($this->response->view('anomaly.module.posts::posts/post', ['post' => $post, 'content' => $post->getContent()])); }
/** * Make the post response. * * @param PostInterface $post */ public function make(PostInterface $post) { $post->setResponse($this->response->view('anomaly.module.posts::posts/post', compact('post'))); }
/** * Delete a post. * * @param PostInterface|EntryModel $post * @return bool */ public function delete(PostInterface $post) { return $post->delete(); }
/** * Return the view link. * * @return string */ public function viewLink() { return app('html')->link($this->object->path(), $this->object->getTitle(), ['target' => '_blank']); }
/** * Make the view content. * * @param PostInterface $p */ public function make(PostInterface $post) { $post->setContent($this->view->make($post->getLayoutViewPath(), compact('post'))->render()); }