Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace dn\AnkieterBundle\DataFixtures\ORM;
- use Doctrine\Common\DataFixtures\FixtureInterface;
- use dn\AnkieterBundle\Entity\Inquiry;
- use dn\AnkieterBundle\Entity\Question;
- use dn\AnkieterBundle\Entity\Answer;
- class LoadTestInquiryData implements FixtureInterface
- {
- public function load($manager)
- {
- // creating inquiry:
- $inquiry = new Inquiry();
- $inquiry->setName('Testowe badanie');
- $inquiry->setDescription('Jakiś opis badania…');
- $manager->persist($inquiry);
- // creating questions for the inquiry:
- for ($i = 1; $i <= 5; $i++) {
- $question = new Question();
- $question->setPosition($i);
- $question->setContent('Pytanie nr '.$i);
- $question->setInquiry($inquiry);
- $manager->persist($question);
- // creating answers for questions:
- for ($j = 1; $j <= 5; $j++) {
- $answer = new Answer();
- $answer->setPosition($j);
- $answer->setContent('Odpowiedź nr '.$j);
- $answer->setQuestion($question);
- $manager->persist($answer);
- }
- }
- $manager->flush();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement