Differential D19854 Diff 47435 src/applications/transactions/editengine/PhabricatorEditEngineSubtypeMap.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editengine/PhabricatorEditEngineSubtypeMap.php
| Show All 40 Lines | final class PhabricatorEditEngineSubtypeMap | ||||
| public function getCreateFormsForSubtype( | public function getCreateFormsForSubtype( | ||||
| PhabricatorEditEngine $edit_engine, | PhabricatorEditEngine $edit_engine, | ||||
| PhabricatorEditEngineSubtypeInterface $object) { | PhabricatorEditEngineSubtypeInterface $object) { | ||||
| $subtype_key = $object->getEditEngineSubtype(); | $subtype_key = $object->getEditEngineSubtype(); | ||||
| $subtype = $this->getSubtype($subtype_key); | $subtype = $this->getSubtype($subtype_key); | ||||
| // TODO: Allow subtype configuration to specify that children should be | $select_identifiers = $subtype->getChildFormIdentifiers(); | ||||
| // created from particular forms or subtypes. | $select_subtypes = $subtype->getChildSubtypes(); | ||||
| $select_ids = array(); | |||||
| $select_subtypes = array(); | |||||
| $query = $edit_engine->newConfigurationQuery() | $query = $edit_engine->newConfigurationQuery() | ||||
| ->withIsDisabled(false); | ->withIsDisabled(false); | ||||
| if ($select_ids) { | if ($select_identifiers) { | ||||
| $query->withIDs($select_ids); | $query->withIdentifiers($select_identifiers); | ||||
| } else { | } else { | ||||
| // If we're selecting by subtype rather than selecting specific forms, | // If we're selecting by subtype rather than selecting specific forms, | ||||
| // only select create forms. | // only select create forms. | ||||
| $query->withIsDefault(true); | $query->withIsDefault(true); | ||||
| if ($select_subtypes) { | if ($select_subtypes) { | ||||
| $query->withSubtypes($select_subtypes); | $query->withSubtypes($select_subtypes); | ||||
| } else { | } else { | ||||
| $query->withSubtypes(array($subtype_key)); | $query->withSubtypes(array($subtype_key)); | ||||
| } | } | ||||
| } | } | ||||
| $forms = $query->execute(); | $forms = $query->execute(); | ||||
| $forms = mpull($forms, null, 'getIdentifier'); | $forms = mpull($forms, null, 'getIdentifier'); | ||||
| // If we're selecting by ID, respect the order specified in the | // If we're selecting by ID, respect the order specified in the | ||||
| // constraint. Otherwise, use the create form sort order. | // constraint. Otherwise, use the create form sort order. | ||||
| if ($select_ids) { | if ($select_identifiers) { | ||||
| $forms = array_select_keys($forms, $select_ids) + $forms; | $forms = array_select_keys($forms, $select_identifiers) + $forms; | ||||
| } else { | } else { | ||||
| $forms = msort($forms, 'getCreateSortKey'); | $forms = msort($forms, 'getCreateSortKey'); | ||||
| } | } | ||||
| return $forms; | return $forms; | ||||
| } | } | ||||
| } | } | ||||