本文整理汇总了PHP中Migration::getLocalModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::getLocalModel方法的具体用法?PHP Migration::getLocalModel怎么用?PHP Migration::getLocalModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::getLocalModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nextAutoSelectBatch
function nextAutoSelectBatch()
{
if (!empty($this->autoSelect)) {
$modelName = $this->autoSelect[0]['model'];
$ids = array();
foreach ($this->autoSelect as $i => $sel) {
$ids[] = $sel['local_id'];
unset($this->autoSelect[$i]);
}
$this->autoSelect = array_values($this->autoSelect);
$Model = Migration::getLocalModel($modelName);
$this->batches[] = $batch = new MigrationBatch($this, $Model, array('conditions' => array($Model->alias . '.' . $Model->primaryKey => $ids)));
return $batch;
}
}
示例2: updateAllTracking
function updateAllTracking($data)
{
//debug($data);
foreach ($data as $model => $mdata) {
$Model = Migration::getLocalModel($model);
$Model->updateMigrationTracking($mdata);
}
}
示例3: prepDataForMigration
function prepDataForMigration($exclude = array())
{
// $this->LocalModel, $this->entry, $this->targetInstance
// $Model, $entry, $targetInstance,
$settings = $this->LocalModel->migrationSettings();
$exclude = array_merge($exclude, array($this->LocalModel->primaryKey), $settings['excludeFields']);
$fullName = $this->LocalModel->getFullName();
$alias = $this->LocalModel->alias;
$entry = $this->entry;
$assoc = $this->LocalModel->getMigratedAssociations();
if (!empty($assoc)) {
foreach ($assoc as $name => $opt) {
$paths = array();
if (!empty($opt['path'])) {
$paths = Migration::extractPath($entry[$alias], $opt['path']);
} elseif (!empty($opt['foreignKey']) && array_key_exists($opt['foreignKey'], $entry[$alias])) {
$paths = array($opt['foreignKey'] => $entry[$alias][$opt['foreignKey']]);
}
//debug($paths);
if (!empty($paths)) {
$AssocModel = Migration::getLocalModel($opt['className']);
foreach ($paths as $path => $local_id) {
$removed = false;
$remote_id = $AssocModel->getRemoteId($local_id, $this->targetInstance);
if (is_null($remote_id)) {
if (isset($opt['unsetLevel'])) {
$entry[$alias] = Set::remove($entry[$alias], implode('.', array_slice(explode('.', $path), 0, $opt['unsetLevel'])));
$removed = true;
}
if (!empty($opt['autoTrack'])) {
$entry['MigrationTracking'][$opt['className']][$local_id] = 1;
}
if (!empty($opt['autoSelect'])) {
$this->Batch->Process->autoSelect[] = array('model' => $opt['className'], 'local_id' => $local_id);
}
$entry['MigrationMissing'][] = array('model' => $opt['className'], 'local_id' => $local_id);
}
if (!$removed) {
$entry[$alias] = Set::insert($entry[$alias], $path, $remote_id);
}
}
}
}
//debug($assoc);
}
//debug($entry[$alias]);
$raw = $this->LocalModel->getRawEntry($entry);
$data = $raw[$alias];
$data = array_diff_key($data, array_flip($exclude));
$entry['MigrationData'] = $data;
return $entry;
}
示例4: admin_deleted
function admin_deleted($instance, $modelName, $id)
{
App::import('Lib', 'Migration.Migration');
$Model = Migration::getLocalModel($modelName);
$remoteModel = Migration::getRemoteModel($Model, $instance);
$remote = $remoteModel->read(null, $id);
$this->set('modelUrlAlias', $Model->getUrlName());
$this->set('modelAlias', $remoteModel->alias);
$this->set('remote', $remote);
}