Differential D18967 Diff 45494 src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
| Show First 20 Lines • Show All 1,449 Lines • ▼ Show 20 Lines | /* -( Export )------------------------------------------------------------- */ | ||||
| public function canExport() { | public function canExport() { | ||||
| $fields = $this->newExportFields(); | $fields = $this->newExportFields(); | ||||
| return (bool)$fields; | return (bool)$fields; | ||||
| } | } | ||||
| final public function newExportFieldList() { | final public function newExportFieldList() { | ||||
| $object = $this->newResultObject(); | |||||
| $builtin_fields = array( | $builtin_fields = array( | ||||
| id(new PhabricatorIDExportField()) | id(new PhabricatorIDExportField()) | ||||
| ->setKey('id') | ->setKey('id') | ||||
| ->setLabel(pht('ID')), | ->setLabel(pht('ID')), | ||||
| id(new PhabricatorPHIDExportField()) | |||||
| ->setKey('phid') | |||||
| ->setLabel(pht('PHID')), | |||||
| ); | ); | ||||
| if ($object->getConfigOption(LiskDAO::CONFIG_AUX_PHID)) { | |||||
| $builtin_fields[] = id(new PhabricatorPHIDExportField()) | |||||
| ->setKey('phid') | |||||
| ->setLabel(pht('PHID')); | |||||
| } | |||||
| $fields = mpull($builtin_fields, null, 'getKey'); | $fields = mpull($builtin_fields, null, 'getKey'); | ||||
| $export_fields = $this->newExportFields(); | $export_fields = $this->newExportFields(); | ||||
| foreach ($export_fields as $export_field) { | foreach ($export_fields as $export_field) { | ||||
| $key = $export_field->getKey(); | $key = $export_field->getKey(); | ||||
| if (isset($fields[$key])) { | if (isset($fields[$key])) { | ||||
| throw new Exception( | throw new Exception( | ||||
| Show All 27 Lines | foreach ($extensions as $extension) { | ||||
| $fields[$key] = $extension_field; | $fields[$key] = $extension_field; | ||||
| } | } | ||||
| } | } | ||||
| return $fields; | return $fields; | ||||
| } | } | ||||
| final public function newExport(array $objects) { | final public function newExport(array $objects) { | ||||
| $object = $this->newResultObject(); | |||||
| $has_phid = $object->getConfigOption(LiskDAO::CONFIG_AUX_PHID); | |||||
| $objects = array_values($objects); | $objects = array_values($objects); | ||||
| $n = count($objects); | $n = count($objects); | ||||
| $maps = array(); | $maps = array(); | ||||
| foreach ($objects as $object) { | foreach ($objects as $object) { | ||||
| $maps[] = array( | $map = array( | ||||
| 'id' => $object->getID(), | 'id' => $object->getID(), | ||||
| 'phid' => $object->getPHID(), | |||||
| ); | ); | ||||
| if ($has_phid) { | |||||
| $map['phid'] = $object->getPHID(); | |||||
| } | |||||
| $maps[] = $map; | |||||
| } | } | ||||
| $export_data = $this->newExportData($objects); | $export_data = $this->newExportData($objects); | ||||
| $export_data = array_values($export_data); | $export_data = array_values($export_data); | ||||
| if (count($export_data) !== count($objects)) { | if (count($export_data) !== count($objects)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'Search engine ("%s") exported the wrong number of objects, '. | 'Search engine ("%s") exported the wrong number of objects, '. | ||||
| ▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines | |||||