diff --git a/src/Skobkin/Bundle/PointToolsBundle/DataFixtures/ORM/LoadCommentsData.php b/src/Skobkin/Bundle/PointToolsBundle/DataFixtures/ORM/LoadCommentsData.php index 14b8a40..4ddcc2d 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/DataFixtures/ORM/LoadCommentsData.php +++ b/src/Skobkin/Bundle/PointToolsBundle/DataFixtures/ORM/LoadCommentsData.php @@ -11,7 +11,7 @@ use Skobkin\Bundle\PointToolsBundle\Entity\User; class LoadCommentsData extends AbstractFixture implements OrderedFixtureInterface { - public function load(ObjectManager $om) + public function load(ObjectManager $om): void { /** @var Post $post */ $post = $this->getReference('test_post_longpost'); @@ -25,29 +25,28 @@ class LoadCommentsData extends AbstractFixture implements OrderedFixtureInterfac $this->getReference('test_user_99995'), ]; - $comments = []; + $text = 'Some text with [link to @skobkin-ru site](https://skobk.in/) and `code block`'.PHP_EOL. + 'and some quotation:'.PHP_EOL. + '> test test quote'.PHP_EOL. + 'and some text after'; foreach (range(1, 10000) as $num) { - $comment = (new Comment()) - ->setNumber($num) - ->setDeleted(mt_rand(0, 15) ? false : true) - ->setCreatedAt(new \DateTime()) - ->setAuthor($users[array_rand($users)]) - ->setRec(false) - ->setText( - 'Some text with [link to @skobkin-ru site](https://skobk.in/) and `code block`'.PHP_EOL. - 'and some quotation:'.PHP_EOL. - '> test test quote'.PHP_EOL. - 'and some text after' - ) - ; + $comment = new Comment( + $text, + new \DateTime(), + false, + $post, + $num, + ($num > 1 && !random_int(0, 4)) ? random_int(1, $num - 1) : null, + $users[array_rand($users)], + [] + ); - if (count($comments) > 0 && mt_rand(0, 1)) { - $comment->setParent($comments[mt_rand(0, count($comments) - 1)]); + if (!random_int(0, 15)) { + $comment->delete(); } $post->addComment($comment); - $comments[] = $comment; $om->persist($comment); } diff --git a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Comment.php b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Comment.php index c53f332..b11c7ea 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Comment.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Entity/Blogs/Comment.php @@ -67,7 +67,7 @@ class Comment private $number; /** - * @var int + * @var int|null * * @ORM\Column(name="to_number", type="integer") */ @@ -99,7 +99,7 @@ class Comment bool $rec, Post $post, int $number, - int $toNumber, + ?int $toNumber, User $author, array $files ) { @@ -154,6 +154,11 @@ class Comment return $this->number; } + public function getToNumber(): ?int + { + return $this->toNumber; + } + public function getAuthor(): User { return $this->author;