Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | public function readFieldsFromStorage( | ||||
| $keys = array(); | $keys = array(); | ||||
| foreach ($this->fields as $field) { | foreach ($this->fields as $field) { | ||||
| if ($field->shouldEnableForRole(PhabricatorCustomField::ROLE_STORAGE)) { | if ($field->shouldEnableForRole(PhabricatorCustomField::ROLE_STORAGE)) { | ||||
| $keys[$field->getFieldIndex()] = $field; | $keys[$field->getFieldIndex()] = $field; | ||||
| } | } | ||||
| } | } | ||||
| if (!$keys) { | if (!$keys) { | ||||
| return; | return $this; | ||||
| } | } | ||||
| // NOTE: We assume all fields share the same storage. This isn't guaranteed | // NOTE: We assume all fields share the same storage. This isn't guaranteed | ||||
| // to be true, but always is for now. | // to be true, but always is for now. | ||||
| $table = head($keys)->newStorageObject(); | $table = head($keys)->newStorageObject(); | ||||
| $objects = array(); | $objects = array(); | ||||
| Show All 10 Lines | foreach ($keys as $key => $field) { | ||||
| if ($storage) { | if ($storage) { | ||||
| $field->setValueFromStorage($storage->getFieldValue()); | $field->setValueFromStorage($storage->getFieldValue()); | ||||
| } else if ($object->getPHID()) { | } else if ($object->getPHID()) { | ||||
| // NOTE: We set this only if the object exists. Otherwise, we allow the | // NOTE: We set this only if the object exists. Otherwise, we allow the | ||||
| // field to retain any default value it may have. | // field to retain any default value it may have. | ||||
| $field->setValueFromStorage(null); | $field->setValueFromStorage(null); | ||||
| } | } | ||||
| } | } | ||||
| return $this; | |||||
| } | } | ||||
| public function appendFieldsToForm(AphrontFormView $form) { | public function appendFieldsToForm(AphrontFormView $form) { | ||||
| $enabled = array(); | $enabled = array(); | ||||
| foreach ($this->fields as $field) { | foreach ($this->fields as $field) { | ||||
| if ($field->shouldEnableForRole(PhabricatorCustomField::ROLE_EDIT)) { | if ($field->shouldEnableForRole(PhabricatorCustomField::ROLE_EDIT)) { | ||||
| $enabled[] = $field; | $enabled[] = $field; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | $any_index->openTransaction(); | ||||
| $table, | $table, | ||||
| $chunk); | $chunk); | ||||
| } | } | ||||
| } | } | ||||
| $any_index->saveTransaction(); | $any_index->saveTransaction(); | ||||
| } | } | ||||
| public function updateAbstractDocument( | |||||
| PhabricatorSearchAbstractDocument $document) { | |||||
| $role = PhabricatorCustomField::ROLE_GLOBALSEARCH; | |||||
| foreach ($this->getFields() as $field) { | |||||
| if (!$field->shouldEnableForRole($role)) { | |||||
| continue; | |||||
| } | |||||
| $field->updateAbstractDocument($document); | |||||
| } | |||||
| return $document; | |||||
| } | |||||
| } | } | ||||