当前位置: 首页>>代码示例>>PHP>>正文


PHP Term::update方法代码示例

本文整理汇总了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.
     }
 }
开发者ID:habari-extras,项目名称:addon_catalog,代码行数:35,代码来源:addon_catalog.plugin.php

示例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.
     }
 }
开发者ID:ringmaster,项目名称:post_receive,代码行数:33,代码来源:post_receive.plugin.php


注:本文中的Term::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。