Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editengine/PhabricatorEditEngine.php
| Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | final protected function buildEditFields($object) { | ||||
| $fields = mpull($fields, null, 'getKey'); | $fields = mpull($fields, null, 'getKey'); | ||||
| if ($this->isEngineExtensible()) { | if ($this->isEngineExtensible()) { | ||||
| $extensions = PhabricatorEditEngineExtension::getAllEnabledExtensions(); | $extensions = PhabricatorEditEngineExtension::getAllEnabledExtensions(); | ||||
| } else { | } else { | ||||
| $extensions = array(); | $extensions = array(); | ||||
| } | } | ||||
| // See T13248. Create a template object to provide to extensions. We | |||||
| // adjust the template to have the intended subtype, so that extensions | |||||
| // may change behavior based on the form subtype. | |||||
| $template_object = clone $object; | |||||
| if ($this->getIsCreate()) { | |||||
| if ($this->supportsSubtypes()) { | |||||
| $config = $this->getEditEngineConfiguration(); | |||||
| $subtype = $config->getSubtype(); | |||||
| $template_object->setSubtype($subtype); | |||||
| } | |||||
| } | |||||
| foreach ($extensions as $extension) { | foreach ($extensions as $extension) { | ||||
| $extension->setViewer($viewer); | $extension->setViewer($viewer); | ||||
| if (!$extension->supportsObject($this, $object)) { | if (!$extension->supportsObject($this, $template_object)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $extension_fields = $extension->buildCustomEditFields($this, $object); | $extension_fields = $extension->buildCustomEditFields( | ||||
| $this, | |||||
| $template_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); | ||||
| ▲ Show 20 Lines • Show All 2,484 Lines • Show Last 20 Lines | |||||