本文整理汇总了PHP中Term::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Term::update方法的具体用法?PHP Term::update怎么用?PHP Term::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Term
的用法示例。
在下文中一共展示了Term::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_versions
public static function save_versions($post = null, $versions = array())
{
if (isset($post) && count($versions) !== 0) {
$vocabulary = Vocabulary::get(self::CATALOG_VOCABULARY);
$extant_terms = $vocabulary->get_associations($post->id, 'addon');
foreach ($versions as $key => $version) {
$version_display = "{$version['habari_version']}-{$version['version']}";
echo "Incoming Version: {$version_display}\n\n";
$found = false;
foreach ($extant_terms as $eterm) {
$extant_display = "{$eterm->info->habari_version}-{$eterm->info->version}";
echo ">> Extant Version: {$extant_display}\n\n";
if ($extant_display == $version_display) {
$found = true;
$term = $eterm;
break;
}
}
if (!$found) {
$term = new Term(array('term_display' => $version_display, 'term' => Utils::slugify("{$post->id} {$version_display} {$post->info->repo_url}", '-')));
}
foreach ($version as $field => $value) {
$term->info->{$field} = $value;
}
if ($found) {
$term->update();
} else {
$vocabulary->add_term($term);
$term->associate('addon', $post->id);
}
}
} else {
// post didn't work or there was no version.
}
}
示例2: save_version
public static function save_version($post = null, $versions = array())
{
if (isset($post) && count($versions) !== 0) {
$vocabulary = Vocabulary::get(self::$vocabulary);
$extant_terms = $vocabulary->get_associations($post->id, 'addon');
foreach ($versions as $key => $version) {
$term_display = "{$post->id} {$key} {$post->info->repo_url}";
$found = false;
foreach ($extant_terms as $eterm) {
if ($eterm->term_display == $term_display) {
// This is super-cheesy!
$found = true;
$term = $eterm;
break;
}
}
if (!$found) {
$term = new Term(array('term_display' => $post->id . " {$key}"));
}
foreach ($version as $field => $value) {
$term->info->{$field} = $value;
}
if ($found) {
$term->update();
} else {
$vocabulary->add_term($term);
$term->associate('addon', $post->id);
}
}
} else {
// post didn't work or there was no version.
}
}