Skip to content

Commit 088d716

Browse files
oussakaGrafikart
authored andcommitted
fixture data comments and posts
1 parent 4eef911 commit 088d716

File tree

4 files changed

+339
-1
lines changed

4 files changed

+339
-1
lines changed

src/AppBundle/DataFixtures/ORM/LoadCategoryData.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ public function load(ObjectManager $manager)
2323
$category->setPostCount(0);
2424
$manager->persist($category);
2525

26+
$category = new Category();
27+
$category->setName('Test category 3');
28+
$category->setslug('category-3');
29+
$category->setPostCount(0);
30+
$manager->persist($category);
31+
2632
$manager->flush();
2733
}
2834
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
namespace AppBundle\DataFixtures\ORM;
3+
4+
use AppBundle\Entity\Comment;
5+
use Doctrine\Common\Persistence\ObjectManager;
6+
use Doctrine\Common\DataFixtures\AbstractFixture;
7+
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
8+
9+
/**
10+
* Class LoadPostData
11+
* @package AppBundle\DataFixtures\ORM
12+
*/
13+
class LoadCommentData extends AbstractFixture implements OrderedFixtureInterface
14+
{
15+
/**
16+
* Comments to save
17+
*/
18+
private $commentsData = array(
19+
array(
20+
'post' => 'the-route-of-all-evil',
21+
'username' => 'User #1',
22+
'mail' => 'contact@test.fr',
23+
'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vero, laudantium voluptatibus quae doloribus dolorem earum dicta quasi. Fugit, eligendi, voluptatibus corporis deleniti perferendis accusantium totam harum dolor ab veniam laudantium!',
24+
'created' => '2013-09-22 19:45:53',
25+
),
26+
array(
27+
'post' => 'the-route-of-all-evil',
28+
'username' => 'User #2',
29+
'mail' => 'contact@wordpress.com',
30+
'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vero, laudantium voluptatibus quae doloribus dolorem earum dicta quasi. Fugit, eligendi, voluptatibus corporis deleniti perferendis accusantium totam harum dolor ab veniam laudantium!',
31+
'created' => '2013-09-22 19:46:11',
32+
),
33+
array(
34+
'post' => 'the-route-of-all-evil',
35+
'username' => 'User #3',
36+
'mail' => 'contact@lol.fr',
37+
'content' => 'Hi !
38+
This is my first comment !',
39+
'created' => '2013-09-22 20:07:42',
40+
)
41+
);
42+
43+
44+
/**
45+
* {@inheritDoc}
46+
*/
47+
public function load(ObjectManager $manager)
48+
{
49+
// Create comments
50+
foreach ($this->commentsData as $commentData) {
51+
$comment = new Comment();
52+
53+
$post = $manager->getRepository('AppBundle:Post')->findOneBySlug($commentData['post']);
54+
55+
$comment
56+
->setPost($post)
57+
->setUsername($commentData['username'])
58+
->setEmail($commentData['mail'])
59+
->setContent($commentData['content'])
60+
->setCreatedAt(new \DateTime($commentData['created']))
61+
;
62+
63+
$manager->persist($comment);
64+
}
65+
66+
$manager->flush();
67+
}
68+
69+
/**
70+
* {@inheritDoc}
71+
*/
72+
public function getOrder()
73+
{
74+
return 15;
75+
}
76+
}
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
<?php
2+
namespace AppBundle\DataFixtures\ORM;
3+
4+
use AppBundle\Entity\Post;
5+
use Doctrine\Common\Persistence\ObjectManager;
6+
use Doctrine\Common\DataFixtures\AbstractFixture;
7+
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
8+
9+
/**
10+
* Class LoadPostData
11+
* @package AppBundle\DataFixtures\ORM
12+
*/
13+
class LoadPostData extends AbstractFixture implements OrderedFixtureInterface
14+
{
15+
/**
16+
* Posts to save
17+
*/
18+
private $postsData = array(
19+
array(
20+
'category' => 'category-1',
21+
'user' => 'admin',
22+
'name' => 'Space Pilot 3000',
23+
'slug' => 'space-pilot-3000',
24+
'content' => "I don't want to be rescued. So I really am important? How I feel when I'm drunk is correct? Leela's gonna kill me. It's a T. It goes \"tuh\". File not found. She also liked to shut up!
25+
26+
## The Why of Fry
27+
28+
I love this planet! I've got wealth, fame, and access to the depths of sleaze that those things bring. You won't have time for sleeping, soldier, not with all the bed making you'll be doing. Alright, let's mafia things up a bit. Joey, burn down the ship. Clamps, burn down the crew.
29+
30+
* So I really am important? How I feel when I'm drunk is correct?
31+
* No! The cat shelter's on to me.
32+
* No, she'll probably make me do it.
33+
34+
### My Three Suns
35+
36+
OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can. Why yes! Thanks for noticing. Now, now. Perfectly symmetrical violence never solved anything.
37+
38+
#### A Clockwork Origin
39+
40+
You can see how I lived before I met you. Can we have Bender Burgers again? I guess because my parents keep telling me to be more ladylike. As though! Hey! I'm a porno-dealing monster, what do I care what you think? You know, I was God once.
41+
42+
1. You lived before you met me?!
43+
2. They're like sex, except I'm having them!
44+
3. You, a bobsleder!? That I'd like to see!
45+
46+
##### Leela's Homeworld
47+
48+
Yep, I remember. They came in last at the Olympics, then retired to promote alcoholic beverages! Large bet on myself in round one. Actually, that's still true. Ask her how her day was. In your time, yes, but nowadays shut up! Besides, these are adult stemcells, harvested from perfectly healthy adults whom I killed for their stemcells. Why not indeed!",
49+
'created' => '2013-09-22 18:00:00',
50+
),
51+
array(
52+
'category' => 'category-2',
53+
'user' => 'admin',
54+
'name' => 'Rebirth',
55+
'slug' => 'rebirth',
56+
'content' => "Yep, I remember. They came in last at the Olympics, then retired to promote alcoholic beverages! You know, I was God once. That could be 'my' beautiful soul sitting naked on a couch. If I could just learn to play this stupid thing. Okay, I like a challenge. I barely knew Philip, but as a clergyman I have no problem telling his most intimate friends all about him.
57+
58+
## I, Roommate
59+
60+
Now, now. Perfectly symmetrical violence never solved anything. With a warning label this big, you know they gotta be fun! I'm Santa Claus!
61+
62+
* You guys realize you live in a sewer, right?
63+
* Okay, I like a challenge.
64+
* Robot 1-X, save my friends! And Zoidberg!
65+
66+
### Love and Rocket
67+
68+
Can we have Bender Burgers again? This is the worst part. The calm before the battle. For one beautiful night I knew what it was like to be a grandmother. Subjugated, yet honored. You'll have all the Slurm you can drink when you're partying with Slurms McKenzie!
69+
70+
#### War Is the H-Word
71+
72+
You know the worst thing about being a slave? They make you work, but they don't pay you or let you go. Ooh, name it after me! Kids don't turn rotten just from watching TV. You guys aren't Santa! You're not even robots. How dare you lie in front of Jesus?
73+
74+
1. Why yes! Thanks for noticing.
75+
2. You guys aren't Santa! You're not even robots. How dare you lie in front of Jesus?
76+
3. There's no part of that sentence I didn't like!
77+
4. I had more, but you go ahead.
78+
5. Bender, we're trying our best.
79+
80+
##### Anthology of Interest II
81+
82+
Goodbye, cruel world. Goodbye, cruel lamp. Goodbye, cruel velvet drapes, lined with what would appear to be some sort of cruel muslin and the cute little pom-pom curtain pull cords. Cruel though they may be&hellip; It must be wonderful. Leela, are you alright? You got wanged on the head.",
83+
'created' => '2013-09-22 16:49:55',
84+
),
85+
array(
86+
'category' => 'category-3',
87+
'user' => 'admin',
88+
'name' => 'Future Stock',
89+
'slug' => 'future-stock',
90+
'content' => "You, a bobsleder!? That I'd like to see! I barely knew Philip, but as a clergyman I have no problem telling his most intimate friends all about him. Robot 1-X, save my friends! And Zoidberg! You know the worst thing about being a slave? They make you work, but they don't pay you or let you go. OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can. Good news, everyone! There's a report on TV with some very bad news!
91+
92+
## Roswell That Ends Well
93+
94+
Why yes! Thanks for noticing. For the last time, I don't like lilacs! Your 'first' wife was the one who liked lilacs! We'll go deliver this crate like professionals, and then we'll go home.
95+
96+
* Why yes! Thanks for noticing.
97+
* That's the ONLY thing about being a slave.
98+
* OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can.
99+
* It must be wonderful.
100+
101+
### A Tale of Two Santas
102+
103+
This is the worst part. The calm before the battle. There's no part of that sentence I didn't like! Ask her how her day was.
104+
105+
#### Bendless Love
106+
107+
Your best is an idiot! Oh dear! She's stuck in an infinite loop, and he's an idiot! Well, that's love for you. I'm sure those windmills will keep them cool. I had more, but you go ahead. Fry! Stay back! He's too powerful! No, she'll probably make me do it.
108+
109+
1. I barely knew Philip, but as a clergyman I have no problem telling his most intimate friends all about him.
110+
2. Kif might!
111+
3. I barely knew Philip, but as a clergyman I have no problem telling his most intimate friends all about him.
112+
4. Goodbye, cruel world. Goodbye, cruel lamp. Goodbye, cruel velvet drapes, lined with what would appear to be some sort of cruel muslin and the cute little pom-pom curtain pull cords. Cruel though they may be&hellip;
113+
114+
##### The Series Has Landed
115+
116+
Ooh, name it after me! In your time, yes, but nowadays shut up! Besides, these are adult stemcells, harvested from perfectly healthy adults whom I killed for their stemcells. No, of course not. It was&hellip; uh&hellip; porno. Yeah, that's it. So I really am important? How I feel when I'm drunk is correct? I suppose I could part with 'one' and still be feared&hellip; Well I'da done better, but it's plum hard pleading a case while awaiting trial for that there incompetence.",
117+
'created' => '2013-09-22 16:52:52',
118+
),
119+
array(
120+
'category' => 'category-1',
121+
'user' => 'admin',
122+
'name' => 'Parasites Lost',
123+
'slug' => 'parasites-lost',
124+
'content' => "I love this planet! I've got wealth, fame, and access to the depths of sleaze that those things bring. You, minion. Lift my arm. AFTER HIM! I don't want to be rescued. I had more, but you go ahead. I'm Santa Claus! Hey! I'm a porno-dealing monster, what do I care what you think?
125+
126+
## The Deep South
127+
128+
Oh dear! She's stuck in an infinite loop, and he's an idiot! Well, that's love for you. I was having the most wonderful dream. Except you were there, and you were there, and you were there! File not found. Man, I'm sore all over. I feel like I just went ten rounds with mighty Thor. But, like most politicians, he promised more than he could deliver. I guess because my parents keep telling me to be more ladylike. As though!
129+
130+
* They're like sex, except I'm having them!
131+
* You know, I was God once.
132+
* Then we'll go with that data file!
133+
134+
### Devil's Hands are Idle Playthings
135+
136+
Actually, that's still true. No, she'll probably make me do it. Oh, I always feared he might run off like this. Why, why, why didn't I break his legs? WINDMILLS DO NOT WORK THAT WAY! GOOD NIGHT! This is the worst part. The calm before the battle.
137+
138+
#### The Deep South
139+
140+
For the last time, I don't like lilacs! Your 'first' wife was the one who liked lilacs! Pansy. You know, I was God once.
141+
142+
1. You, a bobsleder!? That I'd like to see!
143+
2. Well I'da done better, but it's plum hard pleading a case while awaiting trial for that there incompetence.
144+
145+
##### Bendin' in the Wind
146+
147+
I usually try to keep my sadness pent up inside where it can fester quietly as a mental illness. No, of course not. It was&hellip; uh&hellip; porno. Yeah, that's it. Your best is an idiot! There's no part of that sentence I didn't like! They're like sex, except I'm having them! I had more, but you go ahead.",
148+
'created' => '2013-09-22 16:53:16',
149+
),
150+
array(
151+
'category' => 'category-2',
152+
'user' => 'admin',
153+
'name' => 'The Sting',
154+
'slug' => 'the-sting',
155+
'content' => "Your best is an idiot! Can we have Bender Burgers again? That could be 'my' beautiful soul sitting naked on a couch. If I could just learn to play this stupid thing. You guys realize you live in a sewer, right? Now that the, uh, garbage ball is in space, Doctor, perhaps you can help me with my sexual inhibitions? I love this planet! I've got wealth, fame, and access to the depths of sleaze that those things bring.
156+
157+
## Kif Gets Knocked Up A Notch
158+
159+
Leela, are you alright? You got wanged on the head. Come, Comrade Bender! We must take to the streets! Man, I'm sore all over. I feel like I just went ten rounds with mighty Thor.
160+
161+
* I love this planet! I've got wealth, fame, and access to the depths of sleaze that those things bring.
162+
* OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can.
163+
164+
### Anthology of Interest I
165+
166+
We're rescuing ya. I'm sure those windmills will keep them cool. Oh dear! She's stuck in an infinite loop, and he's an idiot! Well, that's love for you. But I've never been to the moon!
167+
168+
#### Lrrreconcilable Ndndifferences
169+
170+
We'll go deliver this crate like professionals, and then we'll go home. You are the last hope of the universe. Fatal. No! The cat shelter's on to me. Fry! Stay back! He's too powerful! So I really am important? How I feel when I'm drunk is correct?
171+
172+
1. I barely knew Philip, but as a clergyman I have no problem telling his most intimate friends all about him.
173+
2. We can't compete with Mom! Her company is big and evil! Ours is small and neutral!
174+
3. Hello, little man. I will destroy you!
175+
176+
##### Bendless Love
177+
178+
Hello, little man. I will destroy you! Ooh, name it after me! Well I'da done better, but it's plum hard pleading a case while awaiting trial for that there incompetence. You know, I was God once. You won't have time for sleeping, soldier, not with all the bed making you'll be doing. With a warning label this big, you know they gotta be fun!",
179+
'created' => '2013-09-22 16:50:16',
180+
),
181+
array(
182+
'category' => 'category-3',
183+
'user' => 'admin',
184+
'name' => 'The Route of All Evil',
185+
'slug' => 'the-route-of-all-evil',
186+
'content' => "Five hours? Aw, man! Couldn't you just get me the death penalty? Daylight and everything. What's with you kids? Every other day it's food, food, food. Alright, I'll get you some stupid food.
187+
188+
## Bendin' in the Wind
189+
190+
<img src=\"http://lorempicsum.com/futurama/200/150/1\" class=\"img-thumbnail\" style=\"float:left; margin-right:10px;\">
191+
192+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Suscipit, modi, libero, earum, fugiat beatae ipsa quae accusamus eligendi minima eos sint consequuntur voluptate nihil inventore voluptatum? Possimus neque similique quam.
193+
194+
Nemo, aliquam non nulla corporis veritatis molestiae omnis nobis dolores dicta dolorum accusamus porro ipsum rem tempora maxime quisquam accusantium facilis saepe consequatur qui doloribus iusto distinctio perspiciatis modi voluptatum?
195+
196+
Illum temporibus natus cumque recusandae non fugiat quisquam fuga repellendus. Quas, esse, a rem possimus vero sequi fugit non dolor corrupti in similique repudiandae excepturi quidem perspiciatis soluta amet qui?
197+
198+
* Fetal stemcells, aren't those controversial?
199+
* Yes! In your face, Gandhi!
200+
* The key to victory is discipline, and that means a well made bed. You will practice until you can make your bed in your sleep.
201+
202+
### Why Must I Be a Crustacean in Love?
203+
204+
<img src=\"http://lorempicsum.com/futurama/200/150/2\" class=\"img-thumbnail\" style=\"float:right; margin-left:10px;\">
205+
206+
We're rescuing ya. I'm Santa Claus! Have you ever tried just turning off the TV, sitting down with your children, and hitting them? Calculon is gonna kill us and it's all everybody else's fault! I just want to talk. It has nothing to do with mating. Fry, that doesn't make sense. Ummm&hellip;to eBay?
207+
208+
#### Attack of the Killer App
209+
210+
Why would I want to know that? It's toe-tappingly tragic! You won't have time for sleeping, soldier, not with all the bed making you'll be doing. I've got to find a way to escape the horrible ravages of youth. Suddenly, I'm going to the bathroom like clockwork, every three hours. And those jerks at Social Security stopped sending me checks. Now 'I'' have to pay ''them'! I was all of history's great robot actors - Acting Unit 0.8; Thespomat; David Duchovny! Five hours? Aw, man! Couldn't you just get me the death penalty?
211+
212+
1. But, like most politicians, he promised more than he could deliver.
213+
2. Calculon is gonna kill us and it's all everybody else's fault!
214+
3. Bender?! You stole the atom.
215+
216+
##### A Tale of Two Santas
217+
218+
Kif might! I wish! It's a nickel. OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can. Kif, I have mated with a woman. Inform the men. Look, everyone wants to be like Germany, but do we really have the pure strength of 'will'?",
219+
'created' => '2013-09-22 16:42:16',
220+
),
221+
);
222+
223+
/**
224+
* {@inheritDoc}
225+
*/
226+
public function load(ObjectManager $manager)
227+
{
228+
// Create posts
229+
foreach ($this->postsData as $postData) {
230+
$post = new Post();
231+
232+
$category = $manager->getRepository('AppBundle:Category')->findOneBySlug($postData['category']);
233+
$author = $manager->getRepository('AppBundle:User')->findOneByUsername($postData['user']);
234+
235+
$post
236+
->setCategory($category)
237+
->setUser($author)
238+
->setName($postData['name'])
239+
->setSlug($postData['slug'])
240+
->setContent($postData['content'])
241+
->setCreatedAt(new \DateTime($postData['created']))
242+
;
243+
244+
$manager->persist($post);
245+
}
246+
247+
$manager->flush();
248+
}
249+
250+
/**
251+
* {@inheritDoc}
252+
*/
253+
public function getOrder()
254+
{
255+
return 12;
256+
}
257+
}

src/AppBundle/Entity/Category.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ public function getPostCount()
136136
*/
137137
public function __construct()
138138
{
139-
var_dump('constructed Category');
140139
$this->posts = new \Doctrine\Common\Collections\ArrayCollection();
141140
}
142141

0 commit comments

Comments
 (0)