public function approveRepresentative(Representative $representative) { $representative->setStatus(Representative::STATUS_ACTIVE); //find in current representative storage $reprStorageObj = $this->entityManager->getRepository('CivixCoreBundle:RepresentativeStorage')->getSTRepresentativeByOfficialInfo($representative->getFirstName(), $representative->getLastName(), $representative->getOfficialTitle()); if (!$reprStorageObj) { //update database from api $district = $this->ciceroService->updateByRepresentativeInfo($representative); //if no representative in cicero api if (!$district) { //try to get info by address $districts = $this->ciceroService->getRepresentativeByLocation($representative->getOfficialAddress(), $representative->getCity(), $representative->getState()->getCode(), $representative->getCountry(), true); if (!empty($districts)) { $district = array_shift($districts); $representative->setIsNonLegislative(1); } else { return false; } } $representative->setDistrict($district); } else { $representative->setDistrict($reprStorageObj->getDistrict()); $representative->setStorageId($reprStorageObj->getStorageId()); } return $representative; }
public function setStatus($status) { $this->__load(); return parent::setStatus($status); }