-
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
4 changed files
with
94 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,21 @@ | ||
<?php | ||
|
||
namespace TickTackk\Seeder\Cli\Command\Seed; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
|
||
/** | ||
* @since 1.1.0 Release Candidate 1 | ||
*/ | ||
class SeedThreadPrefixGroup extends AbstractSeedCommand | ||
{ | ||
protected function getSeedName() : string | ||
{ | ||
return 'thread-prefix-group'; | ||
} | ||
|
||
protected function getContentTypePlural(InputInterface $input = null) : string | ||
{ | ||
return 'Thread prefix groups'; | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
|
||
namespace TickTackk\Seeder\Seed; | ||
|
||
use XF\Mvc\Entity\Entity; | ||
use XF\Entity\AbstractPrefixGroup as AbstractPrefixGroupEntity; | ||
|
||
/** | ||
* @since 1.1.0 Release Candidate 1 | ||
*/ | ||
abstract class AbstractContentPrefixGroup extends AbstractSeed | ||
{ | ||
abstract protected function getClassIdentifier() : string; | ||
|
||
/** | ||
* @return Entity|AbstractPrefixGroupEntity | ||
*/ | ||
protected function getEntity() : AbstractPrefixGroupEntity | ||
{ | ||
return $this->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; | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
|
||
namespace TickTackk\Seeder\Seed; | ||
|
||
/** | ||
* @since 1.1.0 Release Candidate 1 | ||
*/ | ||
class ThreadPrefixGroup extends AbstractContentPrefixGroup | ||
{ | ||
protected function getClassIdentifier(): string | ||
{ | ||
return 'XF:ThreadPrefixGroup'; | ||
} | ||
} |