diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c50725..1397ffa 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 (#16) ## 1.1.0 Alpha 1 (`1010011`) diff --git a/Cli/Command/Seed/SeedProfilePost.php b/Cli/Command/Seed/SeedProfilePost.php new file mode 100644 index 0000000..24740f2 --- /dev/null +++ b/Cli/Command/Seed/SeedProfilePost.php @@ -0,0 +1,18 @@ +finderWithRandomOrder('XF:User')->fetchOne(); + if (!$randomUser) + { + return false; + } + + $faker = $this->faker(); + + $profilePostCreatorSvc = $this->getProfilePostCreatorSvc($randomUser->Profile); + + if ($faker->boolean) + { + $profilePostCreatorSvc->logIp($faker->boolean ? $faker->ipv4 : $faker->ipv6); + } + else + { + $profilePostCreatorSvc->logIp(false); + } + + $profilePostCreatorSvc->setContent($faker->text); + if (!$profilePostCreatorSvc->validate()) + { + return false; + } + + $profilePostCreatorSvc->save(); + + return true; + } + + protected function getProfilePostCreatorSvc(UserProfileEntity $userProfile) : ProfilePostCreatorSvc + { + return $this->service('XF:ProfilePost\Creator', $userProfile); + } +} \ No newline at end of file