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();
 }
 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();
 }