From 464da439dcff9bd335b9092824e4f98da5e4eb84 Mon Sep 17 00:00:00 2001 From: ticktackk Date: Wed, 26 Aug 2020 07:54:03 +0530 Subject: [PATCH] closes #17 --- CHANGELOG.md | 1 + Cli/Command/Seed/SeedProfilePostComment.php | 18 ++++++++ Seed/ProfilePostComment.php | 50 +++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 Cli/Command/Seed/SeedProfilePostComment.php create mode 100644 Seed/ProfilePostComment.php 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