/**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     $rep = $this->em->getRepository('AnimeDbCatalogBundle:Studio');
     // rename studios
     /* @var $studio Studio */
     foreach ($this->rename as $from => $to) {
         $studio = $rep->findOneBy(['name' => $from]);
         $studio->setName($to);
         $this->em->persist($studio);
     }
     // add new studios
     foreach ($this->add as $name) {
         $studio = new Studio();
         $studio->setName($name);
         $this->em->persist($studio);
     }
     $this->em->flush();
 }
Example #2
0
 /**
  * @param Studio $studio
  *
  * @return Item
  */
 public function setStudio(Studio $studio = null)
 {
     if ($this->studio !== $studio) {
         // romove link on this item for old studio
         if ($this->studio instanceof Studio) {
             $tmp = $this->studio;
             $this->studio = null;
             $tmp->removeItem($this);
         }
         $this->studio = $studio;
         // add link on this item
         if ($this->studio instanceof Studio) {
             $this->studio->addItem($this);
         }
     }
     return $this;
 }