Comment::$toNumber type fixed. LoadCommentsData fixed according to new Comment constructor.
This commit is contained in:
parent
5d2ce0fe42
commit
31d49eb270
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue