/**
  * Handle the command.
  *
  * @param TypeRepositoryInterface $types
  * @param PostRepositoryInterface $posts
  */
 public function handle(TypeRepositoryInterface $types, PostRepositoryInterface $posts)
 {
     /* @var TypeInterface $type */
     $type = $types->find($this->type->getId());
     /* @var PostInterface $post */
     foreach ($type->getPosts() as $post) {
         $posts->save($post->setAttribute('entry_type', $this->type->getEntryModelName()));
     }
 }
 /**
  * Handle the command.
  *
  * @param StreamRepositoryInterface $streams
  * @param TypeRepositoryInterface   $types
  * @param Repository                $config
  */
 public function handle(StreamRepositoryInterface $streams, TypeRepositoryInterface $types, Repository $config)
 {
     /* @var TypeInterface $type */
     $type = $types->find($this->type->getId());
     /* @var StreamInterface $stream */
     $stream = $type->getEntryStream();
     $stream->fill([$config->get('app.fallback_locale') => ['name' => $this->type->getName(), 'description' => $this->type->getDescription()], 'slug' => $this->type->getSlug() . '_posts']);
     $streams->save($stream);
 }
Beispiel #3
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 #4
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 #5
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 #6
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;
 }
 /**
  * Handle the command.
  *
  * @param TypeRepositoryInterface $types
  * @param PostFormBuilder         $builder
  * @param Request                 $request
  */
 public function handle(TypeRepositoryInterface $types, PostFormBuilder $builder, Request $request)
 {
     $this->builder->addForm('post', $builder->setType($types->find($request->get('type'))));
 }
 /**
  * Handle the command.
  *
  * @param TypeRepositoryInterface $types
  * @param EntryFormBuilder        $builder
  * @param Request                 $request
  */
 public function handle(TypeRepositoryInterface $types, EntryFormBuilder $builder, Request $request)
 {
     $type = $types->find($request->get('type'));
     $this->builder->addForm('entry', $builder->setModel($type->getEntryModelName()));
 }
 /**
  * Return a form for an existing post type field and assignment.
  *
  * @param AssignmentFormBuilder       $form
  * @param TypeRepositoryInterface     $types
  * @param BreadcrumbCollection        $breadcrumbs
  * @param                             $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function assignment(AssignmentFormBuilder $form, TypeRepositoryInterface $types, BreadcrumbCollection $breadcrumbs, $id, $assignment)
 {
     $type = $types->find($id);
     $breadcrumbs->put('module::breadcrumb.fields', 'admin/posts/types/fields/' . $type->getId());
     return $form->render($assignment);
 }
Beispiel #10
0
 /**
  * Return the modal for choosing a post type.
  *
  * @param TypeRepositoryInterface $types
  * @return \Illuminate\View\View
  */
 public function chooseType(TypeRepositoryInterface $types)
 {
     return view('module::admin/ajax/choose_type', ['types' => $types->all()]);
 }