<commit_before><?php namespace Anomaly\PostsModule\Seeder;

use Anomaly\PostsModule\Category\Contract\CategoryRepositoryInterface;
use Anomaly\PostsModule\Post\Contract\PostRepositoryInterface;
use Anomaly\PostsModule\Type\Contract\TypeRepositoryInterface;
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
use Anomaly\Streams\Platform\Entry\EntryRepository;
use Anomaly\Streams\Platform\Model\Posts\PostsDefaultPostsEntryModel;
use Anomaly\UsersModule\User\UserModel;
use Anomaly\UsersModule\User\UserRepository;

/**
 * Class PostSeeder
 *
 * @link          http://pyrocms.com/
 * @author        PyroCMS, Inc. <<EMAIL>>
 * @author        <NAME> <<EMAIL>>
 * @package       Anomaly\PostsModule\Seeder
 */
class PostSeeder extends Seeder
{

    /**
     * The post repository.
     *
     * @var PostRepositoryInterface
     */
    protected $posts;

    /**
     * The type repository.
     *
     * @var TypeRepositoryInterface
     */
    protected $types;

    /**
     * The category repository.
     *
     * @var CategoryRepositoryInterface
     */
    protected $categories;

    /**
     * Create a new PostSeeder instance.
     *
     * @param PostRepositoryInterface     $posts
     * @param TypeRepositoryInterface     $types
     * @param CategoryRepositoryInterface $categories
     */
    public function __construct(
        PostRepositoryInterface $posts,
        TypeRepositoryInterface $types,
        CategoryRepositoryInterface $categories
    ) {
        $this->posts      = $posts;
        $this->types      = $types;
        $this->categories = $categories;
    }

    /**
     * Run the seeder.
     */
    public function run()
    {
        $this->posts->truncate();

        $repository = new EntryRepository();

        $repository->setModel(new PostsDefaultPostsEntryModel());

        $users = new UserRepository(new UserModel());

        $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'     => $users->findByUsername('admin')
            ]
        );
    }
}<commit_msg>We don't know the User's ID yet.<commit_after><?php namespace Anomaly\PostsModule\Seeder;

use Anomaly\PostsModule\Category\Contract\CategoryRepositoryInterface;
use Anomaly\PostsModule\Post\Contract\PostRepositoryInterface;
use Anomaly\PostsModule\Type\Contract\TypeRepositoryInterface;
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
use Anomaly\Streams\Platform\Entry\EntryRepository;
use Anomaly\Streams\Platform\Model\Posts\PostsDefaultPostsEntryModel;

/**
 * Class PostSeeder
 *
 * @link          http://pyrocms.com/
 * @author        PyroCMS, Inc. <<EMAIL>>
 * @author        <NAME> <<EMAIL>>
 * @package       Anomaly\PostsModule\Seeder
 */
class PostSeeder extends Seeder
{

    /**
     * The post repository.
     *
     * @var PostRepositoryInterface
     */
    protected $posts;

    /**
     * The type repository.
     *
     * @var TypeRepositoryInterface
     */
    protected $types;

    /**
     * The category repository.
     *
     * @var CategoryRepositoryInterface
     */
    protected $categories;

    /**
     * Create a new PostSeeder instance.
     *
     * @param PostRepositoryInterface     $posts
     * @param TypeRepositoryInterface     $types
     * @param CategoryRepositoryInterface $categories
     */
    public function __construct(
        PostRepositoryInterface $posts,
        TypeRepositoryInterface $types,
        CategoryRepositoryInterface $categories
    ) {
        $this->posts      = $posts;
        $this->types      = $types;
        $this->categories = $categories;
    }

    /**
     * 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
            ]
        );
    }
}
{'fraction_non_alphanumeric': 0.12184331797235023, 'fraction_numerical': 0.00018433179723502304, 'mean_word_length': 1.925067385444744, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 68, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7026581', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1448, 'n_words': 288}