本文整理汇总了PHP中Migration::migratingModels方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::migratingModels方法的具体用法?PHP Migration::migratingModels怎么用?PHP Migration::migratingModels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::migratingModels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pendingList
function pendingList()
{
$MigrationRemote = ClassRegistry::init('Migration.MigrationRemote');
$models = Migration::migratingModels();
$list = array();
foreach ($models as $mname) {
$Model = Migration::getLocalModel($mname);
$up = $Model->migrationPendingCount();
if (!empty($up)) {
$list[$mname]['update'] = $up;
}
$del = $Model->migrationDeletedCount();
if (!empty($del)) {
$list[$mname]['delete'] = $del;
}
}
return $list;
}
示例2: getMigratedAssociations
function getMigratedAssociations($Model)
{
$settings = $this->settings[$Model->alias];
$assoc = Set::normalize($settings['assoc']);
$belongsTo = array_diff($Model->getAssociated('belongsTo'), array_keys($assoc));
if (!empty($belongsTo)) {
$exclude = array_merge(array($Model->primaryKey), $settings['excludeFields']);
foreach ($Model->getAssociated('belongsTo') as $alias) {
$opt = $Model->belongsTo[$alias];
$migratingModels = Migration::migratingModels();
if (!in_array($opt['foreignKey'], $exclude)) {
if (in_array($opt['className'], $migratingModels)) {
$assoc[$alias] = $opt;
} elseif (isset($migratingModels[$opt['className']])) {
$opt['className'] = $migratingModels[$opt['className']];
$assoc[$alias] = $opt;
}
}
}
}
App::import('Lib', 'Migration.MigrationConfig');
$parsers = MigrationConfig::load('assocParsers');
if (!empty($parsers)) {
foreach ($parsers as $p) {
$res = call_user_func($p, $this, $Model, $assoc);
if (!empty($res)) {
$assoc = array_merge($assoc, $res);
}
}
}
return $assoc;
}
示例3: admin_index
function admin_index()
{
App::import('Lib', 'Migration.Migration');
App::import('Lib', 'Migration.MigrationProcess');
$targets = Migration::targetList();
if (empty($targets)) {
$this->render('admin_missing_target');
return;
}
//$Model = Migration::getLocalModel('Slider');
//debug($Model->migrationDeletedCount());
// $Model = Migration::getLocalModel('Page');
// debug($Model->migrationDeletedCount());
$posted = !empty($this->data);
if ($posted) {
foreach ($this->data['Migration']['targets'] as $target => $active) {
if ($active) {
$process = new MigrationProcess($target);
foreach ($this->data['Migration']['models'] as $modelName => $active) {
if ($active) {
$modelName = str_replace('-', '.', $modelName);
//$process->models[$modelName] = $this->Migrated->findOpt($modelName);
$process->setModelOpt($modelName, $this->Migrated->getModelOpt($modelName));
}
}
// debug($process->models);
$process->run();
$this->Session->setFlash(implode("<br>\n", $process->msgs));
}
}
$dry = MigrationConfig::load('dryRun');
if ($dry) {
$this->data = array();
$posted = false;
} else {
$this->Migrated->clear();
$this->redirect(array('action' => 'index'));
}
}
$modelsNames = Migration::migratingModels();
$models = array();
$pendings = Migration::pendingList();
foreach ($modelsNames as $mname) {
$m = array('class' => Migration::classNameParts($mname, 'class'), 'name' => str_replace('.', '-', $mname), 'count' => 0, 'deleted_count' => 0, 'migrated_count' => 0, 'param' => Migration::modelNameToUrl($mname));
if (!empty($pendings[$mname])) {
$m['count'] = array_sum($pendings[$mname]);
$m['deleted_count'] = empty($pendings[$mname]['delete']) ? 0 : $pendings[$mname]['delete'];
$m['migrated_count'] = $this->Migrated->alterCount($mname, $m['count']);
if (!$posted) {
$this->data['Migration']['models'][$m['name']] = 1;
}
}
$models[] = $m;
}
// debug($models);
if (!$posted) {
foreach ($targets as $key => $label) {
$this->data['Migration']['targets'][$key] = 1;
}
}
$this->set('models', $models);
$this->set('targets', $targets);
}