/** * Save representative from api in representative storage. * Set link between representative and representative storage * * @param Object $resultApiCollection Object from Cicero API * @param Representative $representative Representative object * * @return District */ protected function updateRepresentativeStorage($resultApiCollection, Representative $representative) { $lastReprDistrict = false; foreach ($resultApiCollection as $repr) { $storRepr = $this->entityManager->getRepository('CivixCoreBundle:RepresentativeStorage')->findOneByStorageId($repr->id); if (!$storRepr) { $storRepr = $this->createStorRepresentativeByApiObj($repr); $this->entityManager->persist($storRepr); } //Update link between representative and representative storage $representative->setStorageId($storRepr->getStorageId()); $lastReprDistrict = $storRepr->getDistrict(); } $this->entityManager->flush(); return $lastReprDistrict; }
public function setStorageId($storageId) { $this->__load(); return parent::setStorageId($storageId); }