Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editengine/PhabricatorEditEngine.php
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
/* -( Managing Fields )---------------------------------------------------- */ | /* -( Managing Fields )---------------------------------------------------- */ | ||||
abstract public function getEngineApplicationClass(); | abstract public function getEngineApplicationClass(); | ||||
abstract protected function buildCustomEditFields($object); | abstract protected function buildCustomEditFields($object); | ||||
protected function didBuildCustomEditFields($object, array $fields) { | |||||
return; | |||||
} | |||||
public function getFieldsForConfig( | public function getFieldsForConfig( | ||||
PhabricatorEditEngineConfiguration $config) { | PhabricatorEditEngineConfiguration $config) { | ||||
$object = $this->newEditableObject(); | $object = $this->newEditableObject(); | ||||
$this->editEngineConfiguration = $config; | $this->editEngineConfiguration = $config; | ||||
// This is mostly making sure that we fill in default values. | // This is mostly making sure that we fill in default values. | ||||
Show All 9 Lines | final protected function buildEditFields($object) { | ||||
foreach ($fields as $field) { | foreach ($fields as $field) { | ||||
$field | $field | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setObject($object); | ->setObject($object); | ||||
} | } | ||||
$fields = mpull($fields, null, 'getKey'); | $fields = mpull($fields, null, 'getKey'); | ||||
$this->didBuildCustomEditFields($object, $fields); | |||||
$extensions = PhabricatorEditEngineExtension::getAllEnabledExtensions(); | $extensions = PhabricatorEditEngineExtension::getAllEnabledExtensions(); | ||||
foreach ($extensions as $extension) { | foreach ($extensions as $extension) { | ||||
$extension->setViewer($viewer); | $extension->setViewer($viewer); | ||||
if (!$extension->supportsObject($this, $object)) { | if (!$extension->supportsObject($this, $object)) { | ||||
continue; | continue; | ||||
} | } | ||||
$extension_fields = $extension->buildCustomEditFields($this, $object); | $extension_fields = $extension->buildCustomEditFields($this, $object); | ||||
// TODO: Validate this in more detail with a more tailored error. | // TODO: Validate this in more detail with a more tailored error. | ||||
assert_instances_of($extension_fields, 'PhabricatorEditField'); | assert_instances_of($extension_fields, 'PhabricatorEditField'); | ||||
foreach ($extension_fields as $field) { | foreach ($extension_fields as $field) { | ||||
$field | $field | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setObject($object); | ->setObject($object); | ||||
} | } | ||||
$extension_fields = mpull($extension_fields, null, 'getKey'); | $extension_fields = mpull($extension_fields, null, 'getKey'); | ||||
$extension->didBuildCustomEditFields($this, $object, $extension_fields); | |||||
foreach ($extension_fields as $key => $field) { | foreach ($extension_fields as $key => $field) { | ||||
$fields[$key] = $field; | $fields[$key] = $field; | ||||
} | } | ||||
} | } | ||||
$config = $this->getEditEngineConfiguration(); | $config = $this->getEditEngineConfiguration(); | ||||
$fields = $this->willConfigureFields($object, $fields); | |||||
$fields = $config->applyConfigurationToFields($this, $object, $fields); | $fields = $config->applyConfigurationToFields($this, $object, $fields); | ||||
return $fields; | return $fields; | ||||
} | } | ||||
protected function willConfigureFields($object, array $fields) { | |||||
return $fields; | |||||
} | |||||
/* -( Display Text )------------------------------------------------------- */ | /* -( Display Text )------------------------------------------------------- */ | ||||
/** | /** | ||||
* @task text | * @task text | ||||
*/ | */ | ||||
abstract public function getEngineName(); | abstract public function getEngineName(); | ||||
▲ Show 20 Lines • Show All 1,736 Lines • Show Last 20 Lines |