コード例 #1
0
 /** Moves each author for this citation to it's new source entity.  */
 private function transferAuthors(&$citEntity, &$srcEntity, &$em)
 {
     $attributions = $citEntity->getAttributions();
     foreach ($attributions as $attribution) {
         $contribEntity = new Contribution();
         $contribEntity->setAuthorSource($attribution->getAuthor()->getSource());
         $contribEntity->setWorkSource($srcEntity);
         $contribEntity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6')));
         $em->persist($contribEntity);
     }
 }
コード例 #2
0
 private function addContributor($authors, &$srcEntity, &$em)
 {
     print "    addContributor ->";
     foreach ($authors as $authId) {
         $contribEntity = new Contribution();
         $author = $em->getRepository('AppBundle:Author')->findOneBy(array('id' => $authId));
         $contribEntity->setAuthorSource($author->getSource());
         $contribEntity->setWorkSource($srcEntity);
         $contribEntity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6')));
         $em->persist($contribEntity);
     }
 }
コード例 #3
0
 /**
  * Adds any new attributions from the citation entity as new contributions of 
  * the source entity.
  */
 private function transferAuthors(&$citEntity, &$srcEntity, &$em)
 {
     $attribs = $citEntity->getAttributions();
     $contribs = $srcEntity->getContributors();
     print "\n   --existing contributions for source " . $srcEntity->getId() . " = " . count($contribs);
     foreach ($attribs as $attribution) {
         $attribAuthSrc = $attribution->getAuthor()->getSource();
         $attribAuthSrcId = $attribAuthSrc->getAuthor()->getId();
         print "\n    attribAuthSrcId = " . $attribAuthSrcId;
         /* All authors source's have been created. These can thus be checked for redundancy. */
         foreach ($contribs as $contrib) {
             $contribAuthSrcId = $contrib->getAuthorSource()->getAuthor()->getId();
             print "\n        contribAuthSrcId = " . $contribAuthSrcId;
             /* Returns if this author has already been added as a contributor. */
             if ($contribAuthSrcId === $attribAuthSrcId) {
                 print "\n---skipping\n";
                 break 2;
             }
         }
         $contribEntity = new Contribution();
         $contribEntity->setAuthorSource($attribAuthSrc);
         $contribEntity->setWorkSource($srcEntity);
         $contribEntity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6')));
         $em->persist($contribEntity);
     }
 }