本文整理匯總了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.
}
}