private function BuildLocEntity($country, $cntryName, $em)
 {
     $entity = new Location();
     $entity->setDescription($cntryName);
     $entity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6')));
     //Sarah
     $entity->setLocationType($em->getRepository('AppBundle:LocationType')->findOneBy(array('id' => 2)));
     $parentDesc = $country->getRegion()->getDescription();
     $parent = $em->getRepository('AppBundle:Location')->findOneBy(array('description' => $parentDesc));
     $entity->setParentLoc($parent);
     $childLocs = $country->getLocations();
     foreach ($childLocs as $loc) {
         $entity->addChildLocs($loc);
     }
     $em->persist($entity);
     $em->flush();
 }
 private function buildLocEntity($region, $regionName, $parent, $em)
 {
     $entity = new Location();
     $regionName = $regionName ?: $region->getDescription();
     $entity->setDescription($regionName);
     $entity->setCreatedBy($em->getRepository('AppBundle:User')->findOneBy(array('id' => '6')));
     $entity->setLocationType($em->getRepository('AppBundle:LocationType')->findOneBy(array('id' => 1)));
     $childLocs = $region->getLocations();
     foreach ($childLocs as $loc) {
         $entity->addChildLocs($loc);
     }
     if ($parent !== null) {
         $entity->setParentLoc($parent);
     }
     $em->persist($entity);
     $em->flush();
 }
示例#3
0
 /**
  * Add childLoc.
  *
  * @param \AppBundle\Entity\Location $childLoc
  *
  * @return Location
  */
 public function addChildLocs(\AppBundle\Entity\Location $childLoc)
 {
     $this->childLocs[] = $childLoc;
     $childLoc->setParentLoc($this);
     return $this;
 }