本文整理汇总了PHP中Entity::setEntityField方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::setEntityField方法的具体用法?PHP Entity::setEntityField怎么用?PHP Entity::setEntityField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::setEntityField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onEntitySave
public function onEntitySave(Entity $entity)
{
//save to entity name only if doesn't exist
if (!$entity->rawGet('name')) {
$entity->setEntityField('name', $this->getFullName(false));
}
}
示例2: onEntitySave
public function onEntitySave(Entity $entity)
{
if (!$entity->rawGet('name')) {
$entity->setEntityField('name', trim($this->name));
}
}
示例3: parseResults
public function parseResults($match)
{
if (isset($match['bio'])) {
$bio_dirty = LsHtml::replaceEntities(LsString::spacesToSpace(LsHtml::stripTags($match['bio'], "; ")));
$bio_dirty = preg_replace('/(\\;\\s)+/is', '; ', $bio_dirty);
}
foreach ($match as $k => &$m) {
$m = LsHtml::replaceEntities(LsString::spacesToSpace(LsHtml::stripTags($m, " ")));
}
if (isset($match['name'])) {
$name = $match['name'];
$bio = '';
if (isset($match['bio'])) {
$bio = $match['bio'];
}
} else {
return;
}
$this->printDebug("_________________________\n\nname: " . $name . "\n");
$this->printDebug("bio: " . $bio . "\n");
$accept = strtolower($this->readline('Process this entity? (n to skip) '));
if ($accept == 'n' || $accept == 'no') {
return false;
}
if (!$this->org_org) {
if ($this->last_first) {
$entity = PersonTable::parseCommaName($name);
} else {
$entity = PersonTable::parseFlatName($name);
}
$similar_entities = PersonTable::getSimilarQuery2($entity)->execute();
} else {
$entity = new Entity();
$entity->addExtension('Org');
foreach ($this->org_extensions as $ext) {
$entity->addExtension($ext);
}
$entity->setEntityField('name', $name);
$name = trim($name);
$name = str_replace('.', '', $name);
$similar_entities = OrgTable::getSimilarQuery($entity)->execute();
}
$matched = false;
foreach ($similar_entities as $similar_entity) {
if ($similar_entity['primary_ext'] == 'Person') {
$this->printDebug(' POSSIBLE MATCH: ' . $similar_entity->name . ' (Orgs :: ' . $similar_entity->getRelatedOrgsSummary() . " Bio :: {$similar_entity->summary})");
} else {
$this->printDebug(' POSSIBLE MATCH: ' . $similar_entity->name . ' (Summary :: ' . $similar_entity->summary . ')');
}
$accept = $this->readline(' Is this the same entity? (y or n)');
$attempts = 1;
while ($accept != 'y' && $accept != 'n' && $attempts < 5) {
$accept = $this->readline(' Is this the same entity? (y or n) ');
$attempts++;
}
if ($accept == 'y') {
$entity = $similar_entity;
$matched = true;
$this->printDebug(' [accepted]');
//sleep(1);
break;
} else {
if ($accept == 'break') {
break;
}
}
}
$created = false;
if (!$matched) {
if ($entity->getPrimaryExtension() == 'Person') {
$this->printDebug(' New person: ' . $entity->name_first . ' ' . $entity->name_last);
} else {
$this->printDebug(' New org: ' . $entity->name);
}
$accept = $this->readline(' create this new entity? (y or n) ');
$attempts = 1;
while ($accept != 'y' && $accept != 'n' && $attempts < 5) {
$accept = $this->readline(' create this new entity? (y or n) ');
$attempts++;
}
if ($accept == 'y') {
if ($entity->getPrimaryExtension() == 'Person') {
$this->printDebug("\n Bio: {$bio} \n");
$accept = $this->readline(' Add this bio? (y or n) ');
$attempts = 1;
while ($accept != 'y' && $accept != 'n' && $attempts < 5) {
$accept = $this->readline(' add this bio? (y or n) ');
$attempts++;
}
if ($accept == 'y') {
$entity->summary = $bio;
}
}
$entity->save();
$entity->addReference($this->url, null, null, $this->url_name);
$created = true;
$this->printDebug(' ' . $entity->name . ' saved');
//sleep(1);
}
}
//.........这里部分代码省略.........
示例4: processRow
public function processRow($row)
{
if (isset($row['url']) && $row['url'] != '' && isset($row['url_name']) && $row['url_name'] != '') {
$url = $row['url'];
$url_name = $row['url_name'];
} else {
$url = $this->url;
$url_name = $this->url_name;
}
foreach ($row as &$r) {
trim($r);
}
unset($r);
if ($this->entity) {
$required = array('entity_name', 'primary_type', 'relationship_category');
} else {
$required = array('entity_name', 'primary_type');
}
foreach ($required as $req) {
if (!isset($row[$req]) || $row[$req] == '') {
$this->printDebug('!!! > skipping row, ' . $req . ' not set');
return;
}
}
if ($row['primary_type'] != 'Person' && $row['primary_type'] != 'Org') {
$this->printDebug('!!! > primary type not properly set, skipping row...');
return;
}
if ($this->entity) {
$relationship_category = trim($row['relationship_category']);
$relationship_category_id = array_search($relationship_category, RelationshipCategoryTable::$categoryNames);
if (!$relationship_category_id) {
$this->printDebug('!!! > relationship type not properly set, skipping row...');
return;
}
}
$this->printDebug("processing: " . $row['entity_name'] . '......');
if ($row['primary_type'] == 'Person') {
$entity2 = PersonTable::parseFlatName($row['entity_name']);
$similar_entities = PersonTable::getSimilarQuery2($entity2)->execute();
} else {
$entity2 = new Entity();
$entity2->addExtension('Org');
$entity2->setEntityField('name', $row['entity_name']);
$similar_entities = OrgTable::getOrgsWithSimilarNames($entity2->name);
}
$matched = false;
foreach ($similar_entities as $similar_entity) {
if ($similar_entity['primary_ext'] == 'Person') {
$this->printDebug(' POSSIBLE MATCH: ' . $similar_entity->name . ' (Orgs :: ' . $similar_entity->getRelatedOrgsSummary() . " Bio :: {$similar_entity->summary})");
} else {
$this->printDebug(' POSSIBLE MATCH: ' . $similar_entity->name . ' (Summary :: ' . $similar_entity->summary . ')');
}
$accept = $this->readline(' Is this the same entity? (y or n or b to break)');
if ($accept == 'y') {
$entity2 = $similar_entity;
$matched = true;
$this->printDebug(' [accepted]');
break;
} else {
if ($accept == 'b') {
break;
}
}
}
$created = false;
if (!$matched) {
if ($entity2->getPrimaryExtension() == 'Person') {
$this->printDebug(' New person: ' . $entity2->name_first . ' ' . $entity2->name_last);
} else {
$this->printDebug(' New org: ' . $entity2->name);
}
$accept = $this->readline(' create this new entity? (y or n) ');
if ($accept == 'y') {
try {
$extensions = LsString::split($row['entity_extensions'], '\\s*\\,\\s*');
foreach ($extensions as $extension) {
$entity2->addExtension($extension);
}
$entity2->save();
$entity2->addReference($url, null, null, $url_name);
} catch (Exception $e) {
$this->printDebug(' !!! problems with extensions for this row');
}
$fields = array('summary', 'blurb', 'website');
foreach ($fields as $field) {
if (isset($row[$field])) {
$entity2[$field] = $row[$field];
}
}
$entity2->save();
$entity2->addReference($url, null, null, $url_name);
$created = true;
$this->printDebug(' ' . $entity2->name . ' saved');
//sleep(1);
} else {
$entity2 = null;
}
}
// create relationship
//.........这里部分代码省略.........