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


PHP Versions::diff方法代碼示例

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


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

示例1: test_history

 /**
  * @depends test_diff
  */
 function test_history()
 {
     // test history
     $history = Versions::history(self::$foo);
     $this->assertEquals(count($history), 2);
     $modified = Versions::diff($history[0], $history[1]);
     $this->assertEquals($modified[0], 'name');
     // get a count with class name (groups by pkey, so one result)
     $history = Versions::history('Foobar', true);
     $this->assertEquals($history, 1);
     // get a count with object (all for the item, so two results)
     $history = Versions::history(self::$foo, true);
     $this->assertEquals($history, 2);
     // get history from class name (groups by pkey, so one result)
     $history = Versions::history('Foobar');
     $this->assertEquals(count($history), 1);
 }
開發者ID:nathanieltite,項目名稱:elefant,代碼行數:20,代碼來源:VersionsTest.php

示例2: Versions

<?php

/**
 * Compares a previous version of a Model object to the
 * current version, allowing you to restore the previous
 * version if desired.
 */
$page->layout = 'admin';
if (!User::require_admin()) {
    $this->redirect('/admin');
}
$ver = new Versions($_GET['id']);
$old = $ver->restore();
$class = $ver->class;
$cur = new $class($ver->pkey);
if ($cur->error) {
    // deleted item
    foreach (json_decode($ver->serialized) as $key => $value) {
        $cur->{$key} = $value;
    }
}
$diff = Versions::diff($old, $cur);
$data = array();
foreach ((array) $cur->orig() as $key => $value) {
    $data[$key] = array('cur' => $value, 'old' => $old->{$key}, 'diff' => in_array($key, $diff) ? true : false);
}
$page->title = i18n_get('Comparing') . ' ' . $ver->class . ' / ' . $ver->pkey;
echo $tpl->render('admin/compare', array('fields' => $data, 'class' => $ver->class, 'pkey' => $ver->pkey, 'ts' => $ver->ts));
開發者ID:nathanieltite,項目名稱:elefant,代碼行數:28,代碼來源:compare.php


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