code/controllers/ExternalContentAdmin.php
public function migrate($request) {
		$migrationTarget 		= isset($request['MigrationTarget']) ? $request['MigrationTarget'] : '';
		$fileMigrationTarget 	= isset($request['FileMigrationTarget']) ? $request['FileMigrationTarget'] : '';
		$includeSelected 		= isset($request['IncludeSelected']) ? $request['IncludeSelected'] : 0;
		$includeChildren 		= isset($request['IncludeChildren']) ? $request['IncludeChildren'] : 0;
		$duplicates 			= isset($request['DuplicateMethod']) ? $request['DuplicateMethod'] : ExternalContentTransformer::DS_OVERWRITE;
		$selected 				= isset($request['ID']) ? $request['ID'] : 0;

		if(!$selected){
			$messageType = 'bad';
			$message = _t('ExternalContent.NOITEMSELECTED', 'No item selected to import.');
		}

		if(!$migrationTarget || !$fileMigrationTarget){
			$messageType = 'bad';
			$message = _t('ExternalContent.NOTARGETSELECTED', 'No target to import to selected.');
		}

		if ($selected && ($migrationTarget || $fileMigrationTarget)) {
			// get objects and start stuff
			$target = null;
			$targetType = 'SiteTree';
			if ($migrationTarget) {
				$target = DataObject::get_by_id('SiteTree', $migrationTarget);
			} else {
				$targetType = 'File';
				$target = DataObject::get_by_id('File', $fileMigrationTarget);
			}

			$from = ExternalContent::getDataObjectFor($selected);
			if ($from instanceof ExternalContentSource) {
				$selected = false;
			}

			if (isset($request['Repeat']) && $request['Repeat'] > 0) {
				$job = new ScheduledExternalImportJob($request['Repeat'], $from, $target, $includeSelected, $includeChildren, $targetType, $duplicates, $request);
				singleton('QueuedJobService')->queueJob($job);

				$messageType = 'good';
				$message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.');
			} else {
				$importer = $from->getContentImporter($targetType);
				if ($importer) {
					$result = $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates, $request);

					$messageType = 'good';
					if ($result instanceof QueuedExternalContentImporter) {
						$message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.');
					} else {
						$message = _t('ExternalContent.CONTENTMIGRATED', 'Import Successful.');
					}
				}
			}
		}

		Session::set("FormInfo.Form_EditForm.formError.message",$message);
		Session::set("FormInfo.Form_EditForm.formError.type", $messageType);

		return $this->getResponseNegotiator()->respond($this->request);
	}
public function migrate($request) {
		$migrationTarget 		= isset($request['MigrationTarget']) ? $request['MigrationTarget'] : '';
		$fileMigrationTarget 	= isset($request['FileMigrationTarget']) ? $request['FileMigrationTarget'] : '';
		$includeSelected 		= isset($request['IncludeSelected']) ? $request['IncludeSelected'] : 0;
		$includeChildren 		= isset($request['IncludeChildren']) ? $request['IncludeChildren'] : 0;
		$duplicates 			= isset($request['DuplicateMethod']) ? $request['DuplicateMethod'] : ExternalContentTransformer::DS_OVERWRITE;
		$selected 				= isset($request['ID']) ? $request['ID'] : 0;

		if(!$selected){
			$messageType = 'bad';
			$message = _t('ExternalContent.NOITEMSELECTED', 'No item selected to import.');
		}

		if(!$migrationTarget || !$fileMigrationTarget){
			$messageType = 'bad';
			$message = _t('ExternalContent.NOTARGETSELECTED', 'No target to import to selected.');
		}

		if ($selected && ($migrationTarget || $fileMigrationTarget)) {
			// get objects and start stuff
			$target = null;
			$targetType = 'SiteTree';
			if ($migrationTarget) {
				$target = DataObject::get_by_id('SiteTree', $migrationTarget);
			} else {
				$targetType = 'File';
				$target = DataObject::get_by_id('File', $fileMigrationTarget);
			}

			$from = ExternalContent::getDataObjectFor($selected);
			if ($from instanceof ExternalContentSource) {
				$selected = false;
			}

			if (isset($request['Repeat']) && $request['Repeat'] > 0) {
				$job = new ScheduledExternalImportJob($request['Repeat'], $from, $target, $includeSelected, $includeChildren, $targetType, $duplicates, $request);
				singleton('QueuedJobService')->queueJob($job);

				$messageType = 'good';
				$message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.');
			} else {
				$importer = $from->getContentImporter($targetType);
				if ($importer) {
					$result = $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates, $request);

					$messageType = 'good';
					if ($result instanceof QueuedExternalContentImporter) {
						$message = _t('ExternalContent.CONTENTMIGRATEQUEUED', 'Import job queued.');
					} else {
						$message = _t('ExternalContent.CONTENTMIGRATED', 'Import Successful.');
					}
				}
			}
		}

		Session::set("FormInfo.Form_EditForm.formError.message",$message);
		Session::set("FormInfo.Form_EditForm.formError.type", $messageType);

		return $this->getResponseNegotiator()->respond($this->request);
	}
public function migrate ( $ request ) { $ migrationTarget = isset ( $ request [ 'MigrationTarget' ] ) ? $ request [ 'MigrationTarget' ] : '' ; $ fileMigrationTarget = isset ( $ request [ 'FileMigrationTarget' ] ) ? $ request [ 'FileMigrationTarget' ] : '' ; $ includeSelected = isset ( $ request [ 'IncludeSelected' ] ) ? $ request [ 'IncludeSelected' ] : 0 ; $ includeChildren = isset ( $ request [ 'IncludeChildren' ] ) ? $ request [ 'IncludeChildren' ] : 0 ; $ duplicates = isset ( $ request [ 'DuplicateMethod' ] ) ? $ request [ 'DuplicateMethod' ] : ExternalContentTransformer :: DS_OVERWRITE ; $ selected = isset ( $ request [ 'ID' ] ) ? $ request [ 'ID' ] : 0 ; if ( ! $ selected ) { $ messageType = 'bad' ; $ message = _t ( 'ExternalContent.NOITEMSELECTED' , 'No item selected to import.' ) ; } if ( ! $ migrationTarget || ! $ fileMigrationTarget ) { $ messageType = 'bad' ; $ message = _t ( 'ExternalContent.NOTARGETSELECTED' , 'No target to import to selected.' ) ; } if ( $ selected && ( $ migrationTarget || $ fileMigrationTarget ) ) { // get objects and start stuff $ target = null ; $ targetType = 'SiteTree' ; if ( $ migrationTarget ) { $ target = DataObject :: get_by_id ( 'SiteTree' , $ migrationTarget ) ; } else { $ targetType = 'File' ; $ target = DataObject :: get_by_id ( 'File' , $ fileMigrationTarget ) ; } $ from = ExternalContent :: getDataObjectFor ( $ selected ) ; if ( $ from instanceof ExternalContentSource ) { $ selected = false ; } if ( isset ( $ request [ 'Repeat' ] ) && $ request [ 'Repeat' ] > 0 ) { $ job = new ScheduledExternalImportJob ( $ request [ 'Repeat' ] , $ from , $ target , $ includeSelected , $ includeChildren , $ targetType , $ duplicates , $ request ) ; singleton ( 'QueuedJobService' ) -> queueJob ( $ job ) ; $ messageType = 'good' ; $ message = _t ( 'ExternalContent.CONTENTMIGRATEQUEUED' , 'Import job queued.' ) ; } else { $ importer = $ from -> getContentImporter ( $ targetType ) ; if ( $ importer ) { $ result = $ importer -> import ( $ from , $ target , $ includeSelected , $ includeChildren , $ duplicates , $ request ) ; $ messageType = 'good' ; if ( $ result instanceof QueuedExternalContentImporter ) { $ message = _t ( 'ExternalContent.CONTENTMIGRATEQUEUED' , 'Import job queued.' ) ; } else { $ message = _t ( 'ExternalContent.CONTENTMIGRATED' , 'Import Successful.' ) ; } } } } Session :: set ( "FormInfo.Form_EditForm.formError.message" , $ message ) ; Session :: set ( "FormInfo.Form_EditForm.formError.type" , $ messageType ) ; return $ this -> getResponseNegotiator ( ) -> respond ( $ this -> request ) ; }
Action to migrate a selected object through to SS

@param array $request
Action to migrate a selected object through to SS