Differential D19853 Diff 47434 src/applications/transactions/editengine/PhabricatorEditEngineSubtypeMap.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editengine/PhabricatorEditEngineSubtypeMap.php
| Show All 33 Lines | if (!$this->isValidSubtype($subtype_key)) { | ||||
| pht( | pht( | ||||
| 'Subtype key "%s" does not identify a valid subtype.', | 'Subtype key "%s" does not identify a valid subtype.', | ||||
| $subtype_key)); | $subtype_key)); | ||||
| } | } | ||||
| return $this->subtypes[$subtype_key]; | return $this->subtypes[$subtype_key]; | ||||
| } | } | ||||
| public function getCreateFormsForSubtype( | |||||
| PhabricatorEditEngine $edit_engine, | |||||
| PhabricatorEditEngineSubtypeInterface $object) { | |||||
| $subtype_key = $object->getEditEngineSubtype(); | |||||
| $subtype = $this->getSubtype($subtype_key); | |||||
| // TODO: Allow subtype configuration to specify that children should be | |||||
| // created from particular forms or subtypes. | |||||
| $select_ids = array(); | |||||
| $select_subtypes = array(); | |||||
| $query = $edit_engine->newConfigurationQuery() | |||||
| ->withIsDisabled(false); | |||||
| if ($select_ids) { | |||||
| $query->withIDs($select_ids); | |||||
| } else { | |||||
| // If we're selecting by subtype rather than selecting specific forms, | |||||
| // only select create forms. | |||||
| $query->withIsDefault(true); | |||||
| if ($select_subtypes) { | |||||
| $query->withSubtypes($select_subtypes); | |||||
| } else { | |||||
| $query->withSubtypes(array($subtype_key)); | |||||
| } | |||||
| } | |||||
| $forms = $query->execute(); | |||||
| $forms = mpull($forms, null, 'getIdentifier'); | |||||
| // If we're selecting by ID, respect the order specified in the | |||||
| // constraint. Otherwise, use the create form sort order. | |||||
| if ($select_ids) { | |||||
| $forms = array_select_keys($forms, $select_ids) + $forms; | |||||
| } else { | |||||
| $forms = msort($forms, 'getCreateSortKey'); | |||||
| } | |||||
| return $forms; | |||||
| } | |||||
| } | } | ||||