Beispiel #1
0
 /**
  * Run the seeder.
  */
 public function run()
 {
     if ($type = $this->types->findBySlug('default_posts')) {
         $this->types->delete($type);
     }
     /* @var TypeInterface $type */
     $type = $this->types->truncate()->create(['en' => ['name' => 'Default', 'description' => 'A simple post type.'], 'slug' => 'default', 'theme_layout' => 'theme::layouts/default.twig', 'layout' => '{{ post.content|raw }}']);
     $stream = $type->getEntryStream();
     $this->assignments->create(['stream' => $stream, 'field' => $this->fields->findBySlugAndNamespace('content', 'posts')]);
 }
Beispiel #2
0
 /**
  * Run the seeder.
  */
 public function run()
 {
     $this->posts->truncate();
     $repository = new EntryRepository();
     $repository->setModel(new PostsDefaultPostsEntryModel());
     $repository->truncate();
     $type = $this->types->findBySlug('default');
     $category = $this->categories->findBySlug('news');
     $welcome = (new PostsDefaultPostsEntryModel())->create(['content' => '<p>Welcome to PyroCMS!</p>']);
     $this->posts->create(['en' => ['title' => 'Welcome to PyroCMS!', 'summary' => 'This is an example post to demonstrate the posts module.'], 'slug' => 'welcome-to-pyrocms', 'publish_at' => time(), 'enabled' => true, 'type' => $type, 'entry' => $welcome, 'category' => $category, 'author' => 1]);
 }
Beispiel #3
0
 /**
  * Return an index of type posts.
  *
  * @param TypeRepositoryInterface     $categories
  * @param PostRepositoryInterface     $posts
  * @param                             $type
  * @return \Illuminate\View\View
  */
 public function index(TypeRepositoryInterface $categories, PostRepositoryInterface $posts, $type)
 {
     if (!($type = $categories->findBySlug($type))) {
         abort(404);
     }
     $this->dispatch(new AddPostsBreadcrumb());
     $this->dispatch(new AddTypeBreadcrumb($type));
     $this->dispatch(new AddTypeMetaTitle($type));
     $posts = $posts->findManyByType($type);
     return view('anomaly.module.posts::types/index', compact('type', 'posts'));
 }
Beispiel #4
0
 /**
  * Handle the command.
  *
  * @param TypeRepositoryInterface $types
  * @return TypeInterface|null
  */
 public function handle(TypeRepositoryInterface $types)
 {
     if (is_numeric($this->identifier)) {
         return $types->find($this->identifier);
     }
     if (is_string($this->identifier)) {
         return $types->findBySlug($this->identifier);
     }
     if ($this->identifier instanceof Presenter) {
         return $this->identifier->getObject();
     }
     if ($this->identifier instanceof TypeInterface) {
         return $this->identifier;
     }
     return null;
 }