當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Versioned::clean_array方法代碼示例

本文整理匯總了PHP中Versioned::clean_array方法的典型用法代碼示例。如果您正苦於以下問題:PHP Versioned::clean_array方法的具體用法?PHP Versioned::clean_array怎麽用?PHP Versioned::clean_array使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Versioned的用法示例。


在下文中一共展示了Versioned::clean_array方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * Overload Sprig::update() to save revision change
  * @param bump  whether to bump the version number
  */
 public function update($bump = TRUE)
 {
     Kohana::$log->add(Kohana::DEBUG, 'Executing Versioned_Sprig::update');
     $updated = FALSE;
     foreach ($this->_fields as $field => $object) {
         if ($object instanceof Sprig_Field_Tracked and $this->changed($field)) {
             $this->comment = UTF8::ucwords($object->label) . ' changed from "' . $this->_original[$field] . '" to "' . $this->_changed[$field] . '".';
         }
         if ($object instanceof Sprig_Field_Versioned and $this->changed($field) and $bump) {
             $diff = '';
             if ($this->version != 0) {
                 $diff = Versioned::diff($this->_original[$field], $this->_changed[$field]);
                 $diff = Versioned::clean_array($diff);
                 $diff = serialize($diff);
             }
             $this->version++;
             $revision = Sprig::factory($this->_model . '_revision');
             $revision->values(array('entry' => $this->id, 'version' => $this->version, 'editor' => $this->editor, 'diff' => $diff));
             $revision->comments = $this->comments;
             $revision->create();
             $updated = TRUE;
             $this->comments = array();
         }
     }
     if (!$updated and count($this->comments) > 0) {
         $revision = Sprig::factory($this->_model . '_revision');
         $revision->entry = $this->id;
         $revision->version = $this->version;
         $revision->load();
         $revision->comments = array_merge($revision->comments, $this->comments);
         $revision->update();
     }
     return parent::update();
 }
開發者ID:vimofthevine,項目名稱:versioned,代碼行數:38,代碼來源:sprig.php

示例2: populate

 /**
  * Populate table with versions
  */
 private function populate($id)
 {
     $text1 = "This is my string";
     $text2 = "This is my first string";
     // inserted "first"
     $text3 = "This is our first string";
     // changed "my" to "our"
     $text4 = "This is our first";
     // dropped "string"
     $diff2 = serialize(Versioned::clean_array(Versioned::diff($text1, $text2)));
     $diff3 = serialize(Versioned::clean_array(Versioned::diff($text2, $text3)));
     $diff4 = serialize(Versioned::clean_array(Versioned::diff($text3, $text4)));
     try {
         DB::insert('entry_revisions', array('entry_id', 'version', 'diff'))->values(array($id, 1, ''))->execute();
         DB::insert('entry_revisions', array('entry_id', 'version', 'diff'))->values(array($id, 2, $diff2))->execute();
         DB::insert('entry_revisions', array('entry_id', 'version', 'diff'))->values(array($id, 3, $diff3))->execute();
         DB::insert('entry_revisions', array('entry_id', 'version', 'diff'))->values(array($id, 4, $diff4))->execute();
         DB::insert('entries', array('id', 'version', 'text'))->values(array($id, 4, $text4))->execute();
     } catch (Database_Exception $e) {
         echo $e->getMessage();
     }
 }
開發者ID:vimofthevine,項目名稱:versioned,代碼行數:25,代碼來源:UnitTest.php


注:本文中的Versioned::clean_array方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。