本文整理汇总了PHP中Entity::addAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::addAddress方法的具体用法?PHP Entity::addAddress怎么用?PHP Entity::addAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::addAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
public function import($school)
{
if (EntityTable::getByExtensionQuery('Org')->addWhere('LOWER(org.name) LIKE ?', '%' . strtolower($school->instnm) . "%")->fetchOne()) {
$this->printDebug("School exists in database: " . $school->instnm);
} else {
$address = new Address();
$address->street1 = isset($school->addr) ? $school->addr : null;
$address->street2 = isset($school->street2) ? $school->street2 : null;
$address->city = $school->city;
if ($state = AddressStateTable::retrieveByText($school->stabbr)) {
$address->State = $state;
}
$address->postal = $school->zip;
$aliases = explode("|", $school->ialias);
$website = null;
if (!preg_match('/^http\\:\\/\\//i', trim($school->webaddr))) {
$website = "http://" . strtolower($school->webaddr);
}
$this->printDebug($website);
$newschool = new Entity();
$newschool->addExtension('Org');
$newschool->addExtension('School');
$newschool->name = $school->instnm;
$newschool->website = $website;
$newschool->addAddress($address);
$newschool->save();
foreach ($aliases as $alias) {
try {
$newalias = new Alias();
$newalias->Entity = $newschool;
$newalias->name = $alias;
$newalias->save();
} catch (Exception $e) {
$this->printDebug("An alias exception. No biggie. It's most likely that the name already exists. so we ignore it and move on: " . $e);
}
}
$this->printDebug("Adding new school: " . $school->instnm);
}
}
示例2: import
//.........这里部分代码省略.........
} elseif ($this->year > 2004 && preg_match('/<blockquote class="spaced">(.*)<\\/blockquote>/ismU', $text, $match)) {
$summary = str_replace(array(' ', "\n"), array(' ', ' '), html_entity_decode(trim(strip_tags($match[1]))));
}
//get revenue
if ($this->year > 1995 && $this->year < 2000 && preg_match('/<td class="mainlisttxt">\\$([\\S]+) mil<sup>e?<\\/sup><\\/td>/ismU', $text, $match)) {
$this->printDebug($match[1]);
$revenue = str_replace(",", "", $match[1] . ",000,000");
} elseif ($this->year > 1999 && $this->year < 2005 && preg_match('/<td class="mainlisttxt" nowrap>([^<]+)<sup>e?<\\/sup><\\/td>/ismU', $text, $match)) {
$this->printDebug($match[1]);
$revenue = str_replace(",", "", $match[1] . ",000,000");
} elseif ($this->year > 2004 && preg_match('/<td class="highlight" nowrap="nowrap">\\$([\\S]+) bil.*<\\/td> <td class="highlight" nowrap="nowrap">[^<]+<\\/td> <td class="highlight" nowrap="nowrap">([^<]+)<\\/td>/ismU', $text, $match)) {
$revenue = 1000000000 * $match[1];
}
//get employees
if ($this->year > 1995 && $this->year < 2005 && preg_match('/mil<\\/td>.+<td class="mainlisttxt"( nowrap)?>(\\d[^<]+)<\\/td>.+<td class="mainlisttxt">[a-zA-Z]+<\\/td>/ismU', $text, $match)) {
$employees = str_replace(',', '', $match[2]);
} elseif ($this->year > 1999 && $this->year < 2005 && preg_match('/<sup>e?<\\/sup><\\/td> <td class="mainlisttxt"( nowrap)?>(\\d[^<]+)<sup>e?<\\/sup><\\/td> <td class="mainlisttxt">[a-zA-Z]+<\\/td>/ismU', $text, $match)) {
$employees = str_replace(',', '', $match[2]);
} elseif ($this->year > 2004 && preg_match('/<td class="highlight" nowrap="nowrap">([\\d,]+)<\\/td> <td class="highlight" nowrap="nowrap">[A-Z][a-z]{2,}<\\/td>/', $text, $match)) {
$employees = str_replace(',', '', $match[1]);
}
/*$this->printDebug( "URL: ". $url);
$this->printDebug( "Rank: " . $rank );
$this->printDebug( "Name: " . $name );
$this->printDebug( "Industry: " . $industryName );
$this->printDebug( "Street: " . $street1 );
$this->printDebug( "Street2: " . $street2 );
$this->printDebug( "City: " . $city );
$this->printDebug( "State: " . $state );
$this->printDebug( "Postal: " . $postal );
$this->printDebug( "Phone: " . $phone );
$this->printDebug( "Fax: " . $fax );
$this->printDebug( "Website: " . $website );
$this->printDebug( "CEO: " . $ceoName . " " . $ceoBirthYear);
$this->printDebug( "Summary: " . $summary );
$this->printDebug( "Revenue: " . $revenue );
$this->printDebug( "Employees: " . $employees );*/
$search_company_name = trim(implode(' ', array_diff(explode(' ', ucwords(strtolower($name))), array_merge(LsLanguage::$business, LsLanguage::$businessAbbreviations))));
//continue;
$this->printDebug("{$search_company_name} == {$name}");
if ($company = EntityTable::getByExtensionQuery(array('Org', 'PrivateCompany'))->addWhere("LOWER(REPLACE( org.name, '-' , '')) = ?", strtolower($name))->fetchOne()) {
$this->printDebug("Company exists");
$company->revenue = $revenue;
$company->save();
} else {
$this->printDebug("Creating new company {$name}");
Doctrine::getTable('ExtensionDefinition')->clear();
$company = new Entity();
$company->addExtension('Org');
$company->addExtension('Business');
$company->addExtension('PrivateCompany');
$company->name = LsLanguage::titleize($name);
$company->employees = strlen($employees) ? $employees : null;
$company->revenue = strlen($revenue) ? $revenue : null;
$company->website = strlen($website) ? $website : null;
$company->summary = strlen($summary) ? trim($summary) : null;
//add address
if ($phone) {
$company->addPhone($phone);
}
if ($fax) {
//$company->addPhone($fax);
}
if ($city && $state) {
$address = new Address();
$address->street1 = strlen($street1) ? $street1 : null;
$address->street2 = strlen($street2) ? $street2 : null;
$address->city = strlen($city) ? $city : null;
if ($state = AddressStateTable::retrieveByText($state)) {
$address->State = $state;
}
$address->postal = $postal;
$company->addAddress($address);
$address->save();
$address->addReference($source = $url, $excerpt = null, $fields = array('city', 'country_id', 'postal', 'state_id', 'street1'), $name = 'Forbes.com', $detail = null, $date = null);
}
}
/*$this->printDebug( "URL: ". $url);
$this->printDebug( "Rank: " . $rank );
$this->printDebug( "Name: " . $name );
$this->printDebug( "Industry: " . $industryName );
$this->printDebug( "Street: " . $street1 );
$this->printDebug( "Street2: " . $street2 );
$this->printDebug( "City: " . $city );
$this->printDebug( "State: " . $state );
$this->printDebug( "Postal: " . $postal );
$this->printDebug( "Phone: " . $phone );
$this->printDebug( "Fax: " . $fax );
$this->printDebug( "Website: " . $website );
$this->printDebug( "CEO: " . $ceoName . " " . $ceoBirthYear);
$this->printDebug( "Summary: " . $summary );
$this->printDebug( "Revenue: " . $revenue );
$this->printDebug( "Employees: " . $employees );*/
$company->save();
$company->addReference($source = $url, $excerpt = null, $fields = array('website', 'name', 'website', 'summary', 'revenue', 'employees'), $name = 'Forbes.com', $detail = null, $date = null);
$this->saveToList($company, $rank);
} else {
$this->printDebug("Couldn't get company: " . $url);
}
}
示例3: importFiling
//.........这里部分代码省略.........
$lobbying_entity = $existing_lobbyist_registrant;
$this->printDebug('Existing lobbyist is lobbying entity: ' . $lobbying_entity->name);
} else {
$lobbyist = $this->prepLobbyistName($lda_lobbyists[0]->name);
if ($lobbyist) {
$lobbyist->lda_registrant_id = $lda_registrant->federal_registrant_id;
$lobbyist->save();
$lobbyist->addReference(self::$filing_url . $lda_filing->federal_filing_id, null, $lobbyist->getAllModifiedFields(), 'LDA Filing', null, $date, false);
$this->printDebug('New lobbyist/lobbying entity saved: ' . $lobbyist->name);
$lobbying_entity = $lobbyist;
}
}
} else {
if ($existing_firm = EntityTable::getByExtensionQuery('Org')->addWhere('org.lda_registrant_id = ? ', $lda_registrant->federal_registrant_id)->execute()->getFirst()) {
$modified = array();
$lobbying_entity = $existing_firm;
if ($lda_registrant->description) {
$description = trim($lda_registrant->description);
if ($description != '' && preg_match('/[\\/\\-]\\d+[\\/\\-]/isu', $description) == 0) {
if (strlen($description) < 200) {
if (!$existing_firm->blurb || $existing_firm->blurb == '') {
$existing_firm->blurb = $description;
$modified[] = 'blurb';
}
} else {
if (!$existing_firm->summary || $existing_firm->summary == '') {
$existing_firm->summary = $description;
$modified[] = 'summary';
}
}
}
}
if ($lda_registrant->address && $lda_registrant->address != '' && count($existing_firm->Address) == 0) {
if ($address = $existing_firm->addAddress($lda_registrant->address)) {
$existing_firm->save();
$address->addReference(self::$filing_url . $lda_filing->federal_filing_id, null, $address->getAllModifiedFields(), 'LDA Filing', null, $date, false);
}
}
$existing_firm->save();
if (count($modified)) {
$existing_firm->addReference(self::$filing_url . $lda_filing->federal_filing_id, null, $modified, 'LDA Filing', null, $date, false);
}
$this->printDebug('Existing firm is lobbying entity: ' . $lobbying_entity->name);
} else {
$firm = new Entity();
$firm->addExtension('Org');
$firm->addExtension('Business');
$firm->addExtension('LobbyingFirm');
$firm->name = LsLanguage::titleize(OrgTable::stripNamePunctuation($lda_registrant->name), true);
$firm->lda_registrant_id = $lda_registrant->federal_registrant_id;
if ($lda_registrant->description) {
$description = trim($lda_registrant->description);
if ($description != '' && preg_match('/[\\/\\-]\\d+[\\/\\-]/isu', $description) == 0) {
if (strlen($description) < 200) {
$firm->blurb = $description;
} else {
$firm->summary = $description;
}
}
}
if ($lda_registrant->address && $lda_registrant->address != '') {
if ($address = $firm->addAddress($lda_registrant->address)) {
$firm->save();
$address->addReference(self::$filing_url . $lda_filing->federal_filing_id, null, $address->getAllModifiedFields(), 'LDA Filing', null, $date, false);
}
}
示例4: importCompany
private function importCompany($name, $ticker, $website, $address_raw, $telephone, $revenue, $url, $industry)
{
$corp = new Entity();
$corp->addExtension('Org');
$corp->addExtension('Business');
if ($ticker) {
$corp->addExtension('PublicCompany');
$corp->ticker = $ticker;
} else {
$corp->addExtension('PrivateCompany');
}
$corp->name = $name;
$corp->revenue = LsNumber::formatDollarAmountAsNumber($revenue, 1000000);
$corp->website = $website;
$modified = $corp->getAllModifiedFields();
if ($address = $corp->addAddress($address_raw)) {
$addressModified = $address->getAllModifiedFields();
}
if ($telephone) {
$phone = $corp->addPhone($telephone);
$phoneModified = $phone->getAllModifiedFields();
}
$corp->save();
$corp->addReference($url, null, $modified, 'Fortune Magazine Online');
if ($address) {
$address->addReference($url, null, $addressModified, 'Fortune Magazine Online');
}
if ($phone) {
$phone->addReference($url, null, $phoneModified, 'Fortune Magazine Online');
}
if ($industry) {
}
return $corp;
}