/**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $picture = new Picture();
     $this->copyPicture($name = 'lorempixel-1');
     $picture->setFile($this->getUploadedFile($name));
     $picture->setPosition(1);
     $picture->setPost($this->getReference('post-1'));
     $manager->persist($picture);
     $this->setReference('picture-1', $picture);
     $picture = new Picture();
     $this->copyPicture($name = 'lorempixel-2');
     $picture->setFile($this->getUploadedFile($name));
     $picture->setPosition(2);
     $picture->setPost($this->getReference('post-1'));
     $manager->persist($picture);
     $this->setReference('picture-2', $picture);
     $picture = new Picture();
     $this->copyPicture($name = 'lorempixel-3');
     $picture->setFile($this->getUploadedFile($name));
     $picture->setPosition(3);
     $picture->setPost($this->getReference('post-1'));
     $manager->persist($picture);
     $this->setReference('picture-3', $picture);
     $picture = new Picture();
     $this->copyPicture($name = 'lorempixel-4');
     $picture->setFile($this->getUploadedFile($name));
     $picture->setPosition(1);
     $picture->setPost($this->getReference('post-2'));
     $manager->persist($picture);
     $this->setReference('picture-4', $picture);
     $picture = new Picture();
     $this->copyPicture($name = 'lorempixel-5');
     $picture->setFile($this->getUploadedFile($name));
     $picture->setPosition(1);
     $picture->setPost($this->getReference('post-3'));
     $manager->persist($picture);
     $this->setReference('picture-5', $picture);
     $picture = new Picture();
     $this->copyPicture($name = 'lorempixel-6');
     $picture->setFile($this->getUploadedFile($name));
     $picture->setPosition(1);
     $picture->setPost($this->getReference('post-4'));
     $manager->persist($picture);
     $this->setReference('picture-6', $picture);
     $manager->flush();
 }
Exemple #2
0
 /**
  * Add picture
  *
  * @param \AppBundle\Entity\Picture $picture
  *
  * @return Post
  */
 public function addPicture(\AppBundle\Entity\Picture $picture)
 {
     $picture->setPost($this);
     $this->pictures->add($picture);
     return $this;
 }