pull/13/head
root 2018-06-05 18:40:31 +02:00
parent 0d06b360ab
commit ed54b5a656
1 changed files with 17 additions and 0 deletions

View File

@ -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);
}
}