Fixtures
parent
0d06b360ab
commit
ed54b5a656
|
@ -35,6 +35,7 @@ class AppFixtures extends Fixture
|
|||
foreach ($this->getData() as $data) {
|
||||
$question = new Question();
|
||||
$question->setText($data['text']);
|
||||
$question->setSticker($this->getRandomSticker());
|
||||
$manager->persist($question);
|
||||
|
||||
foreach ($data['responses'] as $response) {
|
||||
|
@ -78,4 +79,20 @@ class AppFixtures extends Fixture
|
|||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function getStickersData()
|
||||
{
|
||||
return [
|
||||
'http://image.noelshack.com/fichiers/2017/30/4/1501188178-jesusbestreup.png',
|
||||
];
|
||||
}
|
||||
|
||||
private function getRandomSticker(): string
|
||||
{
|
||||
$stickers = $this->getStickersData();
|
||||
shuffle($stickers);
|
||||
$selectedSticker = array_slice($stickers, 0, 1);
|
||||
|
||||
return array_shift($selectedSticker);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue