Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/source/NuanceSourceDefinition.php
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | abstract class NuanceSourceDefinition extends Phobject { | ||||
} | } | ||||
final public function getImportCursors() { | final public function getImportCursors() { | ||||
if (!$this->hasImportCursors()) { | if (!$this->hasImportCursors()) { | ||||
throw new Exception( | throw new Exception( | ||||
pht('This source has no input cursors.')); | pht('This source has no input cursors.')); | ||||
} | } | ||||
$viewer = PhabricatorUser::getOmnipotentUser(); | |||||
$source = $this->getSource(); | $source = $this->getSource(); | ||||
$cursors = $this->newImportCursors(); | $cursors = $this->newImportCursors(); | ||||
$data = id(new NuanceImportCursorDataQuery()) | $data = id(new NuanceImportCursorDataQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer($viewer) | ||||
->withSourcePHIDs(array($source->getPHID())) | ->withSourcePHIDs(array($source->getPHID())) | ||||
->execute(); | ->execute(); | ||||
$data = mpull($data, 'getCursorKey'); | $data = mpull($data, null, 'getCursorKey'); | ||||
$map = array(); | $map = array(); | ||||
foreach ($cursors as $cursor) { | foreach ($cursors as $cursor) { | ||||
if (!($cursor instanceof NuanceImportCursor)) { | if (!($cursor instanceof NuanceImportCursor)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Source "%s" (of class "%s") returned an invalid value from '. | 'Source "%s" (of class "%s") returned an invalid value from '. | ||||
'method "%s": all values must be objects of class "%s".', | 'method "%s": all values must be objects of class "%s".', | ||||
Show All 25 Lines | foreach ($cursors as $cursor) { | ||||
$this->getName(), | $this->getName(), | ||||
get_class($this), | get_class($this), | ||||
'newImportCursors()', | 'newImportCursors()', | ||||
$key)); | $key)); | ||||
} | } | ||||
$map[$key] = $cursor; | $map[$key] = $cursor; | ||||
$cursor->setSource($source); | |||||
$cursor_data = idx($data, $key); | $cursor_data = idx($data, $key); | ||||
if (!$cursor_data) { | if (!$cursor_data) { | ||||
$cursor_data = $cursor->newEmptyCursorData($source); | $cursor_data = $cursor->newEmptyCursorData($source); | ||||
} | } | ||||
$cursor->setCursorData($cursor_data); | $cursor | ||||
->setViewer($viewer) | |||||
->setSource($source) | |||||
->setCursorData($cursor_data); | |||||
} | } | ||||
return $cursors; | return $cursors; | ||||
} | } | ||||
protected function newImportCursors() { | protected function newImportCursors() { | ||||
throw new PhutilMethodNotImplementedException(); | throw new PhutilMethodNotImplementedException(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |