public function loadFruits($manager)
 {
     $names = ['apple', 'apricot', 'banana', 'blackberry', 'cassis', 'cherry', 'red grapes', 'green grapes', 'lemon', 'orange', 'yellow pear', 'green pear', 'plum', 'raspberry', 'strawberry', 'watermelon'];
     $img = ['apple.jpg', 'apricot.jpg', 'banana.jpg', 'blackberry.jpg', 'cassis.jpg', 'cherry.jpg', 'red-grapes.jpg', 'green-grapes.jpg', 'lemon.jpg', 'orange.jpg', 'yellow-pear.jpg', 'green-pear.jpg', 'plum.jpg', 'raspberry.jpg', 'strawberry.jpg', 'watermelon.jpg'];
     $memory = new Memory();
     $memory->setTopic("fruits");
     $memory->setDescription("discover our fruits");
     $author = $this->getReference('user.super_admin');
     $memory->setAuthor($author);
     $manager->persist($memory);
     $manager->flush();
     foreach ($names as $key => $value) {
         $memoryItem = new MemoryItem();
         $memoryItem->setName($names[$key]);
         $memoryItem->setImg($img[$key]);
         $memoryItem->setTopic($memory);
         $manager->persist($memoryItem);
         $manager->flush();
     }
     $this->addReference('ex.memory', $memory);
 }
Beispiel #2
0
 /**
  * Add item
  *
  * @param \TNCY\SchoolBundle\Entity\MemoryItem $item
  *
  * @return Memory
  */
 public function addItem(\TNCY\SchoolBundle\Entity\MemoryItem $item)
 {
     $this->items[] = $item;
     $item->setTopic($this);
     return $this;
 }