本文整理汇总了PHP中Migration::getRemoteModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::getRemoteModel方法的具体用法?PHP Migration::getRemoteModel怎么用?PHP Migration::getRemoteModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::getRemoteModel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processDeletions
function processDeletions()
{
// debug($this->options);
$ids = $this->LocalModel->migrationDeletedIds($this->Process->targetInstance);
if (!empty($ids)) {
if (!empty($this->options['instance']['execeptions']) || !empty($this->options['execeptions']) && $this->options['mode'] != 'exclude') {
if ($this->options['mode'] == 'exclude') {
$ids = array_diff($ids, $this->options['instance']['execeptions']);
} else {
$ids = array_intersect($ids, $this->options['instance']['execeptions']);
}
}
if (!empty($ids)) {
$remoteModel = Migration::getRemoteModel($this->LocalModel, $this->Process->targetInstance);
$dry = MigrationConfig::load('dryRun');
if ($dry) {
$this->msg('Delete attempt on ' . $remoteModel->alias . ' for Ids : ' . implode(', ', $ids));
} else {
if ($remoteModel->deleteAll(array($remoteModel->alias . '.' . $remoteModel->primaryKey => $ids))) {
$this->msg(str_replace('%nb%', count($ids), __('%nb% entries deleted on the remote server', true)));
$this->MigrationRemote->deleteAll(array('model' => $this->LocalModel->getFullName(), 'remote_id' => $ids));
}
}
}
}
}
示例2: getRemoteId
function getRemoteId($Model, $localEntry, $targetInstance)
{
$MR = $this->MigrationRemote;
$fullName = $this->getFullName($Model);
$settings = $this->settings[$Model->alias];
if (is_numeric($localEntry)) {
$local_id = $localEntry;
} else {
$local_id = $localEntry[$Model->alias][$Model->primaryKey];
}
$remoteNode = $MR->find('first', array('conditions' => array($MR->alias . '.model' => $fullName, $MR->alias . '.instance' => $targetInstance, $MR->alias . '.local_id' => $local_id)));
if ($remoteNode) {
return $remoteNode[$MR->alias]['remote_id'];
}
if (!empty($settings['mapFields'])) {
$remoteModel = Migration::getRemoteModel($Model, $targetInstance);
$MapFieldsConds = $this->_remoteEntryMapFieldsConds($Model, $localEntry, $remoteModel);
if ($MapFieldsConds) {
$remote = $remoteModel->find('first', array('fields' => array($remoteModel->primaryKey), 'conditions' => $MapFieldsConds, 'recursive' => -1));
return $remote[$remoteModel->alias][$remoteModel->primaryKey];
}
}
$lastSync = $this->getLastSync($Model, $targetInstance);
if (!empty($lastSync)) {
if (is_numeric($localEntry)) {
$localEntry = $Model->find('first', array('conditions' => array($Model->alias . '.' . $Model->primaryKey => $localEntry)));
}
if (strtotime($localEntry[$Model->alias]['modified']) <= $lastSync) {
return $local_id;
}
}
return null;
}
示例3: getEntriesStates
function getEntriesStates($Model, $entries, $instance = null)
{
$ids = array();
if (empty($instance)) {
$alias = $Model->alias;
} else {
$remoteModel = Migration::getRemoteModel($Model, $instance);
$alias = $remoteModel->alias;
}
foreach ($entries as $entry) {
$ids[] = $entry[$alias][$Model->primaryKey];
}
return $this->getIdsStates($Model->alias, $ids);
}
示例4: getRemoteModel
function getRemoteModel()
{
if (isset($this->_remoteModel)) {
return $this->_remoteModel;
}
return $this->_remoteModel = Migration::getRemoteModel($this->LocalModel, $this->targetInstance);
}
示例5: 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);
}