private function buildSourceEntity(&$authEntity, &$em) { $srcEntity = new Source(); $srcEntity->setDisplayName($authEntity->getFullName()); $srcEntity->setSourceType($em->getRepository('AppBundle:SourceType')->findOneBy(array('id' => 3))); $srcEntity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6'))); $authEntity->setSource($srcEntity); $authEntity->setUpdatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6'))); $em->persist($srcEntity); $em->persist($authEntity); $em->flush(); }
/** * @Route("/sources.json", name="sources_new") * @Method("POST") */ public function newAction(Request $request) { $name = $request->get('name'); $repeated = $this->getDoctrine()->getRepository('AppBundle:Source')->findOneByName($name); if (!$repeated) { if (!empty($name)) { $source = new Source(); $source->setName($name); $source->setAmount(0); $this->getDoctrine()->getManager()->persist($source); $this->getDoctrine()->getManager()->flush(); return new JsonResponse(['status' => true, 'message' => 'Origen creado']); } } else { return new JsonResponse(['status' => false, 'message' => 'El origen ya existe']); } return new JsonResponse(); }
private function buildSrcEntity(&$citEntity, &$em) { $srcEntity = new Source(); $srcEntity->setDisplayName($citEntity->getTitle()); $srcEntity->setDescription($citEntity->getFullText()); $srcEntity->setYear($citEntity->getYear()); $srcEntity->setIsCitation(true); $srcEntity->setSourceType($em->getRepository('AppBundle:SourceType')->findOneBy(array('id' => 2))); $srcEntity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6'))); $this->transferInteractions($citEntity, $srcEntity, $em); //print("\n Interaction-- records transfered to new Source citation."); $this->transferAuthors($citEntity, $srcEntity, $em); //print("\n Authors-- contributed to the new Source citation."); $em->persist($srcEntity); return $srcEntity; }
private function addSrcEntity($sourceType, $valAry, &$pubEntity, &$em) { $srcFields = ["Year", "Doi", "ParentSource", "LinkUrl", "DisplayName", "Description", "Author"]; $srcEntity = new Source(); $srcEntity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6'))); /** Adds values from the pubEntity that I didn't want to copy into the pub's source array. */ if ($sourceType === "publication") { $srcEntity->setDisplayName($pubEntity->getDisplayName()); $srcEntity->setDescription($pubEntity->getDescription()); $srcEntity->setSourceType($em->getRepository("AppBundle:SourceType")->findOneBy(array('id' => 2))); $pubEntity->setSource($srcEntity); $em->persist($pubEntity); } else { //Publisher $srcEntity->setSourceType($em->getRepository("AppBundle:SourceType")->findOneBy(array('id' => 1))); } for ($i = 0; $i < count($valAry); $i++) { print "\n field = " . $srcFields[$i] . " val = " . $valAry[$i]; if ($i === 2 && $valAry[$i] !== null) { $this->addParentSource($valAry[$i], $srcEntity, $em); } else { if ($i === 6) { $this->addContributor($valAry[$i], $srcEntity, $em); } else { if ($valAry[$i] !== null) { print "\n setting->" . $srcFields[$i]; $setField = "set" . $srcFields[$i]; $srcEntity->{$setField}($valAry[$i]); } } } } $em->persist($srcEntity); $em->persist($pubEntity); $em->flush(); }
/** * Set source. * * @param \AppBundle\Entity\Source $source * * @return Currency */ public function setSource(Source $source = null) { $this->source = $source; $source->addCurrency($this); return $this; }
/** * * {@inheritDoc} */ public function load(ObjectManager $manager) { $rate = new Rating(); $rate->setText("When bad is really bad"); $manager->persist($rate); $rate = new Rating(); $rate->setText("Better than network TV"); $manager->persist($rate); $rate = new Rating(); $rate->setText("Laughs here and there"); $manager->persist($rate); $rate = new Rating(); $rate->setText("Borderline genius"); $manager->persist($rate); $rate = new Rating(); $rate->setText("Sublime in every way"); $manager->persist($rate); $manager->flush(); // --------------------------------------------- $s = new Source(); $s->setName("MST3K"); $manager->persist($s); $s = new Source(); $s->setName("RiffTrax"); $manager->persist($s); $manager->flush(); // --------------------------------------------- $s1 = $manager->find('\\AppBundle\\Entity\\Source', 1); $s2 = $manager->find('\\AppBundle\\Entity\\Source', 2); $r = new Riff(); $r->setTitle('Catalina Caper'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 4)); $manager->persist($r); $r = new Riff(); $r->setTitle('The Amazing Colossal Man'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 4)); $manager->persist($r); $r = new Riff(); $r->setTitle('Daddy-O'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 3)); $manager->persist($r); $r = new Riff(); $r->setTitle('Pod People'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 4)); $manager->persist($r); $r = new Riff(); $r->setTitle('Mitchell'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 5)); $manager->persist($r); $r = new Riff(); $r->setTitle('Cave Dwellers'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 3)); $manager->persist($r); $r = new Riff(); $r->setTitle('Being from Another Planet'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 4)); $manager->persist($r); $r = new Riff(); $r->setTitle('Stranded in Space'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 5)); $manager->persist($r); $r = new Riff(); $r->setTitle('Time of the Apes'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 1)); $manager->persist($r); $r = new Riff(); $r->setTitle('Gamera vs. Gaos'); $r->setSource($s1); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 4)); $manager->persist($r); $r = new Riff(); $r->setTitle('Radical Jack'); $r->setSource($s2); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 5)); $manager->persist($r); $r = new Riff(); $r->setTitle('Planet of the Dinosaurs'); $r->setSource($s2); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 5)); $manager->persist($r); $r = new Riff(); $r->setTitle('The Incredible 2 Headed Transplant'); $r->setSource($s2); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 5)); $manager->persist($r); $r = new Riff(); $r->setTitle('Hawk the Slayer'); $r->setSource($s2); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 3)); $manager->persist($r); $r = new Riff(); $r->setTitle('DinoSaurus'); $r->setSource($s2); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 2)); $manager->persist($r); $r = new Riff(); $r->setTitle('The City of the Dead'); $r->setSource($s2); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 3)); $manager->persist($r); $r = new Riff(); $r->setTitle('The Last Slumber Party'); $r->setSource($s2); $r->setRating($manager->find('\\AppBundle\\Entity\\Rating', 3)); $manager->persist($r); $manager->flush(); }
protected function createSource($sourceShortName, $remoteUrl) { $source = new Source(); $source->setShortCode($sourceShortName)->setUrl($remoteUrl); return $source; }
/** * Add child Source. * * @param \AppBundle\Entity\Source $childSource * * @return Source */ public function addChildSource(\AppBundle\Entity\Source $childSource) { $this->childSources[] = $childSource; $childSource->setParentSource($this); return $this; }