From 0ab61fb8efead1a5b78cae30999b9aadde1df039 Mon Sep 17 00:00:00 2001 From: ticktackk Date: Wed, 10 Mar 2021 15:57:11 +0530 Subject: [PATCH] closes #52 --- CHANGELOG.md | 1 + Cli/Command/Seed/SeedThreadPrefixGroup.php | 21 ++++++++ Seed/AbstractContentPrefixGroup.php | 58 ++++++++++++++++++++++ Seed/ThreadPrefixGroup.php | 14 ++++++ 4 files changed, 94 insertions(+) create mode 100644 Cli/Command/Seed/SeedThreadPrefixGroup.php create mode 100644 Seed/AbstractContentPrefixGroup.php create mode 100644 Seed/ThreadPrefixGroup.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 50d0f0c..b49e2fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG - **New:** Seed for thread prefix (#50) - **New:** Seed for resource prefix (#51) +- **New:** Seed for thread prefix group (#52) ## 1.1.0 Alpha 4 (`1010014`) diff --git a/Cli/Command/Seed/SeedThreadPrefixGroup.php b/Cli/Command/Seed/SeedThreadPrefixGroup.php new file mode 100644 index 0000000..03380c8 --- /dev/null +++ b/Cli/Command/Seed/SeedThreadPrefixGroup.php @@ -0,0 +1,21 @@ +em()->create($this->getClassIdentifier()); + } + + protected function getInput() : array + { + return [ + 'display_order' => $this->faker()->randomNumber() + ]; + } + + /** + * @param array $params + * + * @return bool + * + * @throws \XF\PrintableException + */ + protected function seed(array $params = []): bool + { + $formAction = $this->formAction(); + $prefixGroup = $this->getEntity(); + + $formAction->basicEntitySave($prefixGroup, $this->getInput()); + + $formAction->apply(function() use ($prefixGroup) + { + $phrase = $prefixGroup->getMasterPhrase(); + $phrase->phrase_text = $this->faker()->words(3, true); + $phrase->save(); + }); + + if (!$formAction->run(false)) + { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/Seed/ThreadPrefixGroup.php b/Seed/ThreadPrefixGroup.php new file mode 100644 index 0000000..9bc77a1 --- /dev/null +++ b/Seed/ThreadPrefixGroup.php @@ -0,0 +1,14 @@ +