diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c50725..0737875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ CHANGELOG - **New:** Seed for media gallery item reaction (#13) - **New:** Seed for media gallery comment reaction (#14) - **New:** Seed for media gallery album reaction (#15) +- **New:** Seed for profile post comment (#17) ## 1.1.0 Alpha 1 (`1010011`) diff --git a/Cli/Command/Seed/SeedProfilePostComment.php b/Cli/Command/Seed/SeedProfilePostComment.php new file mode 100644 index 0000000..7caa0a7 --- /dev/null +++ b/Cli/Command/Seed/SeedProfilePostComment.php @@ -0,0 +1,18 @@ +finderWithRandomOrder('XF:ProfilePost')->fetchOne(); + if (!$randomProfilePost) + { + return false; + } + + $faker = $this->faker(); + + $profilePostCommentCreatorSvc = $this->getProfileProfileCommentCreator($randomProfilePost); + + if ($faker->boolean) + { + $profilePostCommentCreatorSvc->logIp($faker->boolean ? $faker->ipv6 : $faker->ipv4); + } + else + { + $profilePostCommentCreatorSvc->logIp(false); + } + + $profilePostCommentCreatorSvc->setContent($faker->text); + + if (!$profilePostCommentCreatorSvc->validate()) + { + return false; + } + + $profilePostCommentCreatorSvc->save(); + + return true; + } + + protected function getProfileProfileCommentCreator(ProfilePostEntity $profilePost) : ProfilePostCommentCreatorSvc + { + return $this->service('XF:ProfilePostComment\Creator', $profilePost); + } +} \ No newline at end of file