3 abstract class PhabricatorCustomFieldStorage
4 extends PhabricatorLiskDAO
{
10 protected function getConfiguration() {
12 self
::CONFIG_TIMESTAMPS
=> false,
13 self
::CONFIG_COLUMN_SCHEMA
=> array(
14 'fieldIndex' => 'bytes12',
15 'fieldValue' => 'text',
17 self
::CONFIG_KEY_SCHEMA
=> array(
18 'objectPHID' => array(
19 'columns' => array('objectPHID', 'fieldIndex'),
23 ) + parent
::getConfiguration();
28 * Get a key which uniquely identifies this storage source.
30 * When loading custom fields, fields using sources with the same source key
33 * @return string Source identifier.
35 final public function getStorageSourceKey() {
36 return $this->getApplicationName().'/'.$this->getTableName();
41 * Load stored data for custom fields.
43 * Given a map of fields, return a map with any stored data for those fields.
44 * The keys in the result should correspond to the keys in the input. The
45 * fields in the list may belong to different objects.
47 * @param map<string, PhabricatorCustomField> Map of fields.
48 * @return map<String, PhabricatorCustomField> Map of available field data.
50 final public function loadStorageSourceData(array $fields) {
53 $object_phids = array();
55 foreach ($fields as $key => $field) {
56 $index = $field->getFieldIndex();
57 $object_phid = $field->getObject()->getPHID();
59 $map[$index][$object_phid] = $key;
60 $indexes[$index] = $index;
61 $object_phids[$object_phid] = $object_phid;
68 $conn = $this->establishConnection('r');
71 'SELECT objectPHID, fieldIndex, fieldValue FROM %T
72 WHERE objectPHID IN (%Ls) AND fieldIndex IN (%Ls)',
73 $this->getTableName(),
78 foreach ($rows as $row) {
79 $index = $row['fieldIndex'];
80 $object_phid = $row['objectPHID'];
81 $value = $row['fieldValue'];
83 $key = $map[$index][$object_phid];
84 $result[$key] = $value;