-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace TickTackk\Seeder\Cli\Command\Seed; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
|
||
class SeedProfilePostComment extends AbstractSeedCommand | ||
{ | ||
protected function getSeedName() : string | ||
{ | ||
return 'profile-post-comment'; | ||
} | ||
|
||
protected function getContentTypePlural(InputInterface $input = null) : string | ||
{ | ||
return 'Profile post comments'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace TickTackk\Seeder\Seed; | ||
|
||
use XF\Entity\ProfilePost as ProfilePostEntity; | ||
use XF\Service\ProfilePostComment\Creator as ProfilePostCommentCreatorSvc; | ||
use XF\Repository\ThreadWatch as ThreadWatchRepo; | ||
use XF\Service\Thread\Replier as ThreadReplierSvc; | ||
|
||
class ProfilePostComment extends AbstractSeed | ||
{ | ||
protected function seed(array $params = []): bool | ||
{ | ||
/** @var ProfilePostEntity $randomProfilePost */ | ||
$randomProfilePost = $this->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); | ||
} | ||
} |